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

public final Class TypeAnnotationParser

extends Object
Class Inheritance
Imports
java.lang.annotation.*, java.lang.reflect.*, java.nio.ByteBuffer, .BufferUnderflowException, java.util.ArrayList, .Arrays, .List, .LinkedHashMap, .Map, jdk.internal.access.SharedSecrets, .JavaLangAccess, jdk.internal.reflect.ConstantPool

TypeAnnotationParser implements the logic needed to parse TypeAnnotations from an array of bytes.

Field Summary

Modifier and TypeField and Description
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final TypeAnnotation[]
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static AnnotatedType[]
buildAnnotatedInterfaces(byte[]
the byte[] encoding of all type annotations on this declaration
rawAnnotations
,
ConstantPool
the ConstantPool needed to parse the embedded Annotation
cp
,
Class<?>
the Class whose annotated implemented interfaces is being built
decl
)

Build an array of AnnotatedTypes for the class decl's implemented interfaces.

public static AnnotatedType
buildAnnotatedSuperclass(byte[]
the byte[] encoding of all type annotations on this declaration
rawAnnotations
,
ConstantPool
the ConstantPool needed to parse the embedded Annotation
cp
,
Class<?>
the Class which annotated supertype is being built
decl
)

Build an AnnotatedType for the class decl's supertype.

public static AnnotatedType
buildAnnotatedType(byte[]
the byte[] encoding of all type annotations on this declaration
rawAnnotations
,
ConstantPool
the ConstantPool needed to parse the embedded Annotation
cp
,
AnnotatedElement
the declaration this type annotation is on
decl
,
Class<?>
the Class this type annotation is on (may be the same as decl)
container
,
Type
the type the AnnotatedType corresponds to
type
,
TypeAnnotation.TypeAnnotationTarget
the type annotation targets included in this AnnotatedType
filter
)

Build an AnnotatedType from the parameters supplied.

public static AnnotatedType[]
buildAnnotatedTypes(byte[]
the byte[] encoding of all type annotations on this declaration
rawAnnotations
,
ConstantPool
the ConstantPool needed to parse the embedded Annotation
cp
,
AnnotatedElement
the declaration this type annotation is on
decl
,
Class<?>
the Class this type annotation is on (may be the same as decl)
container
,
Type[]
the Types the AnnotatedTypes corresponds to
types
,
TypeAnnotation.TypeAnnotationTarget
the type annotation targets that included in this AnnotatedType
filter
)

Build an array of AnnotatedTypes from the parameters supplied.

private static <D extends GenericDeclaration> List<TypeAnnotation>
fetchBounds(D decl)

pack-priv static Map<Class<? extends Annotation>, Annotation>
private static TypeAnnotation.TypeAnnotationTargetInfo
pack-priv static TypeAnnotation[]
public static <D extends GenericDeclaration> AnnotatedType[]
parseAnnotatedBounds(Type[]
the bounds corresponding to the annotated bounds
bounds
,
D
the declaration whose annotated bounds is being built
decl
,
int
the index of this type variable on the decl
typeVarIndex
)

Build an array of AnnotatedTypes for the declaration decl's bounds.

private static <D extends GenericDeclaration> AnnotatedType[]
parseAnnotatedBounds(Type[] bounds, D decl, int typeVarIndex, TypeAnnotation.LocationInfo loc)

private static TypeAnnotation.TypeAnnotationTargetInfo
private static TypeAnnotation.TypeAnnotationTargetInfo
private static TypeAnnotation
private static TypeAnnotation[]
parseTypeAnnotations(byte[] rawAnnotations, ConstantPool cp, AnnotatedElement baseDecl, Class<?> container)

public static <D extends GenericDeclaration> Annotation[]
parseTypeVariableAnnotations(D
the declaration declaring the type variable
genericDecl
,
int
the 0-based index of this type variable in the declaration
typeVarIndex
)

Parse regular annotations on a TypeVariable declared on genericDecl.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CASTback to summary
private static final byte CAST
CLASS_EXTENDSback to summary
private static final byte CLASS_EXTENDS
CLASS_TYPE_PARAMETERback to summary
private static final byte CLASS_TYPE_PARAMETER
CLASS_TYPE_PARAMETER_BOUNDback to summary
private static final byte CLASS_TYPE_PARAMETER_BOUND
CONSTRUCTOR_INVOCATION_TYPE_ARGUMENTback to summary
private static final byte CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
CONSTRUCTOR_REFERENCEback to summary
private static final byte CONSTRUCTOR_REFERENCE
CONSTRUCTOR_REFERENCE_TYPE_ARGUMENTback to summary
private static final byte CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
EMPTY_TYPE_ANNOTATION_ARRAYback to summary
private static final TypeAnnotation[] EMPTY_TYPE_ANNOTATION_ARRAY
EXCEPTION_PARAMETERback to summary
private static final byte EXCEPTION_PARAMETER
FIELDback to summary
private static final byte FIELD
INSTANCEOFback to summary
private static final byte INSTANCEOF
LOCAL_VARIABLEback to summary
private static final byte LOCAL_VARIABLE
METHOD_FORMAL_PARAMETERback to summary
private static final byte METHOD_FORMAL_PARAMETER
METHOD_INVOCATION_TYPE_ARGUMENTback to summary
private static final byte METHOD_INVOCATION_TYPE_ARGUMENT
METHOD_RECEIVERback to summary
private static final byte METHOD_RECEIVER
METHOD_REFERENCEback to summary
private static final byte METHOD_REFERENCE
METHOD_REFERENCE_TYPE_ARGUMENTback to summary
private static final byte METHOD_REFERENCE_TYPE_ARGUMENT
METHOD_RETURNback to summary
private static final byte METHOD_RETURN
METHOD_TYPE_PARAMETERback to summary
private static final byte METHOD_TYPE_PARAMETER
METHOD_TYPE_PARAMETER_BOUNDback to summary
private static final byte METHOD_TYPE_PARAMETER_BOUND
NEWback to summary
private static final byte NEW
RESOURCE_VARIABLEback to summary
private static final byte RESOURCE_VARIABLE
THROWSback to summary
private static final byte THROWS

Constructor Detail

TypeAnnotationParserback to summary
public TypeAnnotationParser()

Method Detail

buildAnnotatedInterfacesback to summary
public static AnnotatedType[] buildAnnotatedInterfaces(byte[] rawAnnotations, ConstantPool cp, Class<?> decl)

Build an array of AnnotatedTypes for the class decl's implemented interfaces.

Parameters
rawAnnotations:byte[]

the byte[] encoding of all type annotations on this declaration

cp:ConstantPool

the ConstantPool needed to parse the embedded Annotation

decl:Class<?>

the Class whose annotated implemented interfaces is being built

buildAnnotatedSuperclassback to summary
public static AnnotatedType buildAnnotatedSuperclass(byte[] rawAnnotations, ConstantPool cp, Class<?> decl)

Build an AnnotatedType for the class decl's supertype.

Parameters
rawAnnotations:byte[]

the byte[] encoding of all type annotations on this declaration

cp:ConstantPool

the ConstantPool needed to parse the embedded Annotation

decl:Class<?>

the Class which annotated supertype is being built

buildAnnotatedTypeback to summary
public static AnnotatedType buildAnnotatedType(byte[] rawAnnotations, ConstantPool cp, AnnotatedElement decl, Class<?> container, Type type, TypeAnnotation.TypeAnnotationTarget filter)

Build an AnnotatedType from the parameters supplied. This method and buildAnnotatedTypes are probably the entry points you are looking for.

Parameters
rawAnnotations:byte[]

the byte[] encoding of all type annotations on this declaration

cp:ConstantPool

the ConstantPool needed to parse the embedded Annotation

decl:AnnotatedElement

the declaration this type annotation is on

container:Class<?>

the Class this type annotation is on (may be the same as decl)

type:Type

the type the AnnotatedType corresponds to

filter:TypeAnnotation.TypeAnnotationTarget

the type annotation targets included in this AnnotatedType

buildAnnotatedTypesback to summary
public static AnnotatedType[] buildAnnotatedTypes(byte[] rawAnnotations, ConstantPool cp, AnnotatedElement decl, Class<?> container, Type[] types, TypeAnnotation.TypeAnnotationTarget filter)

Build an array of AnnotatedTypes from the parameters supplied. This method and buildAnnotatedType are probably the entry points you are looking for.

Parameters
rawAnnotations:byte[]

the byte[] encoding of all type annotations on this declaration

cp:ConstantPool

the ConstantPool needed to parse the embedded Annotation

decl:AnnotatedElement

the declaration this type annotation is on

container:Class<?>

the Class this type annotation is on (may be the same as decl)

types:Type[]

the Types the AnnotatedTypes corresponds to

filter:TypeAnnotation.TypeAnnotationTarget

the type annotation targets that included in this AnnotatedType

fetchBoundsback to summary
private static <D extends GenericDeclaration> List<TypeAnnotation> fetchBounds(D decl)
mapTypeAnnotationsback to summary
pack-priv static Map<Class<? extends Annotation>, Annotation> mapTypeAnnotations(TypeAnnotation[] typeAnnos)
parse2ByteTargetback to summary
private static TypeAnnotation.TypeAnnotationTargetInfo parse2ByteTarget(TypeAnnotation.TypeAnnotationTarget target, ByteBuffer buf)
parseAllTypeAnnotationsback to summary
pack-priv static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl)
parseAnnotatedBoundsback to summary
public static <D extends GenericDeclaration> AnnotatedType[] parseAnnotatedBounds(Type[] bounds, D decl, int typeVarIndex)

Build an array of AnnotatedTypes for the declaration decl's bounds.

Parameters
bounds:Type[]

the bounds corresponding to the annotated bounds

decl:D

the declaration whose annotated bounds is being built

typeVarIndex:int

the index of this type variable on the decl

parseAnnotatedBoundsback to summary
private static <D extends GenericDeclaration> AnnotatedType[] parseAnnotatedBounds(Type[] bounds, D decl, int typeVarIndex, TypeAnnotation.LocationInfo loc)
parseShortTargetback to summary
private static TypeAnnotation.TypeAnnotationTargetInfo parseShortTarget(TypeAnnotation.TypeAnnotationTarget target, ByteBuffer buf)
parseTargetInfoback to summary
private static TypeAnnotation.TypeAnnotationTargetInfo parseTargetInfo(ByteBuffer buf)
parseTypeAnnotationback to summary
private static TypeAnnotation parseTypeAnnotation(ByteBuffer buf, ConstantPool cp, AnnotatedElement baseDecl, Class<?> container)
parseTypeAnnotationsback to summary
private static TypeAnnotation[] parseTypeAnnotations(byte[] rawAnnotations, ConstantPool cp, AnnotatedElement baseDecl, Class<?> container)
parseTypeVariableAnnotationsback to summary
public static <D extends GenericDeclaration> Annotation[] parseTypeVariableAnnotations(D genericDecl, int typeVarIndex)

Parse regular annotations on a TypeVariable declared on genericDecl. Regular Annotations on TypeVariables are stored in the type annotation byte[] in the class file.

Parameters
genericDecl:D

the declaration declaring the type variable

typeVarIndex:int

the 0-based index of this type variable in the declaration