public abstract class AnnotationUtils extends Object
Note that most of the features of this class are not provided by the JDK's introspection facilities themselves.
As a general rule for runtime-retained application annotations (e.g. for
 transaction control, authorization, or service exposure), always use the
 lookup methods on this class (e.g. findAnnotation(Method, Class) or
 getAnnotation(Method, Class)) instead of the plain annotation lookup
 methods in the JDK. You can still explicitly choose between a get
 lookup on the given class level only (getAnnotation(Method, Class))
 and a find lookup in the entire inheritance hierarchy of the given
 method (findAnnotation(Method, Class)).
 
AnnotatedElement (in Java 8).
 An annotation is meta-present on an element if the annotation
 is declared as a meta-annotation on some other annotation which is
 present on the element. Annotation A is meta-present
 on another annotation if A is either directly present or
 meta-present on the other annotation.
 
Most find*() methods and some get*() methods in this class
 provide support for finding annotations used as meta-annotations. Consult the
 javadoc for each method in this class for details. For fine-grained support for
 meta-annotations with attribute overrides in composed annotations,
 consider using AnnotatedElementUtils's more specific methods instead.
 
All public methods in this class that return annotations, arrays of
 annotations, or AnnotationAttributes transparently support attribute
 aliases configured via @AliasFor. Consult the various
 synthesizeAnnotation*(..) methods for details.
 
The search algorithms used by methods in this class stop searching for an annotation once the first annotation of the specified type has been found. As a consequence, additional annotations of the specified type will be silently ignored.
AliasFor, 
AnnotationAttributes, 
AnnotatedElementUtils, 
BridgeMethodResolver, 
AnnotatedElement.getAnnotations(), 
AnnotatedElement.getAnnotation(Class), 
AnnotatedElement.getDeclaredAnnotations()| Modifier and Type | Field and Description | 
|---|---|
| static String | VALUEThe attribute name for annotations with a single element. | 
| Constructor and Description | 
|---|
| AnnotationUtils() | 
| Modifier and Type | Method and Description | 
|---|---|
| static void | clearCache()Clear the internal annotation metadata cache. | 
| static <A extends Annotation> | findAnnotation(AnnotatedElement annotatedElement,
              Class<A> annotationType) | 
| static <A extends Annotation> | findAnnotation(Class<?> clazz,
              Class<A> annotationType)Find a single  AnnotationofannotationTypeon the
 suppliedClass, traversing its interfaces, annotations, and
 superclasses if the annotation is not directly present on
 the given class itself. | 
| static <A extends Annotation> | findAnnotation(Method method,
              Class<A> annotationType)Find a single  AnnotationofannotationTypeon the suppliedMethod, traversing its super methods (i.e. | 
| static Class<?> | findAnnotationDeclaringClass(Class<? extends Annotation> annotationType,
                            Class<?> clazz)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static Class<?> | findAnnotationDeclaringClassForTypes(List<Class<? extends Annotation>> annotationTypes,
                                    Class<?> clazz)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static <A extends Annotation> | getAnnotation(AnnotatedElement annotatedElement,
             Class<A> annotationType)Get a single  AnnotationofannotationTypefrom the suppliedAnnotatedElement, where the annotation is either present or
 meta-present on theAnnotatedElement. | 
| static <A extends Annotation> | getAnnotation(Annotation annotation,
             Class<A> annotationType)Get a single  AnnotationofannotationTypefrom the supplied
 annotation: either the given annotation itself or a direct meta-annotation
 thereof. | 
| static <A extends Annotation> | getAnnotation(Method method,
             Class<A> annotationType)Get a single  AnnotationofannotationTypefrom the
 suppliedMethod, where the annotation is either present
 or meta-present on the method. | 
| static AnnotationAttributes | getAnnotationAttributes(AnnotatedElement annotatedElement,
                       Annotation annotation)Retrieve the given annotation's attributes as an  AnnotationAttributesmap. | 
| static AnnotationAttributes | getAnnotationAttributes(AnnotatedElement annotatedElement,
                       Annotation annotation,
                       boolean classValuesAsString,
                       boolean nestedAnnotationsAsMap)Retrieve the given annotation's attributes as an  AnnotationAttributesmap. | 
| static Map<String,Object> | getAnnotationAttributes(Annotation annotation)Retrieve the given annotation's attributes as a  Map, preserving all
 attribute types. | 
| static Map<String,Object> | getAnnotationAttributes(Annotation annotation,
                       boolean classValuesAsString)Retrieve the given annotation's attributes as a  Map. | 
| static AnnotationAttributes | getAnnotationAttributes(Annotation annotation,
                       boolean classValuesAsString,
                       boolean nestedAnnotationsAsMap)Retrieve the given annotation's attributes as an  AnnotationAttributesmap. | 
| static Annotation[] | getAnnotations(AnnotatedElement annotatedElement)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static Annotation[] | getAnnotations(Method method)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static <A extends Annotation> | getDeclaredRepeatableAnnotations(AnnotatedElement annotatedElement,
                                Class<A> annotationType)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static <A extends Annotation> | getDeclaredRepeatableAnnotations(AnnotatedElement annotatedElement,
                                Class<A> annotationType,
                                Class<? extends Annotation> containerAnnotationType)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static Object | getDefaultValue(Annotation annotation)Retrieve the default value of the  valueattribute
 of a single-element Annotation, given an annotation instance. | 
| static Object | getDefaultValue(Annotation annotation,
               String attributeName)Retrieve the default value of a named attribute, given an annotation instance. | 
| static Object | getDefaultValue(Class<? extends Annotation> annotationType)Retrieve the default value of the  valueattribute
 of a single-element Annotation, given theannotation type. | 
| static Object | getDefaultValue(Class<? extends Annotation> annotationType,
               String attributeName)Retrieve the default value of a named attribute, given the
  annotation type. | 
| static <A extends Annotation> | getRepeatableAnnotations(AnnotatedElement annotatedElement,
                        Class<A> annotationType)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static <A extends Annotation> | getRepeatableAnnotations(AnnotatedElement annotatedElement,
                        Class<A> annotationType,
                        Class<? extends Annotation> containerAnnotationType)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static Object | getValue(Annotation annotation)Retrieve the value of the  valueattribute of a
 single-element Annotation, given an annotation instance. | 
| static Object | getValue(Annotation annotation,
        String attributeName)Retrieve the value of a named attribute, given an annotation instance. | 
| static boolean | isAnnotationDeclaredLocally(Class<? extends Annotation> annotationType,
                           Class<?> clazz)Determine whether an annotation of the specified  annotationTypeis declared locally (i.e. | 
| static boolean | isAnnotationInherited(Class<? extends Annotation> annotationType,
                     Class<?> clazz)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static boolean | isAnnotationMetaPresent(Class<? extends Annotation> annotationType,
                       Class<? extends Annotation> metaAnnotationType)Deprecated. 
 as of 5.2 since it is superseded by the  MergedAnnotationsAPI | 
| static boolean | isCandidateClass(Class<?> clazz,
                Class<? extends Annotation> annotationType)Determine whether the given class is a candidate for carrying the specified annotation
 (at type, method or field level). | 
| static boolean | isCandidateClass(Class<?> clazz,
                Collection<Class<? extends Annotation>> annotationTypes)Determine whether the given class is a candidate for carrying one of the specified
 annotations (at type, method or field level). | 
| static boolean | isCandidateClass(Class<?> clazz,
                String annotationName)Determine whether the given class is a candidate for carrying the specified annotation
 (at type, method or field level). | 
| static boolean | isInJavaLangAnnotationPackage(Annotation annotation)Determine if the supplied  Annotationis defined in the core JDKjava.lang.annotationpackage. | 
| static boolean | isInJavaLangAnnotationPackage(String annotationType)Determine if the  Annotationwith the supplied name is defined
 in the core JDKjava.lang.annotationpackage. | 
| static void | postProcessAnnotationAttributes(Object annotatedElement,
                               AnnotationAttributes attributes,
                               boolean classValuesAsString)Post-process the supplied  AnnotationAttributes, preserving nested
 annotations asAnnotationinstances. | 
| static void | registerDefaultValues(AnnotationAttributes attributes)Register the annotation-declared default values for the given attributes,
 if available. | 
| static <A extends Annotation> | synthesizeAnnotation(A annotation,
                    AnnotatedElement annotatedElement)Synthesize an annotation from the supplied  annotationby wrapping it in a dynamic proxy that transparently enforces
 attribute alias semantics for annotation attributes that are
 annotated with@AliasFor. | 
| static <A extends Annotation> | synthesizeAnnotation(Class<A> annotationType)Synthesize an annotation from its default attributes values. | 
| static <A extends Annotation> | synthesizeAnnotation(Map<String,Object> attributes,
                    Class<A> annotationType,
                    AnnotatedElement annotatedElement)Synthesize an annotation from the supplied map of annotation
 attributes by wrapping the map in a dynamic proxy that implements an
 annotation of the specified  annotationTypeand transparently
 enforces attribute alias semantics for annotation attributes
 that are annotated with@AliasFor. | 
| static void | validateAnnotation(Annotation annotation)Check the declared attributes of the given annotation, in particular covering
 Google App Engine's late arrival of  TypeNotPresentExceptionProxyforClassvalues (instead of earlyClass.getAnnotations() failure. | 
public static final String VALUE
public static boolean isCandidateClass(Class<?> clazz, Collection<Class<? extends Annotation>> annotationTypes)
clazz - the class to introspectannotationTypes - the searchable annotation typesfalse if the class is known to have no such annotations at any level;
 true otherwise. Callers will usually perform full method/field introspection
 if true is being returned here.isCandidateClass(Class, Class), 
isCandidateClass(Class, String)public static boolean isCandidateClass(Class<?> clazz, Class<? extends Annotation> annotationType)
clazz - the class to introspectannotationType - the searchable annotation typefalse if the class is known to have no such annotations at any level;
 true otherwise. Callers will usually perform full method/field introspection
 if true is being returned here.isCandidateClass(Class, String)public static boolean isCandidateClass(Class<?> clazz, String annotationName)
clazz - the class to introspectannotationName - the fully-qualified name of the searchable annotation typefalse if the class is known to have no such annotations at any level;
 true otherwise. Callers will usually perform full method/field introspection
 if true is being returned here.isCandidateClass(Class, Class)@Nullable public static <A extends Annotation> A getAnnotation(Annotation annotation, Class<A> annotationType)
Annotation of annotationType from the supplied
 annotation: either the given annotation itself or a direct meta-annotation
 thereof.
 Note that this method supports only a single level of meta-annotations.
 For support for arbitrary levels of meta-annotations, use one of the
 find*() methods instead.
annotation - the Annotation to checkannotationType - the annotation type to look for, both locally and as a meta-annotationnull if not found@Nullable public static <A extends Annotation> A getAnnotation(AnnotatedElement annotatedElement, Class<A> annotationType)
Annotation of annotationType from the supplied
 AnnotatedElement, where the annotation is either present or
 meta-present on the AnnotatedElement.
 Note that this method supports only a single level of meta-annotations.
 For support for arbitrary levels of meta-annotations, use
 findAnnotation(AnnotatedElement, Class) instead.
annotatedElement - the AnnotatedElement from which to get the annotationannotationType - the annotation type to look for, both locally and as a meta-annotationnull if not found@Nullable public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType)
Annotation of annotationType from the
 supplied Method, where the annotation is either present
 or meta-present on the method.
 Correctly handles bridge Methods generated by the compiler.
 
Note that this method supports only a single level of meta-annotations.
 For support for arbitrary levels of meta-annotations, use
 findAnnotation(Method, Class) instead.
method - the method to look for annotations onannotationType - the annotation type to look fornull if not foundBridgeMethodResolver.findBridgedMethod(Method), 
getAnnotation(AnnotatedElement, Class)@Deprecated @Nullable public static Annotation[] getAnnotations(AnnotatedElement annotatedElement)
MergedAnnotations APIAnnotations that are present on the
 supplied AnnotatedElement.
 Meta-annotations will not be searched.
annotatedElement - the Method, Constructor or Field to retrieve annotations fromnull if not
 resolvable (e.g. because nested Class values in annotation attributes
 failed to resolve at runtime)AnnotatedElement.getAnnotations()@Deprecated @Nullable public static Annotation[] getAnnotations(Method method)
MergedAnnotations APIAnnotations that are present on the
 supplied Method.
 Correctly handles bridge Methods generated by the compiler.
 
Meta-annotations will not be searched.
method - the Method to retrieve annotations fromnull if not
 resolvable (e.g. because nested Class values in annotation attributes
 failed to resolve at runtime)BridgeMethodResolver.findBridgedMethod(Method), 
AnnotatedElement.getAnnotations()@Deprecated public static <A extends Annotation> Set<A> getRepeatableAnnotations(AnnotatedElement annotatedElement, Class<A> annotationType)
MergedAnnotations APIannotationType from the supplied AnnotatedElement, where
 such annotations are either present, indirectly present,
 or meta-present on the element.
 This method mimics the functionality of Java 8's
 AnnotatedElement.getAnnotationsByType(Class)
 with support for automatic detection of a container annotation
 declared via @Repeatable (when running on
 Java 8 or higher) and with additional support for meta-annotations.
 
Handles both single annotations and annotations nested within a container annotation.
Correctly handles bridge methods generated by the
 compiler if the supplied element is a Method.
 
Meta-annotations will be searched if the annotation is not present on the supplied element.
annotatedElement - the element to look for annotations onannotationType - the annotation type to look fornull)getRepeatableAnnotations(AnnotatedElement, Class, Class), 
getDeclaredRepeatableAnnotations(AnnotatedElement, Class, Class), 
AnnotatedElementUtils.getMergedRepeatableAnnotations(AnnotatedElement, Class), 
BridgeMethodResolver.findBridgedMethod(java.lang.reflect.Method), 
Repeatable, 
AnnotatedElement.getAnnotationsByType(java.lang.Class<T>)@Deprecated public static <A extends Annotation> Set<A> getRepeatableAnnotations(AnnotatedElement annotatedElement, Class<A> annotationType, @Nullable Class<? extends Annotation> containerAnnotationType)
MergedAnnotations APIannotationType from the supplied AnnotatedElement, where
 such annotations are either present, indirectly present,
 or meta-present on the element.
 This method mimics the functionality of Java 8's
 AnnotatedElement.getAnnotationsByType(Class)
 with additional support for meta-annotations.
 
