Conversion from ruby types to Java types

If I have a ruby object that can be defined to contain instance
variables
that can be basic types (integers, strings, doubles) is there a standard
way
to convert them to a java.lang.* (where star is String, or Integer, or
whatever). I’m thinking not but before I roll something of my own I
thought
I’d ask.

Basically I’ve defined an MBean in ruby and I’ve defined some
attributes.
In the declaration of the attributes I’ve created accessor methods and
instance variables for the attributes, but when the Java JMX side of the
world calls out to get this data I think I need to convert it into a
java
type. At the time of attribute declaration I can declare the type, so
for
the java JMX calls into the MBean I was thinking I could dynamically
create
a java oriented accessor (think attr_acccessor with 2 additional methods
get_variable and set_variable= which are explicitly defined to return
something like java.lang.String(@instancevar).

Before I did this tho, I just wanted to be sure that there was no helper
method out there that when I require ‘java’ there is a
java.to_java(variable, :type) kind of thing.

(I hope this makes sense?)

Thanks

Jay

This exists today.

thingee.to_java(:string)
thingee.to_java(:int)
etc.

See http://wiki.jruby.org/wiki/Calling_Java_from_JRuby

On Fri, Jun 27, 2008 at 4:48 AM, Jay McGaffigan
[email protected]