Hi Gunnar,

Please take a look at JDK-8010679 'Clarify "present" and annotation ordering in 
Core Reflection for Annotations' [*].

Best regards,
-Yuri

[*] https://bugs.openjdk.java.net/browse/JDK-8010679


-----Original Message-----
From: core-libs-dev [mailto:core-libs-dev-boun...@openjdk.java.net] On Behalf 
Of Gunnar Morling
Sent: Friday, January 13, 2017 08:14 PM
To: core-libs-dev@openjdk.java.net
Subject: Guaranteed order of annotations?

Hi,

Is there any order guaranteed in which an element's annotations are
returned by AnnotatedElement#getDeclaredAnnotations()? Specifically,
is this the order in which the annotations are given in the source
code?

Section 9.7.5. of the JLS ("Multiple Annotations of the Same Type")
makes a statement of the source order being considered by the array of
the implicit container annotation created for a repeatable annotation
("[...] all the base annotations in the left-to-right order in which
they appeared in the context").

But I couldn't find any authoritative description on the ordering
behaviour of getDeclaredAnnotations(). Should we assume that we cannot
rely on the order in the source?

Thanks for any pointers,

--Gunnar

Reply via email to