From: Charles Oliver Nutter Date: 2010-04-22T13:20:12+09:00 Subject: Re: DrX, an object inspector On Tue, Apr 20, 2010 at 10:44 PM, Mooffie n/a wrote: > David Espada wrote: >> Any plan to extend it for JRuby?.... 0:D > > I'm not familiar with JRuby, but it was always on my mind to look into > it, so the short answer to your question is "yes". > > DrX is composed of three independent components (GUI; GraphViz DOT > generation; A helper C extension) exactly for this reason. While the > current GUI, written in Tk, probably isn't portable, it isn't a > stumbling block. For getting the data, you don't even need to write an extension to JRuby. The "jruby" library gives you introspective access to all objects at a very direct level: require 'jruby' # no JRuby on this machine, so I'm doing this from memory some_str = 'hello!' ref = JRuby.reference(some_str) ref.class # now org.jruby.RubyString ref.methods # now includes all Java-land methods on RubyString cls = ref.metaclass # an org.jruby.RubyClass instance cls.methods # should be the internal method table And so on. Basically any Ruby object can be "referenced" in this way to get direct access to all its methods, so you can essentially inspect (or modify) any part of JRuby entirely from Ruby code. I would dare to say that JRuby allows more "native" bits to be accessed from Ruby than any other Ruby (except perhaps for IronRuby, which probably has a similar situation). For GUIs, there's a lot of cool options that have come up on this list: * Raw Swing (not for the uninitiated) * Rubeus (a Swing DSL) * MonkeyBars (an MVC framework to be used with existing GUI tools/kits) * LimeLight (a Flash/JavaFX-like environment for building lickable interfaces) And they basically all work across platforms without recompile. Feel free to ping us on the JRuby list or on #jruby on FreeNode if you have questions :) - Charlie