tags:

views:

13

answers:

2

I'm trying to port some java to jruby, and it uses a beans PropertyDescriptor. The original code is:

new PropertyDescriptor("splitEvaluator", CrossValidationResultProducer.class)

which I've tried to port to:

PropertyDescriptor.new("splitEvaluator", CrossValidationResultProducer)

However, I get the error:

no constructor with arguments matching [class org.jruby.RubyString, class org.jruby.RubyClass] on object #<Java::JavaBeans::PropertyDescriptor:0x86f847> (NameError)

The PropertyDescriptor API says the second argument should be a Java Class. What do I need to pass for this to work in JRuby?

A: 

I need to use the Java class, rather than the Ruby representation of the Java class. This works.

PropertyDescriptor.new("splitEvaluator", CrossValidationResultProducer.java_class)
michaeltwofish
A: 

I can see an argument that it's a bug that it doesn't work the way you originally expected. Or at least that JRuby would be smart enough to convert a Ruby class representation of a Java class to a Java class argument.

As it is, using #java_class works, as you found out.

Nick Sieger
Thanks, Nick. It would be interesting to know if there are any downsides to automatically converting to a Java class if the method expects one.
michaeltwofish