-
Enhancement
-
Resolution: Fixed
-
P4
-
13
Per https://mail.openjdk.java.net/pipermail/compiler-dev/2019-September/013705.html the applicability of an annotation type is at best questionable and at worst unclear in the scenario where no @Target meta-annotation is present on the annotation type's declaration. Expanding the applicability of such an annotation type to ALL contexts is easy to understand, helpful for the vast majority of programs, and future-proof against a growing Java language. Proposal:
-----
If an annotation of type java.lang.annotation.Target is not present on the declaration of an annotation type T, then T is applicable in all nine declaration contexts and all 16 type contexts.
[Delete this informative paragraph] ~~These contexts are the syntactic locations where annotations were allowed in Java SE 7.~~
-----
This expansion is source, binary, and behaviorally compatible because it has always been legal to specify all contexts by spelling out every enum constant of j.l.a.ElementType in an @Target meta-annotation. (2021 update: It would be more accurate to say "_largely_ behaviorally compatible", because annotation processors could in theory be confused by type annotations suddenly appearing due to no-@Target annotations applied in various ambiguous locations.)
-----
If an annotation of type java.lang.annotation.Target is not present on the declaration of an annotation type T, then T is applicable in all nine declaration contexts and all 16 type contexts.
[Delete this informative paragraph] ~~These contexts are the syntactic locations where annotations were allowed in Java SE 7.~~
-----
This expansion is source, binary, and behaviorally compatible because it has always been legal to specify all contexts by spelling out every enum constant of j.l.a.ElementType in an @Target meta-annotation. (2021 update: It would be more accurate to say "_largely_ behaviorally compatible", because annotation processors could in theory be confused by type annotations suddenly appearing due to no-@Target annotations applied in various ambiguous locations.)
- relates to
-
JDK-8261610 9.6.4.1: Refine no-@Target to mean "applicable in all declaration contexts"
-
- Resolved
-
-
JDK-8270916 Update java.lang.annotation.Target for changes in JLS 9.6.4.1
-
- Resolved
-
-
JDK-8231436 Fix the applicability of a no-@Target annotation type
-
- Open
-