Nested Java classes from jruby

Posted by Joel Jensen Thu, 02 Aug 2007 17:06:00 GMT

I needed to get at a nested java class from jruby.

It’s tricky. Here’s How I did it

Java class ‘Fonzie’ has a nested public class ‘Hair’

include_class 'com.als.Fonzie'
Hishair = Fonzie::Hair
folicle = Hishair.new(nil)   # if the constructor takes no arguments you must include nil here.

# view that it's really a nested class

folicle.java_class 

# returns com.als.Fonzie$Hair
Comments

Leave a comment

Comments