Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8250790

an annotation interface may not be declared as a local interface

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 16
    • tools
    • None
    • source
    • minimal
    • Language construct
    • SE

      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.

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: