Martin Kleppmann created JRUBY-6635:
---------------------------------------

             Summary: Java superclass method is not visible to JRuby
                 Key: JRUBY-6635
                 URL: https://jira.codehaus.org/browse/JRUBY-6635
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.6.7
         Environment: Mac OS X 10.7.3
Java(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3635)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01-415, mixed mode)
            Reporter: Martin Kleppmann


In some specific circumstances, methods defined on Java classes are not 
callable from JRuby. I have observed this happening when the following things 
come together:

* the instantiated class is a subclass of another Java class,
* the superclass has default visibility,
* the superclass has a generic type parameter, and
* a method is defined on the superclass whose return type is the generic type 
parameter.

In these circumstances, JRuby thinks that this method does not exist. (It's 
particularly curious that if the method has a non-generic return type, the 
method *is* callable from JRuby!)

Example, using JRuby installed via Maven:

{noformat}
$ cat Superclass.java 

class Superclass<T> {
    private T proto;
    public T getProto() { return proto; }
}

$ cat Subclass.java 

public class Subclass extends Superclass<String> {}

$ javac Superclass.java Subclass.java 

$ java -cp 
.:$HOME/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar 
org.jruby.Main -S irb

irb(main):001:0> java_import Java::Subclass
=> Java::Default::Subclass

irb(main):002:0> Subclass.new.proto
NoMethodError: undefined method `proto' for 
#<Java::Default::Subclass:0x622f996f>
        from (irb):2:in `evaluate'
        from org/jruby/RubyKernel.java:1083:in `eval'
        from 
file:/Users/martin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:158:in
 `eval_input'
        from 
file:/Users/martin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:271:in
 `signal_status'
        from 
file:/Users/martin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:155:in
 `eval_input'
        from org/jruby/RubyKernel.java:1410:in `loop'
        from org/jruby/RubyKernel.java:1183:in `catch'
        from 
file:/Users/martin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:154:in
 `eval_input'
        from 
file:/Users/martin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:71:in
 `start'
        from org/jruby/RubyKernel.java:1183:in `catch'
        from 
file:/Users/martin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:70:in
 `start'
        from /Users/martin/Applications/jruby/bin/jirb:13:in `(root)'
{noformat}

The same exception occurs when trying to call {{get_proto}} or {{getProto}}.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.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