AssertionError at handling of inner inherited Java interface
------------------------------------------------------------

                 Key: JRUBY-4794
                 URL: http://jira.codehaus.org/browse/JRUBY-4794
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.5
            Reporter: Tobias Vogele


When a Java method returns an object to Ruby, which is an instance of a class, 
which implements an inner interface of another class, an AssertionError is 
thrown (when running with assertion enabled, ie. using the Java command line 
parameter "-ea").

It seems, that the problem is: First proxy for the class is initialized. Then 
its interfaces are initialized, so the inner interface is initialized. That all 
its surrounding types are initialized, so the outer interface is initialized. 
Then the the inner types of that outer type are initialized, so the inner 
interface is initialized again. Then the assertion "assert this.proxyModule == 
null;" fails.

Code to reproduce:

{code:title=JRuby script}
Java::Blubber::A.doIt
{code} 
{code:title=Java Code}
package blubber;

public class A {
  public static Object doIt() {
    return new C();
  }
}

interface B {
  interface BInner {
  }
}

class C implements B.BInner {
}

{code}


The stacktrace is: 
{code}
org/jruby/javasupport/JavaClass.java:889:in `setupInterfaceModule': 
java.lang.AssertionError: null (NativeException)
        from org/jruby/javasupport/Java.java:377:in `getInterfaceModule'
        from org/jruby/javasupport/Java.java:453:in `getProxyClass'
        from org/jruby/javasupport/Java.java:354:in `getInstance'
        from org/jruby/javasupport/JavaUtil.java:143:in 
`convertJavaToUsableRubyObject'
        from org/jruby/javasupport/JavaMethod.java:586:in `convertReturn'
        from org/jruby/javasupport/JavaMethod.java:502:in 
`invokeDirectWithExceptionHandling'
        from docs/playground/run_as_ruby_app.rb:2
{code}


A real life usecase (which is a little bit more complicated..), are the swing 
text classes. Here the problem occurs in particular with the classes 
javax.swing.text.LayeredHighlighter.LayerPainter and 
javax.swing.text.Highlighter.HighlightPainter.
Therefore another way to reproduce the problem is to call 
"Java::JavaxSwing::JTextArea.new().getUI()" in JRuby.

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