Handles both single annotations and annotations nested within a container annotation.
Correctly handles bridge methods generated by the
 compiler if the supplied element is a Method.
 
Meta-annotations will be searched if the annotation is not present on the supplied element.
annotatedElement - the element to look for annotations onannotationType - the annotation type to look forcontainerAnnotationType - the type of the container that holds
 the annotations; may be null if a container is not supported
 or if it should be looked up via @Repeatable
 when running on Java 8 or highernull)getRepeatableAnnotations(AnnotatedElement, Class), 
getDeclaredRepeatableAnnotations(AnnotatedElement, Class), 
getDeclaredRepeatableAnnotations(AnnotatedElement, Class, Class), 
AnnotatedElementUtils.getMergedRepeatableAnnotations(AnnotatedElement, Class, Class), 
BridgeMethodResolver.findBridgedMethod(java.lang.reflect.Method), 
Repeatable, 
AnnotatedElement.getAnnotationsByType(java.lang.Class<T>)@Deprecated public static <A extends Annotation> Set<A> getDeclaredRepeatableAnnotations(AnnotatedElement annotatedElement, Class<A> annotationType)
MergedAnnotations APIannotationType from the supplied AnnotatedElement,
 where such annotations are either directly present,
 indirectly present, or meta-present on the element.
 This method mimics the functionality of Java 8's
 AnnotatedElement.getDeclaredAnnotationsByType(Class)
 with support for automatic detection of a container annotation
 declared via @Repeatable (when running on
 Java 8 or higher) and with additional support for meta-annotations.
 
