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

Clarify "present" and annotation ordering in Core Reflection for Annotations

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: core-libs
    • Labels:

      Description

      No implementation changes are needed. Only the javadoc needs to be clarified:

      1) In AnnotatedElement, the interface-level javadoc should have these definitions:

      - An annotation A is directly present on an element E if E has a RuntimeVisibleAnnotations or RuntimeVisibleParameterAnnotations or RuntimeVisibleTypeAnnotations attribute, and the attribute contains A.

      - An annotation A is indirectly present on an element E if E has a RuntimeVisibleAnnotations or RuntimeVisibleParameterAnnotations or RuntimeVisibleTypeAnnotations attribute, and A's type is repeatable, and the attribute contains exactly one annotation whose value element contains A and whose type is the containing annotation type of A's type (§9.6).

      - An annotation A is present on an element E if either:
        - A is directly present on E; or
        - No annotation of A's type is directly present on E, and E is a class, and A's type is inheritable (§9.6.3.3), and A is present on the superclass of E.

      - An annotation A is associated with an element E if either:
        - A is directly or indirectly present on E; or
        - No annotation of A's type is directly or indirectly present on E, and E is a class, and A's type is inheritable (§9.6.3.3), and A is associated with the superclass of E.

      2) In AnnotatedElement#getDeclaredAnnotationsByType, the javadoc should be:

      Returns the annotations which are directly or indirectly present on this element. The order of annotations which are directly or indirectly present on an element E is computed as if indirectly present annotations on E are directly present on E in place of their container annotation, in the order in which they appear in the value element of the container annotation.

      @return: all this element's annotations for the specified annotation type if directly or indirectly present on this element, else an array of length zero.

      3) In AnnotatedElement#getAnnotationsByType, the javadoc should be:

      Returns the annotations which are associated with this element. The order of annotations which are directly or indirectly present on an element E is computed as if indirectly present annotations on E are directly present on E in place of their container annotation, in the order in which they appear in the value element of the container annotation.

      @return: all this element's annotations for the specified annotation type if associated with this element, else an array of length zero.

      4) In AnnotatedElement#getDeclaredAnnotation, the word "directly" is missing:

      Returns this element's annotation for the specified type if such an annotation is directly present.

      @return: this element's annotation for the specified annotation type if directly present on this element, else null.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              abuckley Alex Buckley
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: