New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@JRubyMethod minimum argument not enforced in 9.4.3.0 #7851
Comments
Fixes handling of beginless and endless ranges. Add `resolve_feature_path` to the list of methods defined on `Array` that `RepeatedField` is expected to expose. Workaround jruby/jruby#7851 by explicit bounds checking when initializing RepeatedField.
Removing automatic arity-checking for Java-based Ruby methods broke some users' test suites that expected ArgumentError to be thrown; without a manual arity-check, the target methods now tried to access the incoming vararg array blindly and raised Java index errors. This was reported as jruby#7851. This fixes the issue by restoring arity-checking by default and providing an opt-out flag that we and users can use to indicate that the Java code will check arity manually.
These were all moved to manual arity-checking in jruby#7751, but that led to breakage when third-party extensions had varargs paths that did not check arity manually (see jruby#7851). Instead we restore the default to auto arity-check with this flag provided for opting out (jruby#7680).
These were all moved to manual arity-checking in jruby#7751, but that led to breakage when third-party extensions had varargs paths that did not check arity manually (see jruby#7851). Instead we restore the default to auto arity-check with this flag provided for opting out (jruby#7680).
From Matrix chat:
This feature was implemented in #7860 and the default behavior has reverted to automatic arity checking by default. This feature may be removed in a future release, but as it stands right now it's fine to leave it automatic by default. My original goal was to get core JRuby methods to match MRI behavior and avoid doing extra arity checks where unnecessary. |
jruby 9.4.3.0 (3.1.4) 2023-06-07 3086960792 OpenJDK 64-Bit Server VM 20.0.1+9 on 20.0.1+9 +jit [x86_64-darwin]
Darwin jatl-macbookpro 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64
Expected Behavior
Given a Ruby class defined in Java via
@JRubyClass
, expect the@JRubyMethod()
annotation to enforce the minimum number of arguments passed to a method consistently with previous JRuby versions.Actual Behavior
JRuby 9.2 and 9.3 are observed to block invocations of underlying annotated Java method if the Ruby invocation does not have sufficient arguments, whereas 9.4 is observed to pass a 0 length array to the Java function instead.
Foo.java
:BarService.java
:To reproduce under 9.4.3.0:
Output:
Contrast with behavior under 9.3.4.0:
Output:
The text was updated successfully, but these errors were encountered: