APIdia Launch Partner
Top Fields Constructors Methods
sun.reflect.annotation

public final Class AnnotationSupport

extends Object
Class Inheritance
Imports
java.lang.annotation.*, java.lang.reflect.*, java.util.ArrayList, .Arrays, .List, .Map, .Objects, jdk.internal.access.SharedSecrets, .JavaLangAccess, jdk.internal.reflect.ReflectionFactory

Field Summary

Modifier and TypeField and Description
private static final JavaLangAccess

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static <A extends Annotation> void
checkTypes(A[] annotations, Annotation container, Class<A> annoClass)

private static <A extends Annotation> boolean

Returns:

true if container class is found before containee class when iterating over annotations.keySet().
containerBeforeContainee
(Map<Class<? extends Annotation>, Annotation> annotations, Class<A> annoClass)

Figures out if container class comes before containee class among the keys of the given map.

public static <A extends Annotation> A[]

Returns:

an array of instances of annoClass or an empty array if none were found.
getAssociatedAnnotations
(Map<Class<? extends Annotation>, Annotation>
the declared annotations indexed by their types
declaredAnnotations
,
Class<?>
the class declaration on which to search for annotations
decl
,
Class<A>
the type of annotation to search for
annoClass
)

Finds and returns all associated annotations matching the given class.

public static <A extends Annotation> A[]

Returns:

an array of instances of annoClass or an empty array if none were found
getDirectlyAndIndirectlyPresent
(Map<Class<? extends Annotation>, Annotation>
the Map in which to search for annotations
annotations
,
Class<A>
the type of annotation to search for
annoClass
)

Finds and returns all annotations in annotations matching the given annoClass.

private static <A extends Annotation> A[]

Returns:

an array of instances of annoClass or an empty array if no indirectly present annotations were found
getIndirectlyPresent
(Map<Class<? extends Annotation>, Annotation>
annotations to search indexed by their types
annotations
,
Class<A>
the type of annotation to search for
annoClass
)

Finds and returns all annotations matching the given annoClass indirectly present in annotations.

private static <A extends Annotation> A[]
private static AnnotationFormatError
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LANG_ACCESSback to summary
private static final JavaLangAccess LANG_ACCESS

Constructor Detail

AnnotationSupportback to summary
public AnnotationSupport()

Method Detail

checkTypesback to summary
private static <A extends Annotation> void checkTypes(A[] annotations, Annotation container, Class<A> annoClass)
containerBeforeContaineeback to summary
private static <A extends Annotation> boolean containerBeforeContainee(Map<Class<? extends Annotation>, Annotation> annotations, Class<A> annoClass)

Figures out if container class comes before containee class among the keys of the given map.

Returns:boolean

true if container class is found before containee class when iterating over annotations.keySet().

getAssociatedAnnotationsback to summary
public static <A extends Annotation> A[] getAssociatedAnnotations(Map<Class<? extends Annotation>, Annotation> declaredAnnotations, Class<?> decl, Class<A> annoClass)

Finds and returns all associated annotations matching the given class. The order of the elements in the array returned depends on the iteration order of the provided maps. Specifically, the directly present annotations come before the indirectly present annotations if and only if the directly present annotations come before the indirectly present annotations in the relevant map.

Parameters
declaredAnnotations:Map<Class<? extends Annotation>, Annotation>

the declared annotations indexed by their types

decl:Class<?>

the class declaration on which to search for annotations

annoClass:Class<A>

the type of annotation to search for

Returns:A[]

an array of instances of annoClass or an empty array if none were found.

getDirectlyAndIndirectlyPresentback to summary
public static <A extends Annotation> A[] getDirectlyAndIndirectlyPresent(Map<Class<? extends Annotation>, Annotation> annotations, Class<A> annoClass)

Finds and returns all annotations in annotations matching the given annoClass. Apart from annotations directly present in annotations this method searches for annotations inside containers i.e. indirectly present annotations. The order of the elements in the array returned depends on the iteration order of the provided map. Specifically, the directly present annotations come before the indirectly present annotations if and only if the directly present annotations come before the indirectly present annotations in the map.

Parameters
annotations:Map<Class<? extends Annotation>, Annotation>

the Map in which to search for annotations

annoClass:Class<A>

the type of annotation to search for

Returns:A[]

an array of instances of annoClass or an empty array if none were found

getIndirectlyPresentback to summary
private static <A extends Annotation> A[] getIndirectlyPresent(Map<Class<? extends Annotation>, Annotation> annotations, Class<A> annoClass)

Finds and returns all annotations matching the given annoClass indirectly present in annotations.

Parameters
annotations:Map<Class<? extends Annotation>, Annotation>

annotations to search indexed by their types

annoClass:Class<A>

the type of annotation to search for

Returns:A[]

an array of instances of annoClass or an empty array if no indirectly present annotations were found

getValueArrayback to summary
private static <A extends Annotation> A[] getValueArray(Annotation container)
invalidContainerExceptionback to summary
private static AnnotationFormatError invalidContainerException(Annotation anno, Throwable cause)