Package org.apache.bcel.generic
Class AnnotationEntryGen
java.lang.Object
org.apache.bcel.generic.AnnotationEntryGen
Generates annotation entries.
- Since:
- 6.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConstantPoolGen(package private) static final AnnotationEntryGen[]private List<ElementValuePairGen>private booleanprivate int -
Constructor Summary
ConstructorsModifierConstructorDescriptionAnnotationEntryGen(AnnotationEntry a, ConstantPoolGen cpool, boolean copyPoolEntries) Here we are taking a fixed annotation of type Annotation and building a modifiable AnnotationGen object.privateAnnotationEntryGen(ObjectType type, List<ElementValuePairGen> elements, boolean vis, ConstantPoolGen cpool) Constructs an AnnotationEntryGen. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an element name value pair.private List<ElementValuePairGen>copyValues(ElementValuePair[] in, ConstantPoolGen cpool, boolean copyPoolEntries) voiddump(DataOutputStream dos) Dumps this annotation entry to a DataOutputStream.Retrieves an immutable version of this AnnotationGen.(package private) static Attribute[]getAnnotationAttributes(ConstantPoolGen cp, AnnotationEntryGen[] annotationEntryGens) Converts a list of AnnotationGen objects into a set of attributes that can be attached to the class file.(package private) static Attribute[]Annotations against a class are stored in one of four attribute kinds: - RuntimeVisibleParameterAnnotations - RuntimeInvisibleParameterAnnotationsintGets the type index.final StringGets the type name.final StringGets the type signature.Returns list of ElementNameValuePair objects.booleanGets whether this annotation is runtime visible.private voidisRuntimeVisible(boolean b) static AnnotationEntryGenread(DataInput dis, ConstantPoolGen cpool, boolean b) Reads an AnnotationEntryGen from a DataInput.Returns a short string representation of this annotation.toString()
-
Field Details
-
EMPTY_ARRAY
-
typeIndex
private int typeIndex -
evs
-
cpool
-
isRuntimeVisible
private boolean isRuntimeVisible
-
-
Constructor Details
-
AnnotationEntryGen
Here we are taking a fixed annotation of type Annotation and building a modifiable AnnotationGen object. If the pool passed in is for a different class file, then copyPoolEntries should have been passed as true as that will force us to do a deep copy of the annotation and move the cpool entries across. We need to copy the type and the element name value pairs and the visibility.- Parameters:
a- The annotation entry.cpool- The constant pool generator.copyPoolEntries- whether to copy pool entries.
-
AnnotationEntryGen
-
AnnotationEntryGen
public AnnotationEntryGen(ObjectType type, List<ElementValuePairGen> elements, boolean vis, ConstantPoolGen cpool) Constructs an AnnotationEntryGen.- Parameters:
type- The object type.elements- The element value pairs.vis- whether the annotation is visible.cpool- The constant pool generator.
-
-
Method Details
-
getAnnotationAttributes
static Attribute[] getAnnotationAttributes(ConstantPoolGen cp, AnnotationEntryGen[] annotationEntryGens) Converts a list of AnnotationGen objects into a set of attributes that can be attached to the class file.- Parameters:
cp- The constant pool gen where we can create the necessary name refs.annotationEntryGens- An array of AnnotationGen objects.
-
getParameterAnnotationAttributes
static Attribute[] getParameterAnnotationAttributes(ConstantPoolGen cp, List<AnnotationEntryGen>[] vec) Annotations against a class are stored in one of four attribute kinds: - RuntimeVisibleParameterAnnotations - RuntimeInvisibleParameterAnnotations -
read
public static AnnotationEntryGen read(DataInput dis, ConstantPoolGen cpool, boolean b) throws IOException Reads an AnnotationEntryGen from a DataInput.- Parameters:
dis- The data input stream.cpool- The constant pool generator.b- whether the annotation is runtime visible.- Returns:
- The annotation entry generator.
- Throws:
IOException- Thrown if an I/O error occurs.
-
addElementNameValuePair
Adds an element name value pair.- Parameters:
evp- The element value pair generator.
-
copyValues
private List<ElementValuePairGen> copyValues(ElementValuePair[] in, ConstantPoolGen cpool, boolean copyPoolEntries) -
dump
Dumps this annotation entry to a DataOutputStream.- Parameters:
dos- The data output stream.- Throws:
IOException- Thrown if an I/O error occurs.
-
getAnnotation
Retrieves an immutable version of this AnnotationGen.- Returns:
- An immutable version of this AnnotationGen.
-
getTypeIndex
public int getTypeIndex()Gets the type index.- Returns:
- The type index.
-
getTypeName
Gets the type name.- Returns:
- The type name.
-
getTypeSignature
Gets the type signature.- Returns:
- The type signature.
-
getValues
Returns list of ElementNameValuePair objects.- Returns:
- list of ElementNameValuePair objects.
-
isRuntimeVisible
public boolean isRuntimeVisible()Gets whether this annotation is runtime visible.- Returns:
- true if this annotation is runtime visible.
-
isRuntimeVisible
private void isRuntimeVisible(boolean b) -
toShortString
Returns a short string representation of this annotation.- Returns:
- A short string representation of this annotation.
-
toString
-