public class

AnnotationParser

extends Object
java.lang.Object
   ↳ sun.reflect.annotation.AnnotationParser

Class Overview

Parser for Java programming language annotations. Translates annotation byte streams emitted by compiler into annotation objects.

Summary

Public Constructors
AnnotationParser()
Public Methods
static Annotation annotationForMap(Class type, Map<StringObject> memberValues)
Returns an annotation of the given type backed by the given member -> value map.
static Map<ClassAnnotation> parseAnnotations(byte[] rawAnnotations, ConstantPool constPool, Class container)
Parses the annotations described by the specified byte array.
static Object parseMemberValue(Class memberType, ByteBuffer buf, ConstantPool constPool, Class container)
Parses the annotation member value at the current position in the specified byte buffer, resolving constant references in the specified constant pool.
static Annotation[][] parseParameterAnnotations(byte[] rawAnnotations, ConstantPool constPool, Class container)
Parses the parameter annotations described by the specified byte array.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AnnotationParser ()

Public Methods

public static Annotation annotationForMap (Class type, Map<StringObject> memberValues)

Returns an annotation of the given type backed by the given member -> value map.

public static Map<ClassAnnotation> parseAnnotations (byte[] rawAnnotations, ConstantPool constPool, Class container)

Parses the annotations described by the specified byte array. resolving constant references in the specified constant pool. The array must contain an array of annotations as described in the RuntimeVisibleAnnotations_attribute: u2 num_annotations; annotation annotations[num_annotations];

Throws
AnnotationFormatError if an annotation is found to be malformed.

public static Object parseMemberValue (Class memberType, ByteBuffer buf, ConstantPool constPool, Class container)

Parses the annotation member value at the current position in the specified byte buffer, resolving constant references in the specified constant pool. The cursor of the byte buffer must point to a "member_value structure" as described in the RuntimeVisibleAnnotations_attribute: member_value { u1 tag; union { u2 const_value_index; { u2 type_name_index; u2 const_name_index; } enum_const_value; u2 class_info_index; annotation annotation_value; { u2 num_values; member_value values[num_values]; } array_value; } value; } The member must be of the indicated type. If it is not, this method returns an AnnotationTypeMismatchExceptionProxy.

public static Annotation[][] parseParameterAnnotations (byte[] rawAnnotations, ConstantPool constPool, Class container)

Parses the parameter annotations described by the specified byte array. resolving constant references in the specified constant pool. The array must contain an array of annotations as described in the RuntimeVisibleParameterAnnotations_attribute: u1 num_parameters; { u2 num_annotations; annotation annotations[num_annotations]; } parameter_annotations[num_parameters]; Unlike parseAnnotations, rawAnnotations must not be null! A null value must be handled by the caller. This is so because we cannot determine the number of parameters if rawAnnotations is null. Also, the caller should check that the number of parameters indicated by the return value of this method matches the actual number of method parameters. A mismatch indicates that an AnnotationFormatError should be thrown.

Throws
AnnotationFormatError if an annotation is found to be malformed.