Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8a9ea3eb1ab5
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 62645daf8ad7
Choose a head ref

Commits on Feb 6, 2015

  1. Copy the full SHA
    59a98d5 View commit details
  2. Copy the full SHA
    0549508 View commit details
  3. Copy the full SHA
    cf87818 View commit details
  4. make sure javaClass.setupProxy is the last call when creating proxy c…

    …lass
    
    + make the related code more readable
    kares committed Feb 6, 2015
    Copy the full SHA
    f1783d4 View commit details
  5. Copy the full SHA
    12df245 View commit details
  6. Copy the full SHA
    a851363 View commit details
  7. unify proxy class/module setup and hide methods such as lockProxy whi…

    …ch are internal
    
    also hidden JavaClass' constructor as if it's ever instantiated outside JavaSupport's class-value cache it will start to break things badly
    kares committed Feb 6, 2015
    Copy the full SHA
    00fcfac View commit details
  8. Copy the full SHA
    45598f3 View commit details
  9. Copy the full SHA
    2c50057 View commit details
  10. Copy the full SHA
    edf6e23 View commit details
  11. simplify JavaObject internals avoiding unnecessary NPEs + fix compari…

    …son typos
    
    ... `obj == NEVER` when really unwrapped value was meant to be compared
    kares committed Feb 6, 2015
    Copy the full SHA
    0a85017 View commit details
  12. Copy the full SHA
    bb872d3 View commit details
  13. Copy the full SHA
    9f4e000 View commit details
  14. Copy the full SHA
    45940a4 View commit details
  15. Copy the full SHA
    45d1fa0 View commit details
  16. Copy the full SHA
    ef3a93e View commit details
  17. guard against concurrent Java:: package module initializations (in mu…

    …ltiple threads)
    
    avoid warnings such as rb:42 warning: already initialized constant JavaUtilConcurrent
    
    probably related to #2014
    kares committed Feb 6, 2015
    Copy the full SHA
    aadfcd0 View commit details
  18. Copy the full SHA
    29e27e0 View commit details
  19. Copy the full SHA
    4327ffe View commit details
  20. unify internal Java class loading into a single getProxyClassOrNull m…

    …ethod
    
    ... has a desired side effect of improving "initial" performance
    due not re-raising ClassNotFoundExceptions within the Ruby runtime
    
    they also will no longer be reported by the runtime with log.exeptions=true
    kares committed Feb 6, 2015
    Copy the full SHA
    77ef13e View commit details
  21. simplify and avoid unnecessary code

    - only pass context to (internal) getTopLevelProxyOrPackage method
    - setupJavaClass does not need a java_class argument (it's not used)
    - only intern string on addMethod (although it's likely redundat there as well)
    kares committed Feb 6, 2015
    Copy the full SHA
    b0b0f46 View commit details
  22. Copy the full SHA
    6b96e53 View commit details
  23. Copy the full SHA
    728cd87 View commit details
  24. name.trim-ing seems "dangerous" as we're assuming a valid constant na…

    …me up the stack
    
    ... it very likely never-ever trimmed anything
    kares committed Feb 6, 2015
    Copy the full SHA
    ad8a71a View commit details
  25. Copy the full SHA
    8fbf8dc View commit details
  26. Copy the full SHA
    7269a84 View commit details
  27. Copy the full SHA
    f4e7711 View commit details
  28. Copy the full SHA
    892f903 View commit details
  29. Copy the full SHA
    3584149 View commit details
  30. refactor internal getRuntime invokes (esp. in loops) - pass it around

    also (package) "internalized" JavaClass.getRubyArray as toRubyArray
    kares committed Feb 6, 2015
    Copy the full SHA
    57195fa View commit details
  31. Copy the full SHA
    26e0a22 View commit details
  32. Copy the full SHA
    fcb53b8 View commit details
  33. rename ProxyMethodImpl's internal fields (for better identification) …

    …& also :
    
    - invoke implementation now avoids unnecessary System.arraycopy call
    - pre-maturily optimized some from "excessive" getRuntime() invocations
    kares committed Feb 6, 2015
    Copy the full SHA
    904606a View commit details
  34. Copy the full SHA
    847655f View commit details
  35. Copy the full SHA
    9f423fe View commit details
  36. Copy the full SHA
    7ac67f5 View commit details
  37. Copy the full SHA
    24c7380 View commit details
  38. Copy the full SHA
    bb26fcb View commit details
  39. Copy the full SHA
    51fde2b View commit details
  40. Copy the full SHA
    a20c166 View commit details
  41. Copy the full SHA
    9a55be8 View commit details
  42. Copy the full SHA
    debe720 View commit details
  43. Copy the full SHA
    f829378 View commit details
  44. Copy the full SHA
    8044d79 View commit details
  45. less (duplicate - initialization) instance state to keep in JavaClass…

    … - re-arranged privates
    kares committed Feb 6, 2015
    Copy the full SHA
    66f79e9 View commit details

Commits on Feb 24, 2015

  1. Copy the full SHA
    0ca486c View commit details

Commits on Feb 26, 2015

  1. Use a single global lock for proxy creation to avoid deadlocks.

    This is a temporary measure to avoid deadlocks when multiple
    threads load mutually-dependent Java classes. We should replace
    this with some sort of atomic update of the proxy classes.
    
    Temporary fix for #1621.
    headius committed Feb 26, 2015
    Copy the full SHA
    1ad3c67 View commit details
  2. Begin refactoring JavaClass binding logic.

    * All inner classes moved to top-level.
    * All during-binding state moved to initializer objects.
    * Utility code used only for binding moved to initializers.
    headius committed Feb 26, 2015
    Copy the full SHA
    5755383 View commit details
  3. Clean up imports.

    headius committed Feb 26, 2015
    Copy the full SHA
    e53e2cb View commit details
  4. Copy the full SHA
    7f4f43c View commit details
Showing with 3,298 additions and 3,018 deletions.
  1. +25 −18 core/src/main/java/org/jruby/java/invokers/ConstructorInvoker.java
  2. +2 −1 core/src/main/java/org/jruby/java/invokers/FieldMethodOne.java
  3. +2 −1 core/src/main/java/org/jruby/java/invokers/FieldMethodZero.java
  4. +9 −2 core/src/main/java/org/jruby/java/invokers/MethodInvoker.java
  5. +165 −146 core/src/main/java/org/jruby/java/proxies/ConcreteJavaProxy.java
  6. +139 −157 core/src/main/java/org/jruby/java/proxies/JavaProxy.java
  7. +589 −541 core/src/main/java/org/jruby/javasupport/Java.java
  8. +9 −8 core/src/main/java/org/jruby/javasupport/JavaCallable.java
  9. +224 −1,413 core/src/main/java/org/jruby/javasupport/JavaClass.java
  10. +1 −1 core/src/main/java/org/jruby/javasupport/JavaMethod.java
  11. +65 −73 core/src/main/java/org/jruby/javasupport/JavaObject.java
  12. +9 −0 core/src/main/java/org/jruby/javasupport/JavaSupport.java
  13. +117 −105 core/src/main/java/org/jruby/javasupport/JavaSupportImpl.java
  14. +45 −0 core/src/main/java/org/jruby/javasupport/JavaUtil.java
  15. +15 −0 core/src/main/java/org/jruby/javasupport/binding/AssignedName.java
  16. +221 −0 core/src/main/java/org/jruby/javasupport/binding/ClassInitializer.java
  17. +38 −0 core/src/main/java/org/jruby/javasupport/binding/ConstantField.java
  18. +50 −0 core/src/main/java/org/jruby/javasupport/binding/ConstructorInvokerInstaller.java
  19. +16 −0 core/src/main/java/org/jruby/javasupport/binding/FieldInstaller.java
  20. +535 −0 core/src/main/java/org/jruby/javasupport/binding/Initializer.java
  21. +23 −0 core/src/main/java/org/jruby/javasupport/binding/InstanceFieldGetterInstaller.java
  22. +23 −0 core/src/main/java/org/jruby/javasupport/binding/InstanceFieldSetterInstaller.java
  23. +22 −0 core/src/main/java/org/jruby/javasupport/binding/InstanceMethodInvokerInstaller.java
  24. +89 −0 core/src/main/java/org/jruby/javasupport/binding/InterfaceInitializer.java
  25. +40 −0 core/src/main/java/org/jruby/javasupport/binding/MethodInstaller.java
  26. +34 −0 core/src/main/java/org/jruby/javasupport/binding/NamedInstaller.java
  27. +31 −0 core/src/main/java/org/jruby/javasupport/binding/Priority.java
  28. +31 −0 core/src/main/java/org/jruby/javasupport/binding/SingletonMethodInvokerInstaller.java
  29. +23 −0 core/src/main/java/org/jruby/javasupport/binding/StaticFieldGetterInstaller.java
  30. +23 −0 core/src/main/java/org/jruby/javasupport/binding/StaticFieldSetterInstaller.java
  31. +26 −0 core/src/main/java/org/jruby/javasupport/binding/StaticMethodInvokerInstaller.java
  32. +183 −156 core/src/main/java/org/jruby/javasupport/proxy/JavaProxyClass.java
  33. +221 −244 core/src/main/java/org/jruby/javasupport/proxy/JavaProxyClassFactory.java
  34. +53 −36 core/src/main/java/org/jruby/javasupport/proxy/JavaProxyReflectionObject.java
  35. +2 −1 core/src/main/java/org/jruby/util/ShellLauncher.java
  36. +3 −4 core/src/main/java/org/jruby/util/collections/Java7ClassValue.java
  37. +14 −10 core/src/main/java/org/jruby/util/collections/MapBasedClassValue.java
  38. +7 −7 core/src/main/ruby/jruby/java/java_ext/java.util.rb
  39. +6 −17 core/src/main/ruby/jruby/java/java_module.rb
  40. +2 −2 core/src/main/ruby/jruby/java/java_utilities.rb
  41. +109 −63 test/jruby/test_higher_javasupport.rb
  42. +57 −12 test/jruby/test_java_extension.rb
43 changes: 25 additions & 18 deletions core/src/main/java/org/jruby/java/invokers/ConstructorInvoker.java
Original file line number Diff line number Diff line change
@@ -14,43 +14,50 @@
import org.jruby.runtime.builtin.IRubyObject;

public class ConstructorInvoker extends RubyToJavaInvoker {

public ConstructorInvoker(RubyModule host, List<Constructor> ctors) {
super(host, ctors.toArray(new Constructor[ctors.size()]));

trySetAccessible(getAccessibleObjects());
}

@Override
protected JavaCallable createCallable(Ruby ruby, Member member) {
return JavaConstructor.create(ruby, (Constructor)member);
}

@Override
protected JavaCallable[] createCallableArray(JavaCallable callable) {
return new JavaConstructor[] {(JavaConstructor)callable};
}

@Override
protected JavaCallable[] createCallableArray(int size) {
return new JavaConstructor[size];
}

@Override
protected JavaCallable[][] createCallableArrayArray(int size) {
return new JavaConstructor[size][];
}

@Override
protected Class[] getMemberParameterTypes(Member member) {
return ((Constructor)member).getParameterTypes();
return ((Constructor) member).getParameterTypes();
}

@Override
protected boolean isMemberVarArgs(Member member) {
return ((Constructor)member).isVarArgs();
return ((Constructor) member).isVarArgs();
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) {
JavaProxy proxy = castJavaProxy(self);

int len = args.length;
Object[] convertedArgs = new Object[len];
JavaConstructor constructor = (JavaConstructor)findCallable(self, name, args, len);
final Object[] convertedArgs;
JavaConstructor constructor = (JavaConstructor) findCallable(self, name, args, len);
if (constructor.isVarArgs()) {
len = constructor.getParameterTypes().length - 1;
convertedArgs = new Object[len + 1];
@@ -64,7 +71,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
convertedArgs[i] = convertArg(args[i], constructor, i);
}
}

proxy.setObject(constructor.newInstanceDirect(context, convertedArgs));

return self;
@@ -74,7 +81,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) {
if (javaVarargsCallables != null) return call(context, self, clazz, name, IRubyObject.NULL_ARRAY);
JavaProxy proxy = castJavaProxy(self);
JavaConstructor constructor = (JavaConstructor)findCallableArityZero(self, name);
JavaConstructor constructor = (JavaConstructor) findCallableArityZero(self, name);

proxy.setObject(constructor.newInstanceDirect(context));

@@ -85,7 +92,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0) {
if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0});
JavaProxy proxy = castJavaProxy(self);
JavaConstructor constructor = (JavaConstructor)findCallableArityOne(self, name, arg0);
JavaConstructor constructor = (JavaConstructor) findCallableArityOne(self, name, arg0);
Object cArg0 = convertArg(arg0, constructor, 0);

proxy.setObject(constructor.newInstanceDirect(context, cArg0));
@@ -97,7 +104,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) {
if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1});
JavaProxy proxy = castJavaProxy(self);
JavaConstructor constructor = (JavaConstructor)findCallableArityTwo(self, name, arg0, arg1);
JavaConstructor constructor = (JavaConstructor) findCallableArityTwo(self, name, arg0, arg1);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(arg1, constructor, 1);

@@ -110,7 +117,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
if (javaVarargsCallables != null) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1, arg2});
JavaProxy proxy = castJavaProxy(self);
JavaConstructor constructor = (JavaConstructor)findCallableArityThree(self, name, arg0, arg1, arg2);
JavaConstructor constructor = (JavaConstructor) findCallableArityThree(self, name, arg0, arg1, arg2);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(arg1, constructor, 1);
Object cArg2 = convertArg(arg2, constructor, 2);
@@ -120,18 +127,18 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
return self;
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
if (block.isGiven()) {
Ruby runtime = context.runtime;
JavaProxy proxy = castJavaProxy(self);

int len = args.length;
// too much array creation!
Object[] convertedArgs = new Object[len + 1];
IRubyObject[] intermediate = new IRubyObject[len + 1];
System.arraycopy(args, 0, intermediate, 0, len);
intermediate[len] = RubyProc.newProc(runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallable(self, name, intermediate, len + 1);
intermediate[len] = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor) findCallable(self, name, intermediate, len + 1);
for (int i = 0; i < len + 1; i++) {
convertedArgs[i] = convertArg(intermediate[i], constructor, i);
}
@@ -150,7 +157,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
JavaProxy proxy = castJavaProxy(self);

RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityOne(self, name, proc);
JavaConstructor constructor = (JavaConstructor) findCallableArityOne(self, name, proc);
Object cArg0 = convertArg(proc, constructor, 0);

proxy.setObject(constructor.newInstanceDirect(context, cArg0));
@@ -167,7 +174,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
JavaProxy proxy = castJavaProxy(self);

RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityTwo(self, name, arg0, proc);
JavaConstructor constructor = (JavaConstructor) findCallableArityTwo(self, name, arg0, proc);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(proc, constructor, 1);

@@ -185,7 +192,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
JavaProxy proxy = castJavaProxy(self);

RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityThree(self, name, arg0, arg1, proc);
JavaConstructor constructor = (JavaConstructor) findCallableArityThree(self, name, arg0, arg1, proc);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(arg1, constructor, 1);
Object cArg2 = convertArg(proc, constructor, 2);
@@ -204,7 +211,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
JavaProxy proxy = castJavaProxy(self);

RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityFour(self, name, arg0, arg1, arg2, proc);
JavaConstructor constructor = (JavaConstructor) findCallableArityFour(self, name, arg0, arg1, arg2, proc);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(arg1, constructor, 1);
Object cArg2 = convertArg(arg2, constructor, 2);
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
import org.jruby.runtime.Visibility;

public abstract class FieldMethodOne extends JavaMethodOne {
Field field;

final Field field;

FieldMethodOne(String name, RubyModule host, Field field) {
super(host, Visibility.PUBLIC);
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
import org.jruby.runtime.builtin.IRubyObject;

public abstract class FieldMethodZero extends JavaMethodZero {
Field field;

final Field field;

FieldMethodZero(String name, RubyModule host, Field field) {
super(host, Visibility.PUBLIC);
11 changes: 9 additions & 2 deletions core/src/main/java/org/jruby/java/invokers/MethodInvoker.java
Original file line number Diff line number Diff line change
@@ -19,27 +19,34 @@ public abstract class MethodInvoker extends RubyToJavaInvoker {
trySetAccessible(getAccessibleObjects());
}

@Override
protected JavaCallable createCallable(Ruby ruby, Member member) {
return JavaMethod.create(ruby, (Method)member);
}

@Override
protected JavaCallable[] createCallableArray(JavaCallable callable) {
return new JavaMethod[] {(JavaMethod)callable};
}

@Override
protected JavaCallable[] createCallableArray(int size) {
return new JavaMethod[size];
}

@Override
protected JavaCallable[][] createCallableArrayArray(int size) {
return new JavaMethod[size][];
}

@Override
protected Class[] getMemberParameterTypes(Member member) {
return ((Method)member).getParameterTypes();
return ((Method) member).getParameterTypes();
}

@Override
protected boolean isMemberVarArgs(Member member) {
return ((Method)member).isVarArgs();
return ((Method) member).isVarArgs();
}

}
Loading