-
Bug
-
Resolution: Fixed
-
P4
-
16, 17
-
b09
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8272605 | 17.0.2 | Joe Darcy | P4 | Resolved | Fixed | b01 |
JDK-8272677 | 17.0.1 | Joe Darcy | P4 | Resolved | Fixed | b08 |
JLS 9.6.3 says that a repeatable annotation is applicable to at least the same kinds of program elements as its containing annotation type.
JLS 9.6.4.1 says that if @Target is not present on an annotation, the annotation is applicable in all declaration contexts (and was updated in
This means that a repeatable annotation without a @Target can have a container annotation with an explicit @Target, e.g. in the following example TC explicit targets methods, and T implicitly targets methods:
```
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@interface TC {
T[] value() default {};
}
@Repeatable(TC.class)
@interface T {}
```
However this doesn't work for container annotations that explicitly target modules declarations:
```
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Target;
@Target(ElementType.MODULE)
@interface TC {
T[] value() default {};
}
@Repeatable(A.class)
@interface T {}
```
```
javac full version "16-ea+34-2216"
error: containing annotation type (TC) is applicable to more targets than repeatable annotation type (T)
@Repeatable(TC.class)
^
```
- backported by
-
JDK-8272605 Repeatable annotations without @Target cannot have containers that target module declarations
-
- Resolved
-
-
JDK-8272677 Repeatable annotations without @Target cannot have containers that target module declarations
-
- Resolved
-
- csr for
-
JDK-8261181 Repeatable annotations without @Target cannot have containers that target module declarations
-
- Closed
-
- relates to
-
JDK-8254023 A module declaration is not allowed to be a target of an annotation that lacks an @Target meta-annotation
-
- Resolved
-
-
JDK-8231436 Fix the applicability of a no-@Target annotation type
-
- Open
-
- links to
-
Commit openjdk/jdk17u/cb7e311d
-
Commit openjdk/jdk/60c11fef
-
Review openjdk/jdk17u/14
-
Review openjdk/jdk/2412