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

Invocation of become_java! instances fails with "cannot make variable arity" #3206

Closed
rtyler opened this Issue Aug 1, 2015 · 0 comments

Comments

Projects
None yet
2 participants
@rtyler

rtyler commented Aug 1, 2015

When experimenting with passing objects for invocation back and forth into Nashorn, I wrote the following code:

class Example
  java_signature "java.lang.String hello()"
  def hello
    return 'hello world from Ruby'
  end
end

ex = Example.become_java!.new
# pass `ex` into Nashorn

From the JavaScript, which uses reflection for invocation, I invoked this #hello raises this error:

MemberName.java:852:in `makeAccessException': java.lang.IllegalAccessException: cannot make variable arity: rubyobj.Example.hello()String/invokeVirtual

@headius wrote this patch which, when compiled and tested, properly allows the invocation of this JRuby-originating instantiated Java class

rtyler added a commit to rtyler/jruby that referenced this issue Aug 6, 2015

Remove the requirement for varargs when generating Class objects for …
…Java

This is effectively a patch written by @headius and tested locally and applied
by me. In my use-case this allows Java code to properly reflect back into a
Ruby-generated Class and invoke a method which takes no arguments.

Fixes #3206

kares added a commit to kares/jruby that referenced this issue Jan 10, 2016

Remove the requirement for varargs when generating Class objects for …
…Java

This is effectively a patch written by @headius and tested locally and applied
by me. In my use-case this allows Java code to properly reflect back into a
Ruby-generated Class and invoke a method which takes no arguments.

Fixes #3206

@kares kares added java integration and removed core labels Jan 10, 2016

kares added a commit that referenced this issue Apr 4, 2016

[ji] refactor Ruby class reify to generate more accurate (arity match…
…ing) signatures

previously all method arities ended up as var-args : `foo(IRubyObject[] args)`

now for fixed arities we'll have correct number of args e.g. `foo(IRubyObject arg1)`
... we still generate var-args: `foo(IRubyObject[] args)` for all non-fixed arity sizes!

resolves #3206 and likely #449 also #3366 (java_signature is now honored)

kares added a commit that referenced this issue Apr 6, 2016

[ji] refactor Ruby class reify to generate more accurate (arity match…
…ing) signatures

previously all method arities ended up as var-args : `foo(IRubyObject[] args)`

now for fixed arities we'll have correct number of args e.g. `foo(IRubyObject arg1)`
... we still generate var-args: `foo(IRubyObject[] args)` for all non-fixed arity sizes!

resolves #3206 and likely #449 also #3366 (java_signature is now honored)

@kares kares added this to the JRuby 9.1.0.0 milestone Apr 6, 2016

@kares kares closed this in #3779 Apr 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment