Skip to content

java.lang.IncompatibleClassChangeError when using Java-class, which implements @interface #8348

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

Closed
scabug opened this issue Feb 27, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Feb 27, 2014

When invoking method from instances of class, which implement interfaces, declared in Java as public @interface SomeInterface - then throws java.lang.IncompatibleClassChangeError. But if use that in Java classes - all works fine. Now to solve this problem used workaround which use static methods from Java-class with additional argument of this-object.
for example:

// In Java
public @interface TableColumn {
	int width() default -1;
}
public class TableColumnImpl implements TableColumn {.......}
public class TableWorkAround { 
 public int width(TableColumnImpl column) { return column.width();}
}
// In Scala
...
val column: TableColumnImpl = getSomeFuncReturn_TableColumnImpl
val widthScala = column.width // throw IncompatibleClassChangeError
val widthJava = TableWorkAround.width(column) // works fine

when disassembly
in scala call of method -> invokeinterface
in java call of method -> invokevirtual

Full bundle, which replicates this behaviour in bundle.zip, which attached

@scabug
Copy link
Author

scabug commented Feb 27, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8348?orig=1
Reporter: Sergey Zaytsev (serghy)
Affected Versions: 2.10.2, 2.10.3, 2.11.0-M8
Attachments:

  • bundle.zip (created on Feb 27, 2014 6:53:26 AM UTC, 1521 bytes)

@scabug
Copy link
Author

scabug commented Feb 27, 2014

@soc said (edited on Feb 27, 2014 2:03:56 PM UTC):
Not sure what you are trying to do, but TableColumn is not an interface, it's an annotation.
It's probably a bug, but why are you subclassing annotations in the first place?

@scabug
Copy link
Author

scabug commented Feb 28, 2014

Sergey Zaytsev (serghy) said:
We use this for mixing "static logic" of anotation to "dynamic logic" on runtime. In Java, it did not cause problems, and we did not expect them to appear in Scala. Use the workaround is not convenient, especially when a lot of methods. And abandon Scala is also not desirable.

@hrhino
Copy link

hrhino commented Sep 7, 2017

This appears to have been fixed as a by-product of scala/scala@7d51b3f.

@hrhino hrhino closed this as completed Sep 7, 2017
hrhino added a commit to hrhino/scala that referenced this issue Jan 16, 2018
- scala/bug#5638 was fixed by something farther back than I can build.
- scala/bug#8348 was fixed by scala#5251.
- scala/bug#9291 was fixed by scala#6092.
@SethTisue SethTisue changed the title java.lang.IncompatibleClassChangeError when using Java-class, wich implements @interface java.lang.IncompatibleClassChangeError when using Java-class, which implements @interface Jan 16, 2018
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