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

JRuby subclass cannot call super with arguments if parent constructor is varargs #2375

Closed
headius opened this issue Dec 29, 2014 · 1 comment

Comments

@headius
Copy link
Member

headius commented Dec 29, 2014

From http://jira.codehaus.org/browse/JRUBY-6656. See that issue for attached reproduction files.

I subclass a Java class that has a varargs constructor in JRuby, the JRuby class attempts to call super(a,b) to invoke the superclasses constructor and this fails with:
ArgumentError: wrong number of arguments for constructor
initialize at varargsctor.rb:6
(root) at varargsctor.rb:11
Invoking super(nil) works, but super() and super(a,b) fail.
Sample Java class and JRuby subclass attached.

@kares kares self-assigned this Mar 27, 2015
kares added a commit to kares/jruby that referenced this issue Mar 27, 2015
…cases in jruby#2375)

... since we're storing an annotation "flag" on the gen constructor thus can support this
should be safe to land on JRuby 1.7 since users should not assume raising behaviour !
kares added a commit to kares/jruby that referenced this issue Mar 27, 2015
…cases in jruby#2375)

... since we're storing an annotation "flag" on the gen constructor thus can support this
should be safe to land on JRuby 1.7 since users should not assume raising behaviour !
kares added a commit to kares/jruby that referenced this issue Apr 3, 2015
…cases in jruby#2375)

... since we're storing an annotation "flag" on the gen constructor thus can support this
should be safe to land on JRuby 1.7 since users should not assume raising behaviour !
kares added a commit to kares/jruby that referenced this issue Apr 3, 2015
…cases in jruby#2375)

... since we're storing an annotation "flag" on the gen constructor thus can support this
should be safe to land on JRuby 1.7 since users should not assume raising behaviour !
kares added a commit that referenced this issue Apr 7, 2015
…cases in #2375)

... since we're storing an annotation "flag" on the gen constructor thus can support this
should be safe to land on JRuby 1.7 since users should not assume raising behaviour !
@kares
Copy link
Member

kares commented Apr 7, 2015

landed on jruby-1_7 as 03ed29a and 5fa2cb1 ... in a nutshell we now mark the generated proxy var-arg constructors with an annotation so we can resolve them wrapping an underlying var-arg invocation

@kares kares closed this as completed Apr 7, 2015
@kares kares added this to the JRuby 1.7.20 milestone Apr 7, 2015
kares added a commit that referenced this issue Apr 7, 2015
* jruby-1_7:
  fix compilation error left-over from 7774be5
  some more var-args tests - make sure var-arg (overload) methods are covered
  move ALLOCATOR into a static field
  guess the ivar list size (most objects have only @ variables)
  private can be static
  handle Ruby super -> Java constructor with var-args correctly (fixes cases in #2375)
  mark generated proxy class constructor with @java.lang.SafeVarargs if super is var-args
  time to start sharing the generic (handles var-args) argument toJava conversion
  use (and cache) the more Java [array] version of the API to retrieve proxy constructors
  avoid deprecated JavaMethod.create + make sub-class helpers final
  do the toJava conversion on site instead of constant indirection esp. in loops

Conflicts:
	core/src/main/java/org/jruby/RubyModule.java
	core/src/main/java/org/jruby/java/invokers/ConstructorInvoker.java
	core/src/main/java/org/jruby/java/invokers/InstanceMethodInvoker.java
	core/src/main/java/org/jruby/java/invokers/SingletonMethodInvoker.java
	core/src/main/java/org/jruby/java/invokers/StaticMethodInvoker.java
	test/test_higher_javasupport.rb
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

2 participants