-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b21
This was reported on: https://stackoverflow.com/q/75667924/4297386
After the changes in https://bugs.openjdk.org/browse/JDK-8261610, JLS 9.6.4.1 reads:
> If an annotation of type java.lang.annotation.Target is not present on the declaration of an annotation interface A, then A is applicable in all declaration contexts and in no type contexts.
'all declaration contexts' includes type parameter declarations.
javac still incorrectly rejects @Target-less annotations on type parameter declarations:
```
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@interface A {}
class B<@A C> {}
```
$ javac -fullversion
javac full version "20-ea+35-2342"
$ javac B.java
B.java:7: error: annotation @A not applicable in this type context
class B<@A C> {}
^
1 error
After the changes in https://bugs.openjdk.org/browse/JDK-8261610, JLS 9.6.4.1 reads:
> If an annotation of type java.lang.annotation.Target is not present on the declaration of an annotation interface A, then A is applicable in all declaration contexts and in no type contexts.
'all declaration contexts' includes type parameter declarations.
javac still incorrectly rejects @Target-less annotations on type parameter declarations:
```
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@interface A {}
class B<@A C> {}
```
$ javac -fullversion
javac full version "20-ea+35-2342"
$ javac B.java
B.java:7: error: annotation @A not applicable in this type context
class B<@A C> {}
^
1 error
- csr for
-
JDK-8304169 no-@Target annotations should be applicable to type parameter declarations
- Closed