convertJavaToUsableRubyObject throws AssertionError

I’m calling JavaUtil.convertJavaToUsableRubyObject but an
AssertionError is thrown at at
org.jruby.javasupport.JavaClass.setupProxy(JavaClass.java:679). That
line reads “assert this.proxyClass == null;”.

A simple test program that uses convertJavaToUsableRubyObject on a
simpler instance of the same class.

I’ve sucessfully used convertJavaToUsableRubyObject in a smaller test
program to convert objects of the same type, though the test objects
aren’t as “deep”.

I’m using JRuby 1.1.3. Here’s the top of the stack trace.

Exception in thread “ThreadPool.MyThread:HttpServer-main:0”
java.lang.AssertionError
at
org.jruby.javasupport.JavaClass.setupProxy(JavaClass.java:679)
at org.jruby.javasupport.Java.createProxyClass(Java.java:533)
at org.jruby.javasupport.Java.getProxyClass(Java.java:487)
at org.jruby.javasupport.Java.getProxyClass(Java.java:487)
at org.jruby.javasupport.Java.getProxyClass(Java.java:487)
at org.jruby.javasupport.Java.getProxyClass(Java.java:487)
at org.jruby.javasupport.Java.getInstance(Java.java:335)
at
org.jruby.javasupport.JavaUtil.convertJavaToUsableRubyObject(JavaUtil.java:420)
at
ed.lang.ruby.RubyJxpSource._exposeScope(RubyJxpSource.java:168)

Any ideas what I’m doing wrong?

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Jim M. wrote:

Any ideas what I’m doing wrong?

Exposing a bug? :slight_smile:

Seriously though, could you re-try against trunk and file as a bug if
it’s still broken there? Sounds like a bad bit of logic somewhere in
Java type conversion.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Charles,

On Wed, Aug 20, 2008 at 12:12 PM, Charles Oliver N.
[email protected] wrote:

Jim M. wrote:

Any ideas what I’m doing wrong?

Exposing a bug? :slight_smile:

Seriously though, could you re-try against trunk and file as a bug if it’s
still broken there? Sounds like a bad bit of logic somewhere in Java type
conversion.

Will do, assuming I can recompile JRuby from trunk. (I’ve been using
the pre-build 1.1.3 jar file.)

I’m still having problems creating a simple test case, though it’s
easy to reproduce in the full application.

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Charles,

On Wed, Aug 20, 2008 at 12:12 PM, Charles Oliver N.
[email protected] wrote:

Jim M. wrote:

Any ideas what I’m doing wrong?

Exposing a bug? :slight_smile:

Seriously though, could you re-try against trunk and file as a bug if it’s
still broken there? Sounds like a bad bit of logic somewhere in Java type
conversion.

The same thing happens.

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Jim M. wrote:

conversion.

The same thing happens.

Ok, file it with a complete stack trace and if you can reduce the case
it would obviously help.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

A follow-up: I’m happy to submit a bug report, but I don’t have a
small test case yet. Shall I submit the bug anyway?

Along with the bug report, I can at least submit the stack trace and a
list of superclass names going up the chain to java.lang.Object,
though I imagine the other class names won’t be much help :slight_smile:

Jim

On Wed, Aug 20, 2008 at 12:21 PM, Jim M. [email protected]
wrote:

Seriously though, could you re-try against trunk and file as a bug if it’s
still broken there? Sounds like a bad bit of logic somewhere in Java type
conversion.

The same thing happens.

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Aug 20, 2008 at 12:29 PM, Charles Oliver N.
[email protected] wrote:

Ok, file it with a complete stack trace and if you can reduce the case it
would obviously help.

Done. http://jira.codehaus.org/browse/JRUBY-2938

I also attached to the bug some log statements I inserted into Jruby
and JrubyClass.

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I have found a small, simple test case! I have attached it to
http://jira.codehaus.org/browse/JRUBY-2938 but here it is in its
entirety:

import org.jruby.Ruby;
import org.jruby.javasupport.JavaUtil;

class Root {
public static class LowestSibling extends Middle {}
}

class Middle extends Root {}

class Lowest extends Middle {}

public class Test {
public static void main(String[] args) {
Ruby r = Ruby.newInstance();
try {
JavaUtil.convertJavaToUsableRubyObject(r, new Lowest());
}
catch (AssertionError e) {
System.err.println(e.toString()); // DEBUG
e.printStackTrace();
}
}
}

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

The “Middle” class is not necessary. Here’s a simpler class hierarchy
that still triggers the problem:

class Root {
public static class LowestSibling extends Lowest {}
}
class Lowest extends Root {}
// …
JavaUtil.convertJavaToUsableRubyObject(r, new Lowest());

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I have found a fix, and submitted both a test and the fix as the file
JRUBY-2938.patch.

Jim

On Thu, Aug 21, 2008 at 11:55 AM, Jim M. [email protected]
wrote:

Jim

Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


Jim M., [email protected], [email protected]
http://www.io.com/~jimm/


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email