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 void
addAnnotation(AnnotationEntry ann)
Add an annotation to this attribute.void
assignConstants(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 RuntimeAnnotationsAttr
getAnnotationsAttr(AttrContainer container, String name)
int
getLength()
Return the length of the attribute in bytes.static RuntimeAnnotationsAttr
getRuntimeInvisibleAnnotations(AttrContainer container)
Get or create a RuntimeInvisibleAnnotations attribute.static RuntimeAnnotationsAttr
getRuntimeVisibleAnnotations(AttrContainer container)
Get or create a RuntimeVisibleAnnotations attribute.static void
maybeAddAnnotation(AttrContainer container, AnnotationEntry annotation)
Add to appropriate annotations attribute.void
print(ClassTypeWriter dst)
void
write(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 theRuntimeVisibleAnnotations
attribute. If the annotation's retention policy isCLASS
, add to theRuntimeInvisibleAnnotations
attribute. 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:Attribute
Add any needed constant pool entries for this Attribute. Overridden by sub-classes. Do any other cleanup needed before writing out a .class file.- Overrides:
assignConstants
in classAttribute
-
write
public void write(DataOutputStream dstr) throws IOException
Description copied from class:Attribute
Write out the contents of the Attribute. Does not write the 6-byte attribute header.- Specified by:
write
in classAttribute
- Throws:
IOException
-
-