Skip to content
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

JavaMethod* needs appropriate getParameters info #2817

Open
enebo opened this issue Apr 9, 2015 · 0 comments
Open

JavaMethod* needs appropriate getParameters info #2817

enebo opened this issue Apr 9, 2015 · 0 comments

Comments

@enebo
Copy link
Member

enebo commented Apr 9, 2015

#2816 notices that attr_writer generated methods are lacking parameter info. I fixed 1-3 req args but we need to audit and change all of the JavaMethodXXX. As a follow-on task I think we can just override getParameters() on each of these subtypes not need to store parameters as a field. This is a little less clear since we need to know if anyone is really calling setParameters in a JavaMethodXXX instance or not.

grddev added a commit to grddev/rspec-support that referenced this issue Feb 26, 2018
JRuby apparently only supports #arity (and not #parameters) for Java proxy methods (see jruby/jruby#2817), but verifying doubles in RSpec use #parameters to infer required method parameters, and thus doesn't work for Java classes.

This extends the previously existing JRuby workaround that returns an empty list from #parameters so that it fallbacks to the legacy method of using #arity.

While this obviously doesn't cover all cases, it does cover the cases the previous workaround covered, and also allows using verifying doubles for many Java classes in JRuby.
grddev added a commit to grddev/rspec-support that referenced this issue Feb 26, 2018
JRuby apparently only supports #arity (and not #parameters) for Java proxy methods (see jruby/jruby#2817), but verifying doubles in RSpec use #parameters to infer required method parameters, and thus doesn't work for Java classes.

This extends the previously existing JRuby workaround that returns an empty list from #parameters so that it fallbacks to the legacy method of using #arity.

While this obviously doesn't cover all cases, it does cover the cases the previous workaround covered, and also allows using verifying doubles for many Java classes in JRuby.
grddev added a commit to grddev/rspec-support that referenced this issue Mar 1, 2018
JRuby apparently only supports #arity (and not #parameters) for Java proxy methods (see jruby/jruby#2817), but verifying doubles in RSpec use #parameters to infer required method parameters, and thus doesn't work for Java classes.

This extends the previously existing JRuby workaround that returns an empty list from #parameters so that it fallbacks to the legacy method of using #arity.

In addition, it turns out that the #arity method is broken for Java proxy methods in JRuby 1.7.x. While JRuby 1.7 has been sunset, the test suite still uses it, and thus this introduces another workaround to account for that.

This looks up the corresponding JavaMethod overloads, and if there is only one, retrieves the arity from that one instead. In the presence of multiple overloads, -1 is returned.

While this obviously doesn't cover all cases, it does cover the cases the previous workaround covered, and also allows using verifying doubles for many Java classes in JRuby.
grddev added a commit to grddev/rspec-support that referenced this issue Mar 1, 2018
JRuby apparently only supports #arity (and not #parameters) for Java proxy methods (see jruby/jruby#2817), but verifying doubles in RSpec use #parameters to infer required method parameters, and thus doesn't work for Java classes.

This extends the previously existing JRuby workaround that returns an empty list from #parameters so that it fallbacks to the legacy method of using #arity.

In addition, it turns out that the #arity method is broken for Java proxy methods in JRuby 1.7.x. While JRuby 1.7 has been sunset, the test suite still uses it, and thus this introduces another workaround to account for that.

This looks up the corresponding JavaMethod overloads, and if there is only one, retrieves the arity from that one instead. In the presence of multiple overloads, -1 is returned.

While this obviously doesn't cover all cases, it does cover the cases the previous workaround covered, and also allows using verifying doubles for many Java classes in JRuby.
grddev added a commit to grddev/rspec-support that referenced this issue Mar 4, 2018
JRuby apparently only supports #arity (and not #parameters) for Java proxy methods (see jruby/jruby#2817), but verifying doubles in RSpec use #parameters to infer required method parameters, and thus doesn't work for Java classes.

Given that this issue affects every release of JRuby so far with support for #parameters, it seemed reasonable to replace the previous workaround that only affected JRuby 1.7.0 through 1.7.19.
grddev added a commit to grddev/rspec-support that referenced this issue Mar 12, 2018
The workaround looking up the corresponding Java class and looking at its methods only works for methods, and doesn't work for Proc, where there isn't a direct API to access the proxied Java class.

While the same problem exists for Proc's, until jruby/jruby#2817 has been resolved, there isn't much that can be done for that case. However, the current code fails to run for all blocks with arity -1, so this tweak is necessary to ensure normal blocks work again.

I couldn't find any specs for BlockSignature, so wasn't sure where it would be appropriate to add a test for this.
grddev added a commit to grddev/rspec-support that referenced this issue Mar 12, 2018
The workaround looking up the corresponding Java class and looking at its methods only works for methods, and doesn't work for Proc, where there isn't a direct API to access the proxied Java class.

While the same problem exists for Proc's, until jruby/jruby#2817 has been resolved, there isn't much that can be done for that case. However, the current code fails to run for all blocks with arity -1, so this tweak is necessary to ensure normal blocks work again.

I couldn't find any specs for BlockSignature, so wasn't sure where it would be appropriate to add a test for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant