JDK-8023471 : Add compatibility note to AnnotatedElement
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2013-08-21
  • Updated: 2014-01-22
  • Resolved: 2013-12-06
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 JDK 9
8 b122Fixed 9Fixed
Related Reports
Cloners :  
Description
Per the discussion of compatibility at http://mail.openjdk.java.net/pipermail/enhanced-metadata-spec-discuss/2013-January/000140.html, the interface-level javadoc of AnnotatedElement should say:

--
If an annotation of type T is present on an element, and T is made repeatable, then adding more annotations of type T to the element is source compatible and binary compatible.

It is not behaviorally compatible for the get[Declared]Annotation(Class<T>) methods and get[Declared]Annotations() methods, because they will now see only a container annotation on the element rather than any annotation of type T.

It is not behaviorally compatible for the get[Declared]AnnotationsByType(Class<T>) methods, because their results will expose the additional annotations of type T whereas previously they exposed only a single annotation of type T.

If an annotation of type TC is present on an element, then making
some other annotation type T repeatable (with TC as its containing annotation type) is source compatible and binary compatible.

It is behaviorally compatible for the get[Declared]Annotation(Class<T>) methods and get[Declared]Annotations() methods, in that their results will not change just because TC is a containing annotation type.

However, it is not behaviorally compatible for the get[Declared]AnnotationsByType(Class<T>) methods, because they will now recognize an annotation of type TC as a container annotation and "look through" it to expose annotations of type T.
--
Comments
Release team: Approved for fixing
06-12-2013

Repeating annotations is a new-in-8 feature with some non-obvious compatibility implications. The note in question is doc-only and the final version of it has been reviewed and is ready to be pushed.
06-12-2013

Review thread: http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-December/023735.html
04-12-2013