Handles both single annotations and annotations nested within a container annotation.
Correctly handles bridge methods generated by the
 compiler if the supplied element is a Method.
 
Meta-annotations will be searched if the annotation is not present on the supplied element.
annotatedElement - the element to look for annotations onannotationType - the annotation type to look fornull)getRepeatableAnnotations(AnnotatedElement, Class), 
getRepeatableAnnotations(AnnotatedElement, Class, Class), 
getDeclaredRepeatableAnnotations(AnnotatedElement, Class, Class), 
AnnotatedElementUtils.getMergedRepeatableAnnotations(AnnotatedElement, Class), 
BridgeMethodResolver.findBridgedMethod(java.lang.reflect.Method), 
Repeatable, 
AnnotatedElement.getDeclaredAnnotationsByType(java.lang.Class<T>)@Deprecated public static <A extends Annotation> Set<A> getDeclaredRepeatableAnnotations(AnnotatedElement annotatedElement, Class<A> annotationType, @Nullable Class<? extends Annotation> containerAnnotationType)
MergedAnnotations APIannotationType from the supplied AnnotatedElement,
 where such annotations are either directly present,
 indirectly present, or meta-present on the element.
 This method mimics the functionality of Java 8's
 AnnotatedElement.getDeclaredAnnotationsByType(Class)
 with additional support for meta-annotations.
 
