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
foo(string)
foo(symbol)
bar(string)
NameError: no method 'bar' for arguments (org.jruby.RubySymbol) on Java::Foobar::JRubyArityTest
Tested on JRuby 9.3.11.0 and 9.4.5.0. However, this appears to be a longstanding issue, since our codebase apparently has old workarounds for this bug dating from 2018.
The text was updated successfully, but these errors were encountered:
Note that there are (at least) two possible ways to fix the specific unexpected behavior in the test case:
Make RubyToJavaInvoker#findCallableArityOne (and friends) skip the argument matching logic and return immediately if only one candidate method with the correct name and arity is found.
Make the argument matching logic in CallableSelector recognize RubySymbol as assignable to String.
In my opinion, while option 2 might be nice to have, option 1 fixes the real problem of non-varargs Java methods with different arities affecting each other's behavior when called from JRuby.
Test case:
Create the following Java class:
and run the following JRuby code:
Expected output:
Observed output:
Tested on JRuby 9.3.11.0 and 9.4.5.0. However, this appears to be a longstanding issue, since our codebase apparently has old workarounds for this bug dating from 2018.
The text was updated successfully, but these errors were encountered: