Iirc there are no guatantees but we try as best as we can to maintain source code order. It has been a couple of years now but I think there are a few corner cases with repeating annotations.
Cheers /Joel On Fri, 13 Jan 2017 at 18:14, Gunnar Morling <gun...@hibernate.org> wrote: > 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 > >