Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.5
-
Component/s: Java Integration
-
Labels:None
-
Testcase included:yes
Description
When calling Java methods, in addition to trying to find an exact match JRuby should make an effort in trying to find a logical match, e.g. a ruby list should be automatically transformed into a java List or array. Also, Java emthods taking an array as their last param should be considered varargs methods (like in Java 5 (ok, you have to use the ... notation, but it's still an array)).
See the included test case.
Issue Links
- is duplicated by
-
JRUBY-1924
NameError thrown when trying to pass argument to a Java method that is defined as having variable length arguments
-
- is related to
-
JRUBY-814
Multiple improvements to Java integration (was: Java method get lost.)
-
There is supposed to be a library released soon by one of the Rhino developers that implements Java-standard overloaded method dispatch at runtime. I believe that is our best bet for resolving all remaining method dispatch issues, since we can feed it direct Java types and coerced types until an appropriate match results.
Varargs is actually a pretty good idea, since again it's just a compiler trick in Java 5. We could easily consider methods that have an array as their last arg to be var-argable, provided all extra args in a call can map successfully to that array type.
I would love to see this in 1.0 timeframe, but it could get pushed past 1.0 and certainly won't be ready for 0.9.9.
Note: a patch that makes this varargs behavior work before 1.0 beta/RC release would very likely be accepted. Otherwise it may not be a priority until after 1.0.