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

Add compatibility note to AnnotatedElement

XMLWordPrintable

        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.
        --

              darcy Joe Darcy
              jfranck Joel Borggrén-Franck (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: