Package gnu.bytecode
Class RuntimeAnnotationsAttr
- java.lang.Object
-
- gnu.bytecode.Attribute
-
- gnu.bytecode.RuntimeAnnotationsAttr
-
public class RuntimeAnnotationsAttr extends Attribute
Represents a "RuntimeVisibleAnnotations" or "RuntimeInvisibleAnnotations" attribute.
-
-
Constructor Summary
Constructors Constructor Description RuntimeAnnotationsAttr(String name, AnnotationEntry[] entries, int numEntries, AttrContainer container)Add a new AnnotationAttr to a Member.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(AnnotationEntry ann)Add an annotation to this attribute.voidassignConstants(ClassType cl)Add any needed constant pool entries for this Attribute.static <T extends Annotation>
TgetAnnotation(AttrContainer container, Class<T> clas)<T extends Annotation>
TgetAnnotation(Class<T> clas)static RuntimeAnnotationsAttrgetAnnotationsAttr(AttrContainer container, String name)intgetLength()Return the length of the attribute in bytes.static RuntimeAnnotationsAttrgetRuntimeInvisibleAnnotations(AttrContainer container)Get or create a RuntimeInvisibleAnnotations attribute.static RuntimeAnnotationsAttrgetRuntimeVisibleAnnotations(AttrContainer container)Get or create a RuntimeVisibleAnnotations attribute.static voidmaybeAddAnnotation(AttrContainer container, AnnotationEntry annotation)Add to appropriate annotations attribute.voidprint(ClassTypeWriter dst)voidwrite(DataOutputStream dstr)Write out the contents of the Attribute.-
Methods inherited from class gnu.bytecode.Attribute
addToFrontOf, assignConstants, count, get, getConstants, getContainer, getLengthAll, getName, getNameIndex, getNext, isSkipped, setContainer, setName, setNameIndex, setNext, setSkipped, setSkipped, writeAll
-
-
-
-
Constructor Detail
-
RuntimeAnnotationsAttr
public RuntimeAnnotationsAttr(String name, AnnotationEntry[] entries, int numEntries, AttrContainer container)
Add a new AnnotationAttr to a Member.
-
-
Method Detail
-
getAnnotationsAttr
public static RuntimeAnnotationsAttr getAnnotationsAttr(AttrContainer container, String name)
-
getRuntimeVisibleAnnotations
public static RuntimeAnnotationsAttr getRuntimeVisibleAnnotations(AttrContainer container)
Get or create a RuntimeVisibleAnnotations attribute.
-
getRuntimeInvisibleAnnotations
public static RuntimeAnnotationsAttr getRuntimeInvisibleAnnotations(AttrContainer container)
Get or create a RuntimeInvisibleAnnotations attribute.
-
getAnnotation
public <T extends Annotation> T getAnnotation(Class<T> clas)
-
getAnnotation
public static <T extends Annotation> T getAnnotation(AttrContainer container, Class<T> clas)
-
maybeAddAnnotation
public static void maybeAddAnnotation(AttrContainer container, AnnotationEntry annotation)
Add to appropriate annotations attribute. If the annotation's retention policy isRUNTIME, add to theRuntimeVisibleAnnotationsattribute. If the annotation's retention policy isCLASS, add to theRuntimeInvisibleAnnotationsattribute. Otherwise, ignore the annotation.
-
addAnnotation
public void addAnnotation(AnnotationEntry ann)
Add an annotation to this attribute.
-
getLength
public int getLength()
Return the length of the attribute in bytes. Does not include the 6-byte header (for the name_index and the length).
-
print
public void print(ClassTypeWriter dst)
-
assignConstants
public void assignConstants(ClassType cl)
Description copied from class:AttributeAdd any needed constant pool entries for this Attribute. Overridden by sub-classes. Do any other cleanup needed before writing out a .class file.- Overrides:
assignConstantsin classAttribute
-
write
public void write(DataOutputStream dstr) throws IOException
Description copied from class:AttributeWrite out the contents of the Attribute. Does not write the 6-byte attribute header.- Specified by:
writein classAttribute- Throws:
IOException
-
-