public abstract <A extends Annotation> A[] getAnnotationsByType (Class<A> annotationType)

Returns annotations that are associated with this construct. If there are no annotations associated with this construct, the return value is an array of length 0. The order of annotations which are directly or indirectly present on a construct C is computed as if indirectly present annotations on C are directly present on C in place of their container annotation, in the order in which they appear in the value element of the container annotation. The difference between this method and getAnnotation(Class) is that this method detects if its argument is a repeatable annotation type, and if so, attempts to find one or more annotations of that type by "looking through" a container annotation.

The annotations returned by this method could contain an element whose value is of type Class. This value cannot be returned directly: information necessary to locate and load a class (such as the class loader to use) is not available, and the class might not be loadable at all. Attempting to read a Class object by invoking the relevant method on the returned annotation will result in a MirroredTypeException, from which the corresponding TypeMirror may be extracted. Similarly, attempting to read a Class[]-valued element will result in a MirroredTypesException.

Note: This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation types currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation types.

<A>    the annotation type
annotationType    the Class object corresponding to the annotation type

Returns:  this construct's annotations for the specified annotation type if present on this construct, else an empty array

See also:
getAnnotationMirrors(), getAnnotation(Class), java.lang.reflect.AnnotatedElement.getAnnotationsByType(Class), EnumConstantNotPresentException, AnnotationTypeMismatchException, IncompleteAnnotationException, MirroredTypeException, MirroredTypesException

@jls 9.6 Annotation Types
@jls 9.6.1 Annotation Type Elements