aicas logo Jamaica 3.4 release 8

sun.reflect.annotation
Class AnnotationParser

java.lang.Object
  extended by sun.reflect.annotation.AnnotationParser

public class AnnotationParser
extends Object

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

Since:
1.5

Constructor Summary
AnnotationParser()
           
 
Method Summary
static Annotation annotationForMap(Class type, Map<String,Object> memberValues)
          Returns an annotation of the given type backed by the given member -> value map.
static Map<Class,Annotation> 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationParser

public AnnotationParser()
Method Detail

parseAnnotations

public static Map<Class,Annotation> 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.

parseParameterAnnotations

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.

annotationForMap

public static Annotation annotationForMap(Class type,
                                          Map<String,Object> memberValues)
Returns an annotation of the given type backed by the given member -> value map.


parseMemberValue

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.


aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.