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

AbstractMethodError when implementing abstract @varargs method #9013

Closed
scabug opened this issue Nov 27, 2014 · 9 comments
Closed

AbstractMethodError when implementing abstract @varargs method #9013

scabug opened this issue Nov 27, 2014 · 9 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Nov 27, 2014

import scala.annotation.varargs

abstract class VarargAbstractClass {
  @varargs
  def x(els: String*): Int
}
class ClassImplementsClass extends VarargAbstractClass {
  override def x(els: String*): Int = els.length
}

fails with an AbstractMethodError when the method is called from Java like this:

VarargAbstractClass i = new ClassImplementsClass();
i.x("a", "b", "c");

See more examples in this file:

https://github.com/jrudolph/scala-broken-java-varargs/blob/master/src/test/java/example/Test.java

I first thought that this was related to #1459 but I know think it is a separate issue. It seems the main problem is that the forwarder in VarargAbstractClass is created as abstract because in Uncurry flags from the original method are just copied to the forwarder method. Clearing the DEFERRED flag for the forwarder method seems to fix this issue for me (but I didn't run the complete test suite to look for other problems).

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Nov 27, 2014

Imported From: https://issues.scala-lang.org/browse/SI-9013?orig=1
Reporter: @jrudolph
Affected Versions: 2.10.4, 2.11.4
See #1459, #3899

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Feb 19, 2015

Joseph K Bradley (jkbradley) said:
Are there any known workarounds for this yet? (Thanks in advance for any help!)

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Mar 13, 2015

@retronym said:
Related: #3899 / #1459

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Mar 13, 2015

@retronym said (edited by @adriaanm on Jun 11, 2015 12:50:41 PM UTC):
WIP: https://github.com/retronym/scala/tree/ticket/9220

(scala/scala@53bc6d2)

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 31, 2015

Reynold Xin (rxin) said:
Any idea when we might be able to fix this in a Scala 2.10.x release? If we can't fix this, we would be forced to rewrite the DataFrame APIs in Spark in Java, in order to support streaming functionality, which would require defining abstract vararg methods.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jun 11, 2015

@adriaanm said:
We should fix this in 2.11, but we're not planning to release further 2.10.x releases. https://github.com/scala/scala/releases/tag/v2.10.5 was the last one.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 21, 2015

Michael Rüegg (mrueegg) said:
I've just stumbled over this issue. With my Gist, I was able to verify that this actually worked in Scala 2.10.4 but now I get an AbstractMethodError in 2.11.7. See here: https://gist.github.com/mrueegg/f191e547bee6a24a6bcf

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jun 26, 2016

Reid Spencer (reactific) said:
This issue bit me today. In my case it comes from attempting to implement OrientDB's OBinarySerializer class with a Scala implementation. I have tried several ways to fix this except implementing it in Java which I will try next. I'm looking forward to this being fixed in 2.11.9.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Mar 20, 2017

@scabug scabug closed this Mar 20, 2017
@scabug scabug added this to the 2.11.9 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.