JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6828

TypeError when returning non-nil from a proc called from Java by interface

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1, JRuby 1.7.0.pre2
    • Fix Version/s: JRuby 1.7.0.RC1
    • Component/s: Embedding, Java Integration
    • Labels:
      None
    • Environment:
      Only reproduced in Ruboto, yet.
      Android 2.3/4.1
      Java 6/7
    • Number of attachments :
      0

      Description

      We register a proc as an onClickListener and if the proc returns nil everything is OK, but if it returns non-nil we get this error:

      W/System.err( 1846): org.jruby.exceptions.RaiseException: (TypeError) failed to coerce org.rubototest.multiact.MultiactActivity to void
      

      Downgrading to JRuby 1.6.7.2 works, so I would call it a regression.

      A workaround is to add "; nil" to the end of the block.

      Here is a stack trace of the call into the proc:

      W/System.err( 1914): 	at java.lang.reflect.Constructor.constructNative(Native Method)
      W/System.err( 1914): 	at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
      W/System.err( 1914): 	at org.jruby.javasupport.JavaConstructor.newInstanceDirect(JavaConstructor.java:275)
      W/System.err( 1914): 	at org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:91)
      W/System.err( 1914): 	at org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:178)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:322)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:178)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:182)
      W/System.err( 1914): 	at org.jruby.java.proxies.ConcreteJavaProxy$2.call(ConcreteJavaProxy.java:52)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:322)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:178)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:182)
      W/System.err( 1914): 	at org.jruby.RubyClass.newInstance(RubyClass.java:863)
      W/System.err( 1914): 	at org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
      W/System.err( 1914): 	at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrNBlock.call(JavaMethod.java:274)
      W/System.err( 1914): 	at org.jruby.java.proxies.ConcreteJavaProxy$3.call(ConcreteJavaProxy.java:148)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
      W/System.err( 1914): 	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
      W/System.err( 1914): 	at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
      W/System.err( 1914): 	at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
      W/System.err( 1914): 	at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
      W/System.err( 1914): 	at org.jruby.ast.RescueNode.executeBody(RescueNode.java:226)
      W/System.err( 1914): 	at org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:123)
      W/System.err( 1914): 	at org.jruby.ast.RescueNode.interpret(RescueNode.java:113)
      W/System.err( 1914): 	at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
      W/System.err( 1914): 	at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
      W/System.err( 1914): 	at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
      W/System.err( 1914): 	at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
      W/System.err( 1914): 	at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:209)
      W/System.err( 1914): 	at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:197)
      W/System.err( 1914): 	at org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:128)
      W/System.err( 1914): 	at org.jruby.runtime.Block.call(Block.java:89)
      W/System.err( 1914): 	at org.jruby.RubyProc.call(RubyProc.java:271)
      W/System.err( 1914): 	at org.jruby.RubyProc.call(RubyProc.java:223)
      W/System.err( 1914): 	at org.jruby.javasupport.JavaUtil$1.call(JavaUtil.java:237)
      W/System.err( 1914): 	at org.jruby.javasupport.util.RuntimeHelpers$MethodMissingMethod.call(RuntimeHelpers.java:489)
      W/System.err( 1914): 	at org.jruby.javasupport.util.RuntimeHelpers.callMethodMissing(RuntimeHelpers.java:416)
      W/System.err( 1914): 	at org.jruby.RubyClass.finvoke(RubyClass.java:728)
      W/System.err( 1914): 	at org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:549)
      W/System.err( 1914): 	at org.jruby.javasupport.Java$6.invoke(Java.java:1193)
      W/System.err( 1914): 	at $Proxy0.onClick(Native Method)
      W/System.err( 1914): 	at android.view.View.performClick(View.java:4084)
      W/System.err( 1914): 	at android.view.View$PerformClick.run(View.java:16966)
      W/System.err( 1914): 	at android.os.Handler.handleCallback(Handler.java:615)
      W/System.err( 1914): 	at android.os.Handler.dispatchMessage(Handler.java:92)
      W/System.err( 1914): 	at android.os.Looper.loop(Looper.java:137)
      W/System.err( 1914): 	at android.app.ActivityThread.main(ActivityThread.java:4745)
      W/System.err( 1914): 	at java.lang.reflect.Method.invokeNative(Native Method)
      W/System.err( 1914): 	at java.lang.reflect.Method.invoke(Method.java:511)
      W/System.err( 1914): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
      W/System.err( 1914): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
      W/System.err( 1914): 	at dalvik.system.NativeStart.main(Native Method)
      

      Any help is welcome.

        Activity

        Hide
        Uwe Kubosch added a comment -

        Bisect gave the following:

        f9ca028c26d3b3a34e641a49f14804c47c9c9524 is the first bad commit
        commit f9ca028c26d3b3a34e641a49f14804c47c9c9524
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Wed May 9 16:54:58 2012 -0500
        
            Allow primitive boxes to pass for primitive toJava targets.
            
            Fixes #165.
        
        :040000 040000 a0770b329d1d5db3c74dc9d3d2f3522370d5b972 90f84476b796ac8330d9821e6925f514ecbbf743 M	spec
        :040000 040000 cfcaef629fa4c9dcba45aff24fa4e1c3a277a221 958df5f0c929aa9f80e99a3a79fe5731a71437d7 M	src
        
        Show
        Uwe Kubosch added a comment - Bisect gave the following: f9ca028c26d3b3a34e641a49f14804c47c9c9524 is the first bad commit commit f9ca028c26d3b3a34e641a49f14804c47c9c9524 Author: Charles Oliver Nutter <headius@headius.com> Date: Wed May 9 16:54:58 2012 -0500 Allow primitive boxes to pass for primitive toJava targets. Fixes #165. :040000 040000 a0770b329d1d5db3c74dc9d3d2f3522370d5b972 90f84476b796ac8330d9821e6925f514ecbbf743 M spec :040000 040000 cfcaef629fa4c9dcba45aff24fa4e1c3a277a221 958df5f0c929aa9f80e99a3a79fe5731a71437d7 M src
        Hide
        Charles Oliver Nutter added a comment -

        The fix is in. Unfortunately I don't know how to simulate the test case you have in Ruboto, so that part's on you. The only test case I could come up with is perhaps too trivial, but I'll add it somewhere.

        commit 99ef233e2c433131709007deae6047b6fffeda94
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Fri Aug 10 13:42:46 2012 -0500
        
            Concrete Java classes should coerce to void as null.
        
        :100644 100644 29e15cf... 2709035... M	src/org/jruby/java/proxies/ConcreteJavaProxy.java
        
        Show
        Charles Oliver Nutter added a comment - The fix is in. Unfortunately I don't know how to simulate the test case you have in Ruboto, so that part's on you. The only test case I could come up with is perhaps too trivial, but I'll add it somewhere. commit 99ef233e2c433131709007deae6047b6fffeda94 Author: Charles Oliver Nutter <headius@headius.com> Date: Fri Aug 10 13:42:46 2012 -0500 Concrete Java classes should coerce to void as null. :100644 100644 29e15cf... 2709035... M src/org/jruby/java/proxies/ConcreteJavaProxy.java

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Uwe Kubosch
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: