It really is a little lower. Let's start with the Java 8 feature of repeating annotations, since it has a few bits:
JLS ยง9.7.5. Multiple annotations of the same type :
An implicitly declared annotation is called container annotation, and multiple T type annotations that appear in context are called basic annotations. The elements of the value element of container annotations are all basic annotations in the order from left to right in which they appeared in context.
This way the container will provide repeating annotations in order.
In addition, the AnnotatedElement documentation states:
To call get[Declared]AnnotationsByType( Class < T >) order of annotations that are directly or indirectly present on the element E is calculated as if the indirectly present annotations on E were directly present on E instead of their annotation to the container, in the order specified to which they appear in the element of the annotation value of the container.
Putting the two together means that duplicate annotations like @Foo(1) @Foo(2) @Foo(3) are stored just like you wrote @FooContainer({@Foo(1), @Foo(2), @Foo(3)}) , and the latter, regardless of how they were created, will be treated by getDeclaredAnnotations() , as directly presented annotations in this order.
So the answer for repeated annotations is that the order will be "order from left to right in which they appeared."
But there is another conclusion that we can draw from the AnnotatedElement documentation. Since he states that the order of annotations is calculated as if the indirectly present annotations were directly present instead of their annotation to the container, this means that if you write @Foo(1) @FooContainer({@Foo(2), @Foo(3)}) or @FooContainer({@Foo(1), @Foo(2)}) @Foo(3) , the order will be the same as the elements the container will replace it in the same way as you wrote @Foo(1) @Foo(2) @Foo(3) .
I wonder how this is achieved :
If annotations annotations of the annotationClass type are detected both directly and indirectly, then getDeclaredAnnotations() is called to determine the order of the elements in the returned array.
This implementation note is the first indicator in all documentation that getDeclaredAnnotations() is in good order. It is used to determine the order that is required to fulfill the contract described above.
So the answer is yes, getDeclaredAnnotations() provides annotations in a guaranteed manner, but this information is not directly tied to the documentation of the method itself.
This comes from the Java 8 documentation, but since Java 6 and 7 have reached their end of life and have not changed, the fact that the observed behavior of their implementation matches the behavior guaranteed at least for Java 8 may be enough to rely on it.