Fixnums & Floats should be coerced to the narrowest java.lang.Number when
passed to a java method that expects Object
---------------------------------------------------------------------------------------------------------------------
Key: JRUBY-3305
URL: http://jira.codehaus.org/browse/JRUBY-3305
Project: JRuby
Issue Type: Improvement
Components: Java Integration
Affects Versions: JRuby 1.1.6
Reporter: Martin Traverso
Attachments: Main.java, patch.diff, test.rb
Currently, they are coerced to java.lang.Long and java.lang.Double,
respectively, regardless of whether they fit in something smaller, like
java.lang.Short or java.lang.Float. This causes problems with some APIs like
JMX, which has a generic mechanism for setting attribute values using Object
but expects a value that "fits" in the parameter of the target method.
To reproduce, compile the attached java class and run it with:
java -Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=10000
-Dcom.sun.management.jmxremote.ssl=false Main
And run the attached ruby script with:
jruby test.rb
You'll get the following exception:
com/sun/jmx/mbeanserver/MBeanIntrospector.java:256:in `maybeInvalidParameter':
javax.management.InvalidAttributeValueException: Invalid value for attribute
Value: 1 (NativeException)
from com/sun/jmx/mbeanserver/MBeanIntrospector.java:242:in
`invokeSetter'
from com/sun/jmx/mbeanserver/PerInterface.java:84:in `setAttribute'
from com/sun/jmx/mbeanserver/MBeanSupport.java:240:in `setAttribute'
from javax/management/StandardMBean.java:369:in `setAttribute'
from com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java:762:in
`setAttribute'
from com/sun/jmx/mbeanserver/JmxMBeanServer.java:699:in `setAttribute'
...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email