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

9.7.4: Clarify that "closest annotation" doesn't directly jump to type names

    XMLWordPrintable

Details

    Description

      Assume TA is an annotation type with one meta-annotation, @Target(ElementType.TYPE_USE). It's right to link @TA with "String" (skipping over modifiers) in:

        @TA public String f;

      but we mustn't appear to link @TA to "String" in:

        @TA public java.lang.String f;

      because the 'java' and 'lang' package names get in the way. The informative text in JLS 9.7.4 about the artifact to which @Foo applies should use String rather than java.lang.String. Then, the *** text should be removed in:

      "In the second and third cases above, the type which is closest to the annotation is determined by first taking the type of the declared entity, ***then identifying the first token which itself denotes a type.***"

      That will leave @TA applying to "java.lang.String", which will later be deemed "not admissible" because the first token isn't a TypeName.

      Finally, the following clause should be added: "if that type is an array type, then the element type is deemed to be closest to the annotation."

      Attachments

        Activity

          People

            abuckley Alex Buckley
            abuckley Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: