Summary
The Local Static Interfaces and Enum Classes spec for JDK 16 does not allow annotations to be declared as local interfaces. The javac compiler should be sync'ed with the spec.
Problem
The javac compiler accepts annotations declared as local interfaces while the specification for Local Static Interfaces and Enum Classes forbids it. E.g. the compiler is accepting code like:
class C {
{
@interface A {}
}
}
which is not acceptable according to the Section [14.3] of the Local Static Interfaces and Enum Classes specification for JDK 16 (https://cr.openjdk.java.net/~gbierman/jep384/jep384-20200506/specs/local-statics-jls.html#jls-14.3):
An annotation interface (9.6) may not be declared as a local interface
Solution
Sync the javac compiler with the specification.
Specification
javac will produce a compile-time error for declarations of annotation types declared inside a block.
- csr of
-
JDK-8250741 an annotation interface may not be declared as a local interface
- Resolved