-
Notifications
You must be signed in to change notification settings - Fork 21
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
subclassing a java annotation generates an invalid classfile #9400
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9400?orig=1 |
@lrytz said: |
@lrytz said:
|
@lrytz said (edited on Jul 15, 2015 7:26:40 PM UTC): object Test extends App {
def foo(a: JavaAnnot): scala.annotation.Annotation = a
}
GenBCode catches the problem at bytecode generation time and crashes with an assertion error. |
@lrytz said: |
@lrytz said: |
Previously, `JavaParsers` and `ClassfileParser` would "fix-up" Java annotations to be non-abstract classes with `Annotation` and `StaticAnnotation` as parents. This caused all manner of strangeness and invalid classfiles (see linked tickets) and was surprising, to say the least. Now, the only special dispensation given to Java annotations is that they get a public, no-args class constructor, because that's what it takes to get `typedAnnotation` to be able to look up the type. This means that `new Foo`, where `Foo` is a Java annotation, still compiles (as it does right now, actually). Part of the reason for this commit is to provoke a discussion about how to fix that. Fixes scala/bug#8778. Fixes scala/bug#9400. Fixes scala/bug#9644.
Previously, `JavaParsers` and `ClassfileParser` would "fix-up" Java annotations to be non-abstract classes with `Annotation` and `StaticAnnotation` as parents. This caused all manner of strangeness and invalid classfiles (see linked tickets) and was surprising, to say the least. Now, the only special dispensation given to Java annotations is that they get a public, no-args class constructor, because that's what it takes to get `typedAnnotation` to be able to look up the type. This means that `new Foo`, where `Foo` is a Java annotation, still compiles (as it does right now, actually). Part of the reason for this commit is to provoke a discussion about how to fix that. Fixes scala/bug#8778. Fixes scala/bug#9400. Fixes scala/bug#9644.
Previously, `JavaParsers` and `ClassfileParser` would "fix-up" Java annotations to be non-abstract classes with `Annotation` and `StaticAnnotation` as parents. This caused all manner of strangeness and invalid classfiles (see linked tickets) and was surprising, to say the least. Now, the only special dispensation given to Java annotations is that they get a public, no-args class constructor, because that's what it takes to get `typedAnnotation` to be able to look up the type. This means that `new Foo`, where `Foo` is a Java annotation, still compiles (as it does right now, actually). Part of the reason for this commit is to provoke a discussion about how to fix that. Fixes scala/bug#8778. Fixes scala/bug#9400. Fixes scala/bug#9644.
Previously, `JavaParsers` and `ClassfileParser` would "fix-up" Java annotations to be non-abstract classes with `Annotation` and `StaticAnnotation` as parents. This caused all manner of strangeness and invalid classfiles (see linked tickets) and was surprising, to say the least. Now, the only special dispensation given to Java annotations is that they get a public, no-args class constructor, because that's what it takes to get `typedAnnotation` to be able to look up the type. This means that `new Foo`, where `Foo` is a Java annotation, still compiles (as it does right now, actually). Part of the reason for this commit is to provoke a discussion about how to fix that. Fixes scala/bug#8778. Fixes scala/bug#9400. Fixes scala/bug#9644.
Previously, `JavaParsers` and `ClassfileParser` would "fix-up" Java annotations to be non-abstract classes with `Annotation` and `StaticAnnotation` as parents. This caused all manner of strangeness and invalid classfiles (see linked tickets) and was surprising, to say the least. Now, the only special dispensation given to Java annotations is that they get a public, no-args class constructor, because that's what it takes to get `typedAnnotation` to be able to look up the type. This means that `new Foo`, where `Foo` is a Java annotation, still compiles (as it does right now, actually). Part of the reason for this commit is to provoke a discussion about how to fix that. Fixes scala/bug#8778. Fixes scala/bug#9400. Fixes scala/bug#9644.
JavaAnnot.java:
Test.scala:
There is also a (mostly) spurious warning emitted:
The text was updated successfully, but these errors were encountered: