jmx4r
jmx4r copied to clipboard
fix for calling operations with Java native types
Hi, I ran into this known issue in jmx4r: http://code.google.com/p/jmx4r/issues/detail?id=8
Here is a patch that fixes it at least for a int, short and float...
Jeffrey
I like the change but i was just wondering: why not support all primitives? You could do something like if primitives.has_key?(required_type.name)
with the hash values being Java::java.lang.Float
etc
Forgot to say the complete list is here: http://kenai.com/projects/jruby/pages/CallingJavaFromJRuby#Java_Primitive_Classes
I don't think this pull requests goes quite far enough. I'm running into an issue where an operation needs a java.lang.Integer, but jruby 1.7 creates integers as java.lang.Long objects. Calling the operation blows a huge stack trace unless I manually force the numbers into java.lang.Integers before calling the operation.
It seems like we should try calling to_java with the expected class as given in the required_type, as well as supporting the primitives, and only use to_java(:Object) as a last resort.
I'll try my hand at a pull request for this in the next day or two.