Skip to content

Commit

Permalink
Fix JRUBY-6932
Browse files Browse the repository at this point in the history
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
headius committed Oct 15, 2012
1 parent ad753d1 commit 67f111e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/org/jruby/java/invokers/ConstructorInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/org/jruby/java/invokers/InstanceMethodInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/org/jruby/java/invokers/SingletonMethodInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/org/jruby/java/invokers/StaticMethodInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/org/jruby/java/proxies/InterfaceJavaProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/jruby/util/SunSignalFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.