Converting Ruby objects to Java using to_java

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?


Figured it out.

You cannot send a reference of ‘self’ from the ‘initialize’ method.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs