"Java wrapper with no contents" error when subclassing a Runnable class in JRuby
--------------------------------------------------------------------------------

                 Key: JRUBY-4704
                 URL: http://jira.codehaus.org/browse/JRUBY-4704
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.5
            Reporter: Gergely Nagy
         Attachments: runner-bugger.jar, runner-bugger.rb

The following code will result in a RuntimeError "Java wrapper with no 
contents" in JRuby 1.5 
(rev c0c1314f7912b8bb26e99cd621e4a3f5786c7978).

{code:title=runner-bugger.java|borderStyle=solid}
require 'java'

class RunnableProc < Java::Bug::AbstractRunnable
    def initialize &block
      @block = block
    end

    def doRun
      @block.call
    end
end
  
Java::Bug::Runner.run(RunnableProc.new { # JRuby 1.5 bombs out here, 1.4 and 
1.2 will call this back fine:
   puts "extend AbstractRunnable works :)"
})


{code}


Using the following Java classes:
{code:title=AbstractRunnable.java|borderStyle=solid}
package bug;
public abstract class AbstractRunnable implements Runnable {
    public void run() {
        System.out.println("calling into ruby:");
        doRun();
        System.out.println("calling into ruby: finished");
    }
    protected abstract void doRun();
}
{code} 

{code:title=Runner.java|borderStyle=solid}
package bug;
public class Runner {
    public static void run(Runnable r) {
        System.err.println("Calling r");
        r.run();
        System.err.println("Calling r..done");
    }
}
{code}

As mentioned in the comment above, JRuby 1.2 .. 1.4 will work fine, saying:
{code}
Calling r
calling into ruby:
extend AbstractRunnable works :)
calling into ruby: finished
Calling r..done
{code}

I'm attaching the above for convenience, am running it like this:
{code}
java -jar jruby-complete.jar -r runner-bugger.jar runner-bugger.rb
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to