Browse files

Fix JRUBY-6932

ruby block without arguments for itemStateChanged in 1.9 can fail

We were forcing all blocks-as-interfaces to be LAMBDA, rather than
just going with the natural type of the block. Changed to use
natural type.
  • Loading branch information...
1 parent ad753d1 commit 67f111ecc3c2f795d922c076b105aa21917289fe @headius headius committed Oct 15, 2012
View
10 src/org/jruby/java/invokers/ConstructorInvoker.java
@@ -130,7 +130,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
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.LAMBDA);
+ intermediate[len] = RubyProc.newProc(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);
@@ -149,7 +149,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityOne(self, name, proc);
Object cArg0 = convertArg(proc, constructor, 0);
@@ -166,7 +166,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityTwo(self, name, arg0, proc);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(proc, constructor, 1);
@@ -184,7 +184,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityThree(self, name, arg0, arg1, proc);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(arg1, constructor, 1);
@@ -203,7 +203,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaConstructor constructor = (JavaConstructor)findCallableArityFour(self, name, arg0, arg1, arg2, proc);
Object cArg0 = convertArg(arg0, constructor, 0);
Object cArg1 = convertArg(arg1, constructor, 1);
View
10 src/org/jruby/java/invokers/InstanceMethodInvoker.java
@@ -90,7 +90,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
Object[] convertedArgs = new Object[len + 1];
IRubyObject[] intermediate = new IRubyObject[len + 1];
System.arraycopy(args, 0, intermediate, 0, len);
- intermediate[len] = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ intermediate[len] = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallable(self, name, intermediate, len + 1);
for (int i = 0; i < len + 1; i++) {
convertedArgs[i] = convertArg(intermediate[i], method, i);
@@ -105,7 +105,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityOne(self, name, proc);
Object cArg0 = convertArg(proc, method, 0);
return method.invokeDirect(proxy.getObject(), cArg0);
@@ -118,7 +118,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) {
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(proc, method, 1);
@@ -132,7 +132,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, Block block) {
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityThree(self, name, arg0, arg1, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(arg1, method, 1);
@@ -147,7 +147,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, Block block) {
if (block.isGiven()) {
JavaProxy proxy = castJavaProxy(self);
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityFour(self, name, arg0, arg1, arg2, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(arg1, method, 1);
View
10 src/org/jruby/java/invokers/SingletonMethodInvoker.java
@@ -92,7 +92,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
Object[] convertedArgs = new Object[len + 1];
IRubyObject[] intermediate = new IRubyObject[len + 1];
System.arraycopy(args, 0, intermediate, 0, len);
- intermediate[len] = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ intermediate[len] = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallable(self, name, intermediate, len + 1);
for (int i = 0; i < len + 1; i++) {
convertedArgs[i] = convertArg(intermediate[i], method, i);
@@ -107,7 +107,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityOne(self, name, proc);
Object cArg0 = convertArg(proc, method, 0);
@@ -120,7 +120,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(proc, method, 1);
@@ -134,7 +134,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityThree(self, name, arg0, arg1, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(arg1, method, 1);
@@ -149,7 +149,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityFour(self, name, arg0, arg1, arg2, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(arg1, method, 1);
View
10 src/org/jruby/java/invokers/StaticMethodInvoker.java
@@ -88,7 +88,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
Object[] convertedArgs = new Object[len + 1];
IRubyObject[] intermediate = new IRubyObject[len + 1];
System.arraycopy(args, 0, intermediate, 0, len);
- intermediate[len] = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ intermediate[len] = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallable(self, name, intermediate, len + 1);
for (int i = 0; i < len + 1; i++) {
convertedArgs[i] = convertArg(intermediate[i], method, i);
@@ -103,7 +103,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityOne(self, name, proc);
Object cArg0 = convertArg(proc, method, 0);
@@ -116,7 +116,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityTwo(self, name, arg0, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(proc, method, 1);
@@ -130,7 +130,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityThree(self, name, arg0, arg1, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(arg1, method, 1);
@@ -145,7 +145,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
if (block.isGiven()) {
- RubyProc proc = RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA);
+ RubyProc proc = RubyProc.newProc(context.runtime, block, block.type);
JavaMethod method = (JavaMethod)findCallableArityFour(self, name, arg0, arg1, arg2, proc);
Object cArg0 = convertArg(arg0, method, 0);
Object cArg1 = convertArg(arg1, method, 1);
View
2 src/org/jruby/java/proxies/InterfaceJavaProxy.java
@@ -48,7 +48,7 @@ public static IRubyObject initialize(ThreadContext context, IRubyObject self, IR
Ruby runtime = context.runtime;
self.getInstanceVariables().setInstanceVariable("@java_class", JavaClass.forNameVerbose(runtime, javaClassName.asJavaString()));
- self.getInstanceVariables().setInstanceVariable("@block", RubyProc.newProc(runtime, block, Block.Type.PROC));
+ self.getInstanceVariables().setInstanceVariable("@block", RubyProc.newProc(runtime, block, block.type));
return runtime.getNil();
}
View
2 src/org/jruby/util/SunSignalFacade.java
@@ -173,6 +173,6 @@ public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block)
final RubyModule signalModule = runtime.getModule("Signal");
Block block = CallBlock.newCallClosure(signalModule, signalModule, Arity.noArguments(),
callback, runtime.getCurrentContext());
- return RubyProc.newProc(runtime, block, Block.Type.NORMAL);
+ return RubyProc.newProc(runtime, block, block.type);
}
}// SunSignalFacade

0 comments on commit 67f111e

Please sign in to comment.