Creating bean PropertyDescriptor using JRuby
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 argu开发者_高级运维ment should be a Java Class. What do I need to pass for this to work in JRuby?
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.
I need to use the Java class, rather than the Ruby representation of the Java class. This works.
PropertyDescriptor.new("splitEvaluator", CrossValidationResultProducer.java_class)
精彩评论