Handles both single annotations and annotations nested within a container annotation.
Correctly handles bridge methods generated by the
 compiler if the supplied element is a Method.
 
Meta-annotations will be searched if the annotation is not present on the supplied element.
annotatedElement - the element to look for annotations onannotationType - the annotation type to look forcontainerAnnotationType - the type of the container that holds
 the annotations; may be null if a container is not supported
 or if it should be looked up via @Repeatable
 when running on Java 8 or highernull)getRepeatableAnnotations(AnnotatedElement, Class), 
getRepeatableAnnotations(AnnotatedElement, Class, Class), 
getDeclaredRepeatableAnnotations(AnnotatedElement, Class), 
AnnotatedElementUtils.getMergedRepeatableAnnotations(AnnotatedElement, Class, Class), 
BridgeMethodResolver.findBridgedMethod(java.lang.reflect.Method), 
Repeatable, 
AnnotatedElement.getDeclaredAnnotationsByType(java.lang.Class<T>)@Nullable public static <A extends Annotation> A findAnnotation(AnnotatedElement annotatedElement, @Nullable Class<A> annotationType)
Annotation of annotationType on the
 supplied AnnotatedElement.
 Meta-annotations will be searched if the annotation is not directly present on the supplied element.
Warning: this method operates generically on
 annotated elements. In other words, this method does not execute
 specialized search algorithms for classes or methods. If you require
 the more specific semantics of findAnnotation(Class, Class)
 or findAnnotation(Method, Class), invoke one of those methods
 instead.
annotatedElement - the AnnotatedElement on which to find the annotationannotationType - the annotation type to look for, both locally and as a meta-annotationnull if not found@Nullable public static <A extends Annotation> A findAnnotation(Method method, @Nullable Class<A> annotationType)
Annotation of annotationType on the supplied
 Method, traversing its super methods (i.e. from superclasses and
 interfaces) if the annotation is not directly present on the given
 method itself.
 Correctly handles bridge Methods generated by the compiler.
 
Meta-annotations will be searched if the annotation is not directly present on the method.
Annotations on methods are not inherited by default, so we need to handle this explicitly.
method - the method to look for annotations onannotationType - the annotation type to look fornull if not foundgetAnnotation(Method, Class)@Nullable public static <A extends Annotation> A findAnnotation(Class<?> clazz, @Nullable Class<A> annotationType)
Annotation of annotationType on the
 supplied Class, traversing its interfaces, annotations, and
 superclasses if the annotation is not directly present on
 the given class itself.
 This method explicitly handles class-level annotations which are not
 declared as inherited as well
 as meta-annotations and annotations on interfaces.
 
The algorithm operates as follows:
Note: in this context, the term recursively means that the search process continues by returning to step #1 with the current interface, annotation, or superclass as the class to look for annotations on.
clazz - the class to look for annotations onannotationType - the type of annotation to look fornull if not found@Deprecated @Nullable public static Class<?> findAnnotationDeclaringClass(Class<? extends Annotation> annotationType, @Nullable Class<?> clazz)
MergedAnnotations APIClass in the inheritance hierarchy of the
 specified clazz (including the specified clazz itself)
 on which an annotation of the specified annotationType is
 directly present.
 If the supplied clazz is an interface, only the interface
 itself will be checked; the inheritance hierarchy for interfaces will
 not be traversed.
 
