-
Bug
-
Resolution: Fixed
-
P3
-
15, 16
-
b30
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8258633 | 17 | Joel Borggrén-Franck | P3 | Resolved | Fixed | b03 |
Copied from java.lang.annotation.Target's API documentation:
> If an @Target meta-annotation is not present on an annotation type T, then an annotation of type T may be written as a modifier for any declaration except a type parameter declaration.
As "module declarations" are not listed in the exception above, the following minimal modular example should compile:
`A.java`
| package test;
| public @interface A {}
`module-info.java`
| @test.A
| module test {}
The error message reads:
javac -d classes --module-source-path . --module test
| ./test/module-info.java:1: error: annotation type not applicable to this kind of declaration
| @test.A
| ^
| 1 error
Find the _not-compiling_ source code of the example here: https://github.com/sormuras/sandbox/tree/master/java-annotation-on-module
> If an @Target meta-annotation is not present on an annotation type T, then an annotation of type T may be written as a modifier for any declaration except a type parameter declaration.
As "module declarations" are not listed in the exception above, the following minimal modular example should compile:
`A.java`
| package test;
| public @interface A {}
`module-info.java`
| @test.A
| module test {}
The error message reads:
javac -d classes --module-source-path . --module test
| ./test/module-info.java:1: error: annotation type not applicable to this kind of declaration
| @test.A
| ^
| 1 error
Find the _not-compiling_ source code of the example here: https://github.com/sormuras/sandbox/tree/master/java-annotation-on-module
- backported by
-
JDK-8258633 A module declaration is not allowed to be a target of an annotation that lacks an @Target meta-annotation
- Resolved
- csr for
-
JDK-8257601 A module declaration is not allowed to be a target of an annotation that lacks an @Target meta-annotation
- Closed
- relates to
-
JDK-8261088 Repeatable annotations without @Target cannot have containers that target module declarations
- Resolved
(1 links to)