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

Using a Java annotation as a ClassfileAnnotation leads to problems #10958

Closed
hrhino opened this issue Jun 25, 2018 · 2 comments
Closed

Using a Java annotation as a ClassfileAnnotation leads to problems #10958

hrhino opened this issue Jun 25, 2018 · 2 comments

Comments

@hrhino
Copy link

hrhino commented Jun 25, 2018

This one's mostly for fun, because why would you do such a thing?

hhoughton:tmp hhoughton$ scala-launch 2.12.6
Welcome to Scala 2.12.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_161).
Type in expressions for evaluation. Or try :help.

scala> @Deprecated class Foo
defined class Foo

scala> val ann = classOf[Foo].getAnnotation(classOf[Deprecated])
ann: Deprecated = @java.lang.Deprecated()

scala> ann: annotation.ClassfileAnnotation
java.lang.AssertionError: assertion failed:
  Cannot emit primitive conversion from Ljava/lang/Deprecated; to Lscala/annotation/ClassfileAnnotation; - <console>
     while compiling: <console>
        during phase: jvm

not a ClassCastException, as you may have thought!

I'm not sure what can be done about this; patching parents of a class to add superclasses that just aren't there at runtime is inviting runtime crashers at the very least.

@lrytz
Copy link
Member

lrytz commented Jun 25, 2018

This is an endless source of bugs, see #9400. We should stop modifying java annotations (flags, parents, etc) and trying to work around the inconsistencies in later phases.

@hrhino
Copy link
Author

hrhino commented Jun 25, 2018

ah, I think this is a duplicate of #9644, which I somehow didn't find.

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