Meta-annotations will not be searched.
The standard Class API does not provide a mechanism for
 determining which class in an inheritance hierarchy actually declares
 an Annotation, so we need to handle this explicitly.
annotationType - the annotation type to look forclazz - the class to check for the annotation on (may be null)Class in the inheritance hierarchy that
 declares an annotation of the specified annotationType,
 or null if not foundClass.isAnnotationPresent(Class), 
Class.getDeclaredAnnotations()@Deprecated @Nullable public static Class<?> findAnnotationDeclaringClassForTypes(List<Class<? extends Annotation>> annotationTypes, @Nullable Class<?> clazz)
MergedAnnotations APIClass in the inheritance hierarchy of the
 specified clazz (including the specified clazz itself)
 on which at least one of the specified annotationTypes is
 directly present.
 If the supplied clazz is an interface, only the interface
 itself will be checked; the inheritance hierarchy for interfaces will
 not be traversed.
 
Meta-annotations will not be searched.
The standard Class API does not provide a mechanism for
 determining which class in an inheritance hierarchy actually declares
 one of several candidate annotations, so we
 need to handle this explicitly.
annotationTypes - the annotation types to look forclazz - the class to check for the annotation on (may be null)Class in the inheritance hierarchy that
 declares an annotation of at least one of the specified
 annotationTypes, or null if not foundClass.isAnnotationPresent(Class), 
Class.getDeclaredAnnotations()public static boolean isAnnotationDeclaredLocally(Class<? extends Annotation> annotationType, Class<?> clazz)
annotationType
 is declared locally (i.e. directly present) on the supplied
 clazz.
 The supplied Class may represent any type.
 
Meta-annotations will not be searched.
Note: This method does not determine if the annotation is inherited.
annotationType - the annotation type to look forclazz - the class to check for the annotation ontrue if an annotation of the specified annotationType
 is directly presentClass.getDeclaredAnnotations(), 
Class.getDeclaredAnnotation(Class)@Deprecated public static boolean isAnnotationInherited(Class<? extends Annotation> annotationType, Class<?> clazz)
MergedAnnotations APIannotationType
 is present on the supplied clazz and is
 inherited
 (i.e. not directly present).
 Meta-annotations will not be searched.
If the supplied clazz is an interface, only the interface
 itself will be checked. In accordance with standard meta-annotation
 semantics in Java, the inheritance hierarchy for interfaces will not
 be traversed. See the javadoc
 for the @Inherited meta-annotation for further details regarding
 annotation inheritance.
annotationType - the annotation type to look forclazz - the class to check for the annotation ontrue if an annotation of the specified annotationType
 is present and inheritedClass.isAnnotationPresent(Class), 
isAnnotationDeclaredLocally(Class, Class)@Deprecated public static boolean isAnnotationMetaPresent(Class<? extends Annotation> annotationType, @Nullable Class<? extends Annotation> metaAnnotationType)
MergedAnnotations APImetaAnnotationType is
 meta-present on the supplied annotationType.annotationType - the annotation type to search onmetaAnnotationType - the type of meta-annotation to search fortrue if such an annotation is meta-presentpublic static boolean isInJavaLangAnnotationPackage(@Nullable Annotation annotation)
Annotation is defined in the core JDK
 java.lang.annotation package.annotation - the annotation to checktrue if the annotation is in the java.lang.annotation packagepublic static boolean isInJavaLangAnnotationPackage(@Nullable String annotationType)
Annotation with the supplied name is defined
 in the core JDK java.lang.annotation package.annotationType - the name of the annotation type to checktrue if the annotation is in the java.lang.annotation packagepublic static void validateAnnotation(Annotation annotation)
