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

an annotation interface may not be declared as a local interface

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 16
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Language construct
    • Scope:
      SE

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: