JDK-8010680 : Clarify "present" and annotation ordering in javax.lang.model for Annotations
  • Type: Task
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-03-22
  • Updated: 2018-11-07
  • Resolved: 2013-05-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b93Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
No implementation changes are needed. Only the javadoc needs to be clarified:

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

- An annotation A is directly present on a construct C if either:
  - A is explicitly or implicitly declared as applying to the source code representation of C; or
  - A has a representation in the executable output corresponding to C, such as in the RuntimeVisibleAnnotations attribute of a class file.

(Typically, if A is the only annotation of its type applied to C, then A is explicitly declared as applying to the source code representation of C. If there are multiple annotations of the same type applied to C, then a container annotation is implicitly declared as applying to the source code representation of C (JLS 9.7). Note that the multiple annotations of the same type are _not_ directly present on C; rather, they are indirectly present.)

- An annotation A is indirectly present on a construct C if A's type is repeatable, and C has exactly one annotation whose value element contains A and whose type is the containing annotation type of A's type (JLS 9.6).

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

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

2) In AnnotatedConstruct#getAnnotationsByType, the javadoc should be:

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