TypeNotPresentExceptionProxy for
 Class values (instead of early Class.getAnnotations() failure.
 This method not failing indicates that getAnnotationAttributes(Annotation)
 won't failure either (when attempted later on).
annotation - the annotation to validateIllegalStateException - if a declared Class attribute could not be readClass.getAnnotations(), 
getAnnotationAttributes(Annotation)public static Map<String,Object> getAnnotationAttributes(Annotation annotation)
Map, preserving all
 attribute types.
 Equivalent to calling getAnnotationAttributes(Annotation, boolean, boolean)
 with the classValuesAsString and nestedAnnotationsAsMap parameters
 set to false.
 
Note: This method actually returns an AnnotationAttributes instance.
 However, the Map signature has been preserved for binary compatibility.
annotation - the annotation to retrieve the attributes fornull)getAnnotationAttributes(AnnotatedElement, Annotation), 
getAnnotationAttributes(Annotation, boolean, boolean), 
getAnnotationAttributes(AnnotatedElement, Annotation, boolean, boolean)public static Map<String,Object> getAnnotationAttributes(Annotation annotation, boolean classValuesAsString)
Map.
 Equivalent to calling getAnnotationAttributes(Annotation, boolean, boolean)
 with the nestedAnnotationsAsMap parameter set to false.
 
Note: This method actually returns an AnnotationAttributes instance.
 However, the Map signature has been preserved for binary compatibility.
annotation - the annotation to retrieve the attributes forclassValuesAsString - whether to convert Class references into Strings (for
 compatibility with AnnotationMetadata)
 or to preserve them as Class referencesnull)getAnnotationAttributes(Annotation, boolean, boolean)public static AnnotationAttributes getAnnotationAttributes(Annotation annotation, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
AnnotationAttributes map.
 This method provides fully recursive annotation reading capabilities on par with
 the reflection-based StandardAnnotationMetadata.
annotation - the annotation to retrieve the attributes forclassValuesAsString - whether to convert Class references into Strings (for
 compatibility with AnnotationMetadata)
 or to preserve them as Class referencesnestedAnnotationsAsMap - whether to convert nested annotations into
 AnnotationAttributes maps (for compatibility with
 AnnotationMetadata) or to preserve them as
 Annotation instancesnull)public static AnnotationAttributes getAnnotationAttributes(@Nullable AnnotatedElement annotatedElement, Annotation annotation)
AnnotationAttributes map.
 Equivalent to calling getAnnotationAttributes(AnnotatedElement, Annotation, boolean, boolean)
 with the classValuesAsString and nestedAnnotationsAsMap parameters
 set to false.
annotatedElement - the element that is annotated with the supplied annotation;
 may be null if unknownannotation - the annotation to retrieve the attributes fornull)getAnnotationAttributes(AnnotatedElement, Annotation, boolean, boolean)public static AnnotationAttributes getAnnotationAttributes(@Nullable AnnotatedElement annotatedElement, Annotation annotation, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
AnnotationAttributes map.
 This method provides fully recursive annotation reading capabilities on par with
 the reflection-based StandardAnnotationMetadata.
annotatedElement - the element that is annotated with the supplied annotation;
 may be null if unknownannotation - the annotation to retrieve the attributes forclassValuesAsString - whether to convert Class references into Strings (for
 compatibility with AnnotationMetadata)
 or to preserve them as Class referencesnestedAnnotationsAsMap - whether to convert nested annotations into
 AnnotationAttributes maps (for compatibility with
 AnnotationMetadata) or to preserve them as
 Annotation instancesnull)public static void registerDefaultValues(AnnotationAttributes attributes)
attributes - the annotation attributes to processpublic static void postProcessAnnotationAttributes(@Nullable Object annotatedElement, @Nullable AnnotationAttributes attributes, boolean classValuesAsString)
AnnotationAttributes, preserving nested
 annotations as Annotation instances.
 Specifically, this method enforces attribute alias semantics
 for annotation attributes that are annotated with @AliasFor
 and replaces default value placeholders with their original default values.
annotatedElement - the element that is annotated with an annotation or
 annotation hierarchy from which the supplied attributes were created;
 may be null if unknownattributes - the annotation attributes to post-processclassValuesAsString - whether to convert Class references into Strings (for
 compatibility with AnnotationMetadata)
 or to preserve them as Class referencesgetDefaultValue(Class, String)@Nullable public static Object getValue(Annotation annotation)
value attribute of a
 single-element Annotation, given an annotation instance.annotation - the annotation instance from which to retrieve the valuenull if not found unless the attribute
 value cannot be retrieved due to an AnnotationConfigurationException,
 in which case such an exception will be rethrowngetValue(Annotation, String)@Nullable public static Object getValue(@Nullable Annotation annotation, @Nullable String attributeName)
annotation - the annotation instance from which to retrieve the valueattributeName - the name of the attribute value to retrievenull if not found unless the attribute
 value cannot be retrieved due to an AnnotationConfigurationException,
 in which case such an exception will be rethrowngetValue(Annotation)@Nullable public static Object getDefaultValue(Annotation annotation)
value attribute
 of a single-element Annotation, given an annotation instance.annotation - the annotation instance from which to retrieve the default valuenull if not foundgetDefaultValue(Annotation, String)@Nullable public static Object getDefaultValue(@Nullable Annotation annotation, @Nullable String attributeName)
annotation - the annotation instance from which to retrieve the default valueattributeName - the name of the attribute value to retrievenull if not foundgetDefaultValue(Class, String)@Nullable public static Object getDefaultValue(Class<? extends Annotation> annotationType)
value attribute
 of a single-element Annotation, given the annotation type.annotationType - the annotation type for which the default value should be retrievednull if not foundgetDefaultValue(Class, String)@Nullable public static Object getDefaultValue(@Nullable Class<? extends Annotation> annotationType, @Nullable String attributeName)
annotation type.annotationType - the annotation type for which the default value should be retrievedattributeName - the name of the attribute value to retrieve.null if not foundgetDefaultValue(Annotation, String)public static <A extends Annotation> A synthesizeAnnotation(A annotation, @Nullable AnnotatedElement annotatedElement)
annotation
 by wrapping it in a dynamic proxy that transparently enforces
 attribute alias semantics for annotation attributes that are
 annotated with @AliasFor.annotation - the annotation to synthesizeannotatedElement - the element that is annotated with the supplied
 annotation; may be null if unknownnull if the supplied annotation is
 null; otherwise the supplied annotation unmodifiedAnnotationConfigurationException - if invalid configuration of
 @AliasFor is detectedsynthesizeAnnotation(Map, Class, AnnotatedElement), 
synthesizeAnnotation(Class)public static <A extends Annotation> A synthesizeAnnotation(Class<A> annotationType)
This method simply delegates to
 synthesizeAnnotation(Map, Class, AnnotatedElement),
 supplying an empty map for the source attribute values and null
 for the AnnotatedElement.
annotationType - the type of annotation to synthesizeIllegalArgumentException - if a required attribute is missingAnnotationConfigurationException - if invalid configuration of
 @AliasFor is detectedsynthesizeAnnotation(Map, Class, AnnotatedElement), 
synthesizeAnnotation(Annotation, AnnotatedElement)public static <A extends Annotation> A synthesizeAnnotation(Map<String,Object> attributes, Class<A> annotationType, @Nullable AnnotatedElement annotatedElement)
annotationType and transparently
 enforces attribute alias semantics for annotation attributes
 that are annotated with @AliasFor.
 The supplied map must contain a key-value pair for every attribute
 defined in the supplied annotationType that is not aliased or
 does not have a default value. Nested maps and nested arrays of maps
 will be recursively synthesized into nested annotations or nested
 arrays of annotations, respectively.
 
Note that AnnotationAttributes is a specialized type of
 Map that is an ideal candidate for this method's
 attributes argument.
attributes - the map of annotation attributes to synthesizeannotationType - the type of annotation to synthesizeannotatedElement - the element that is annotated with the annotation
 corresponding to the supplied attributes; may be null if unknownIllegalArgumentException - if a required attribute is missing or if an
 attribute is not of the correct typeAnnotationConfigurationException - if invalid configuration of
 @AliasFor is detectedsynthesizeAnnotation(Annotation, AnnotatedElement), 
synthesizeAnnotation(Class), 
getAnnotationAttributes(AnnotatedElement, Annotation), 
getAnnotationAttributes(AnnotatedElement, Annotation, boolean, boolean)public static void clearCache()