RFR: 8004912: Repeating annotations - getAnnotationsByType is not working as expected
Peter Levart
peter.levart at gmail.com
Tue Oct 22 14:06:52 UTC 2013
Hi,
In the spec. document:
http://cr.openjdk.java.net/~abuckley/8misc.pdf
<http://cr.openjdk.java.net/%7Eabuckley/8misc.pdf>
on page 11, chapter 1.2 the following:
> When the new get[Declared]AnnotationsByType(Class<T>) methods are
> called for a repeatable annotation type T, the question is how to
> extend the policy
> to handle multiple annotations of type T on the superclass and/or
> subclass. Oracle
> proposes the following policy for Java SE 8:
>
> . If a class declaration does not have either a "directly present"
> annotation of
> type T or an "indirectly present by containment" annotation of type T,
> the class
> declaration may be "associated" with an annotation of type T due to
> inheritance.
>
> . If a class declaration does have either a "directly present"
> annotation of type T
> or an "indirectly present by containment" annotation of type T, the
> annotation
> is deemed to "override" every annotation of type T which is
> "associated" with
> the superclass.
...seems to be unnecessary complication. It could be replaced simply by:
When the new get[Declared]AnnotationsByType(Class<T>) methods are
called for a repeatable annotation type T, they return annotations
of type T *associated* with annotated element E.
Since term "associated" is already defined below as:
> . 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.
Regards, Peter
More information about the core-libs-dev
mailing list