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

9.6.4.1: Expand no-@Target to mean "applicable in all contexts"

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 13
    • Fix Version/s: 14
    • Component/s: specification
    • Labels:

      Description

      Per https://mail.openjdk.java.net/pipermail/compiler-dev/2019-September/013705.html, the applicability of an annotation type is at best questionable and at worst unclear in the scenario where no @Target meta-annotation is present on the annotation type's declaration. Expanding the applicability of such an annotation type to ALL contexts is easy to understand, helpful for the vast majority of programs, and future-proof against a growing Java language. Proposal:

      -----
      If an annotation of type java.lang.annotation.Target is not present on the declaration of an annotation type T, then T is applicable in all nine declaration contexts and all 16 type contexts.

      [Delete this informative paragraph] ~~These contexts are the syntactic locations where annotations were allowed in Java SE 7.~~
      -----

      This expansion is source, binary, and behaviorally compatible because it has always been legal to specify all contexts by spelling out every enum constant of j.l.a.ElementType in an @Target meta-annotation.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abuckley Alex Buckley
                Reporter:
                abuckley Alex Buckley
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: