Package com.ibm.wala.shrike.shrikeCT
Class AnnotationsReader
- java.lang.Object
-
- com.ibm.wala.shrike.shrikeCT.AttributeReader
-
- com.ibm.wala.shrike.shrikeCT.AnnotationsReader
-
- Direct Known Subclasses:
TypeAnnotationsReader
public class AnnotationsReader extends AttributeReader
This class reads Annotations attributes, e.g., RuntimeInvisibleAnnotations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnnotationsReader.AnnotationAttributeRepresentation of an annotation attribute.static classAnnotationsReader.AnnotationTypestatic classAnnotationsReader.ArrayElementValuerepresents an annotation argument that itself is an array of argumentsstatic classAnnotationsReader.ConstantElementValueRepresents a constant argument to an annotation.static interfaceAnnotationsReader.ElementValueMarker interface for possible element values in an annotation attribute.static classAnnotationsReader.EnumElementValueRepresents enum constant annotation arguments.
-
Field Summary
Fields Modifier and Type Field Description protected intbeginOffsetoffset in class file where this attribute begins-
Fields inherited from class com.ibm.wala.shrike.shrikeCT.AttributeReader
attr, cr, length
-
-
Constructor Summary
Constructors Constructor Description AnnotationsReader(ClassReader.AttrIterator iter, java.lang.String label)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationsReader.AnnotationAttribute[]getAllAnnotations()get all the annotations declared in this attribute.AnnotationsReader.AnnotationAttribute[][]getAllParameterAnnotations()param_annotations { u2 attribute_name_index; u4 attribute_length; u1 num_parameters; { u2 num_annotations; annotation annotations[num_annotations]; } parameter_annotations[num_parameters];intgetAnnotationCount()protected com.ibm.wala.util.collections.Pair<AnnotationsReader.AnnotationAttribute,java.lang.Integer>getAttributeAndSize(int begin)annotation { u2 type_index; u2 num_element_value_pairs; { u2 element_name_index; element_value value; } element_value_pairs[num_element_value_pairs]intgetAttributeSize()static AnnotationsReadergetReaderForAnnotation(AnnotationsReader.AnnotationType type, ClassReader.AttrIterator iter)protected java.lang.StringgetUtf8ConstantPoolValue(int offset)get the Utf8 constant pool value, where the constant pool offset is given in the classstatic booleanisKnownAnnotation(java.lang.String name)protected com.ibm.wala.util.collections.Pair<AnnotationsReader.ElementValue,java.lang.Integer>readElementValueAndSize(int offset)element_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; element_value values[num_values]; } array_value; } value;-
Methods inherited from class com.ibm.wala.shrike.shrikeCT.AttributeReader
checkSize, checkSizeEquals, getClassReader, getRawOffset, getRawSize
-
-
-
-
Constructor Detail
-
AnnotationsReader
public AnnotationsReader(ClassReader.AttrIterator iter, java.lang.String label) throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
-
Method Detail
-
getAnnotationCount
public int getAnnotationCount() throws InvalidClassFileException- Returns:
- number of annotations in this attribute
- Throws:
InvalidClassFileException
-
getAttributeSize
public int getAttributeSize() throws InvalidClassFileException- Returns:
- total length of this attribute in bytes, including the first 6 bytes
- Throws:
InvalidClassFileException
-
getUtf8ConstantPoolValue
protected java.lang.String getUtf8ConstantPoolValue(int offset) throws InvalidClassFileExceptionget the Utf8 constant pool value, where the constant pool offset is given in the class- Parameters:
offset- offset in the class file at which the constant pool offset is given- Throws:
InvalidClassFileException
-
getAllAnnotations
public AnnotationsReader.AnnotationAttribute[] getAllAnnotations() throws InvalidClassFileException
get all the annotations declared in this attribute.RuntimeVisibleAnnotations_attribute { u2 attribute_name_index; u4 attribute_length; u2 num_annotations; annotation annotations[num_annotations]; }- Throws:
InvalidClassFileException- See Also:
- JLS (SE8), 4.7.16
-
getAllParameterAnnotations
public AnnotationsReader.AnnotationAttribute[][] getAllParameterAnnotations() throws InvalidClassFileException
param_annotations { u2 attribute_name_index; u4 attribute_length; u1 num_parameters; { u2 num_annotations; annotation annotations[num_annotations]; } parameter_annotations[num_parameters];- Throws:
InvalidClassFileException
-
getAttributeAndSize
protected com.ibm.wala.util.collections.Pair<AnnotationsReader.AnnotationAttribute,java.lang.Integer> getAttributeAndSize(int begin) throws InvalidClassFileException
annotation { u2 type_index; u2 num_element_value_pairs; { u2 element_name_index; element_value value; } element_value_pairs[num_element_value_pairs]- Throws:
InvalidClassFileException
-
readElementValueAndSize
protected com.ibm.wala.util.collections.Pair<AnnotationsReader.ElementValue,java.lang.Integer> readElementValueAndSize(int offset) throws java.lang.IllegalArgumentException, InvalidClassFileException
element_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; element_value values[num_values]; } array_value; } value;A constant value (including class info) is represented by aAnnotationsReader.ConstantElementValue. An enum constant value is represented by anAnnotationsReader.EnumElementValue. An array value is represented by anAnnotationsReader.ArrayElementValue. Finally, a nested annotation is represented by anAnnotationsReader.AnnotationAttribute.- Throws:
java.lang.IllegalArgumentExceptionInvalidClassFileException
-
isKnownAnnotation
public static boolean isKnownAnnotation(java.lang.String name)
-
getReaderForAnnotation
public static AnnotationsReader getReaderForAnnotation(AnnotationsReader.AnnotationType type, ClassReader.AttrIterator iter)
-
-