Cannot subclass a Ruby class that implements a Java interface
-------------------------------------------------------------

                 Key: JRUBY-1146
                 URL: http://jira.codehaus.org/browse/JRUBY-1146
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.x
         Environment: JRuby built from head (6/14/07), OSX 10.4, Java 1.5
            Reporter: David Koontz


When instantiating a subclass of a class that implements a method, the 
following exception is thrown:

Exception in thread "main" 
file:/Users/dkoontz/dev/libs/jruby/lib/jruby-complete.jar!/builtin/javasupport/proxy/interface.rb:156:in
 `__jcreate!': Java interface expected. got:  (ArgumentError)
        from 
file:/Users/dkoontz/dev/libs/jruby/lib/jruby-complete.jar!/builtin/javasupport/proxy/interface.rb:138:in
 `send'
        from 
file:/Users/dkoontz/dev/libs/jruby/lib/jruby-complete.jar!/builtin/javasupport/proxy/interface.rb:138:in
 `new'
        from ./bug_report.rb:7
        from <script>:0:in `require'
        from <script>:0
        ...internal jruby stack elided...
        from org.jruby.Ruby.eval(Ruby.java:289)
        from org.jruby.Ruby.evalScript(Ruby.java:282)
        from bugreport.Main.<init>(Main.java:14)
        from bugreport.Main.main(Main.java:18)

Here are the files that demonstrate this.

com/Main.java

package bugreport;

import java.util.ArrayList;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;

public class Main {

    public Main() {
        RubyInstanceConfig config = new RubyInstanceConfig();
        Ruby runtime = Ruby.newInstance(config);
        runtime.getLoadService().init(new ArrayList(0));
        String app =    "require 'java'\n" +
                        "require 'base'\n" +
                        "require 'sub'\n" +
                        "include_class 'bugreport.ExampleInterface'\n" +
                        "class Base\n" +
                        "  include ExampleInterface\n" +
                        "  def testMethod()\n" +
                        "    puts 'in testMethod'\n" +
                        "  end\n" +
                        "end\n" +
                        "class Sub < Base\n" +
                        "end\n" +
                        "b = Base.new\n" +
                        "b.testMethod\n" +
                        "s = Sub.new\n" +
                        "s.testMethod\n";
        runtime.evalScript(app);
    }

    public static void main(String[] args) {
        Main m = new Main();
    }
}

com/TestInterface.java

package bugreport;

public interface ExampleInterface {
    public void testMethod();
}

-- 
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