How can I debug a JRuby class that is invoked from a Java application?

L

Luis

I am using JRuby (through the standard JRE 6 support) to add some Ruby
classes to a big existing Java application.

This application is started as usual as any Java app (by running a
main method), and it eventually calls my Ruby code. Is there a way to
debug Ruby code which is being called from Java?

If not, is there any hack/workaround? I know I can unit-test my Ruby
code but if I want to debug the real (and complex) environment, I need
to have my Ruby code called from the Java application...

Thanks,

Luis.
 
C

Charles Oliver Nutter

Luis said:
I am using JRuby (through the standard JRE 6 support) to add some Ruby
classes to a big existing Java application.

This application is started as usual as any Java app (by running a
main method), and it eventually calls my Ruby code. Is there a way to
debug Ruby code which is being called from Java?

If not, is there any hack/workaround? I know I can unit-test my Ruby
code but if I want to debug the real (and complex) environment, I need
to have my Ruby code called from the Java application...

At the moment this is not yet possible. The challenge here is that most
of the Ruby debugging support out there depends on runtime hooks and
callbacks that comprise their own debugging framework and API. See the
debug-commons project on RubyForge for work on standardizing that.

However soon JRuby will be able to compile all Ruby code to Java
bytecode. You would conceivably then be able to step through Ruby code
just like Java code using any Java debugging tool, since the compiled
bytecode would have file and line number information. Taking that a
couple steps further to support breakpoints and profiling would not be hard.

So then, the short answer is that this is not possible right now...but
it will be possible in the very near future.

- Charlie
 
L

Luis

At the moment this is not yet possible. The challenge here is that most
of the Ruby debugging support out there depends on runtime hooks and
callbacks that comprise their own debugging framework and API. See the
debug-commons project on RubyForge for work on standardizing that.

However soon JRuby will be able to compile all Ruby code to Java
bytecode. You would conceivably then be able to step through Ruby code
just like Java code using any Java debugging tool, since the compiled
bytecode would have file and line number information. Taking that a
couple steps further to support breakpoints and profiling would not be hard.

So then, the short answer is that this is not possible right now...but
it will be possible in the very near future.

- Charlie

Charlie, that is great news. Could you give me an approximation of
when will that feature be available?

Thanks for your quick reply,

Luis.
 
C

Charles Oliver Nutter

Luis said:
Charlie, that is great news. Could you give me an approximation of
when will that feature be available?

Thanks for your quick reply,

Full compilation to Java is planned for JRuby 1.1, by end of October.
Probably 95% of Ruby syntax compiles right now.

- Charlie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top