You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have a Java method that accepts a RubyArray parameter. If you call it, it works fine. But then, if you overload that method with another with a different parameter, you won't be able to call the RubyArray one:
If you run that code, JRuby will tell you that there are no methods for the parameter RubyArray, and then it will mention that there are two overloads available: (int) and (RubyArray), which doesn't make any sense.
JRuby 1.7.11 building with Java SE 6 on Eclipse Kepler for Mac.
The text was updated successfully, but these errors were encountered:
I can reproduce this with 1.7.12 and OpenJDK 1.7.0. It also shows up with static methods -- I simplified to this Java class:
import org.jruby.RubyArray;
public class Foo {
public static void test(int x) {
System.out.println(x);
}
public static void test(RubyArray array) {
System.out.println(array);
}
}
I can compile that, and then open IRB, and:
Java::Foo.test 42
works as expected, but:
Java::Foo.test [1,2,3]
fails exactly as you describe. Swapping the order of the calls or method definitions has no effect. But the RubyArray method does work, so long as it's not overloaded.
Potential workaround: Instead of working with RubyArray directly, use the List interface:
import java.util.List;
public class Foo {
public static void test(int x) {
System.out.println(x);
}
public static void test(List<?> array) {
System.out.println(array);
}
}
For whatever reason, there's at least one chunk of the dispatch code that's interpreting RubyArray as a List. This makes some sense, since it's incredibly handy to be able to call Java methods that expect Lists and give them Ruby arrays instead.
the resolution logic deal with Java types (and their mappings to Ruby types) but having the 'native' Ruby types recognized might be useful as well ... let's see how that goes.
Have a Java method that accepts a RubyArray parameter. If you call it, it works fine. But then, if you overload that method with another with a different parameter, you won't be able to call the RubyArray one:
If you run that code, JRuby will tell you that there are no methods for the parameter RubyArray, and then it will mention that there are two overloads available: (int) and (RubyArray), which doesn't make any sense.
JRuby 1.7.11 building with Java SE 6 on Eclipse Kepler for Mac.
The text was updated successfully, but these errors were encountered: