-
Notifications
You must be signed in to change notification settings - Fork 21
Java annotations with RetentionPolicy.CLASS are retained at runtime (scala 2.8.1) #4788
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4788?orig=1 |
@paulp said: |
@adriaanm said: |
@adriaanm said: |
@adriaanm said: |
@soc said: |
@soc said (edited on Oct 1, 2014 4:35:29 PM UTC): test/partest --failed Selected 402 tests drawn from previously failed tests
# starting 60 tests in pos
ok 1 - pos/NoCyclicReference.scala
ok 2 - pos/A.scala
ok 3 - pos/S1.scala
ok 4 - pos/FPTest.scala
ok 5 - pos/S3.scala
ok 6 - pos/List1.scala
ok 7 - pos/MailBox.scala
!! 8 - pos/inline-access-levels [compilation failed]
... Many of the failures are related to annotated elements just "disappearing": @foo val bar = 1
//Somewhere else:
println(bar)
// scalac: Hey dude, bar doesn't exist, amiright?! But not all of the failures use annotations. I'm running out of ideas how a fix to make scalac determine correctly whether a Java annotation should be visible at runtime can wreak such a havoc all over the place. I'd be happy about any help in this regard. |
@lrytz said: |
@lrytz said: In scala/scala#5606 we upgraded partest to a version that changes the mixed compilation mode. This caused a change in the retained annotations, which (probably) should not be the case. I'll take a look. |
@lrytz said: @Retention(value=SOURCE) // not parsed by the Java parser
@interface SAnnotation {} Tests updated accordingly in scala/scala#5606. |
If I annotate a class in scala, using a annotation defined in java with RetentionPolicy.CLASS, the annotation is retained at runtime.
Here's a typical example using Peter Kriens' annotations for OSGi:
If I launch the REPL with my class in the classpath, but without the definition of the annotation, and I simply try to instantiate the class, I get the following error:
And if I use Peter Kriens' class dump utility, it shows the following information:
This is very problematic in an OSGi environment where the package should not even need to be imported.
The text was updated successfully, but these errors were encountered: