Forum: JRuby Converting Ruby objects to Java using to_java

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Pranav S. (Guest)
on 2008-12-30 00:45
Hi, I'm new to JRuby and I have a question regarding passing ruby
variables to java.

In java, I have an abstract class, called JClassA and another class
called JClassB.
In ruby, I implement the concreate class of JClassA, called RClass.

Here are the relations:

RCLass < JClassA.
JClassB(JClassA) (The constructor of JClassB takes JClassA as an

From RClass, I need to call JClassB and give the current instance as an

If I do, then it will complain about not finding the

On the other hand, if I do then it complains
that it cannot find the method to_java in RClassB.

What am I doing wrong? Can I convert any ruby object to java object?

Pranav S. (Guest)
on 2008-12-30 18:50
Figured it out.

You cannot send a reference of 'self' from the 'initialize' method.
This topic is locked and can not be replied to.