Package gnu.bytecode
Class RuntimeAnnotationsAttr
java.lang.Object
gnu.bytecode.Attribute
gnu.bytecode.RuntimeAnnotationsAttr
Represents a "RuntimeVisibleAnnotations" or "RuntimeInvisibleAnnotations" attribute.
-
Constructor Summary
ConstructorsConstructorDescriptionRuntimeAnnotationsAttr
(String name, AnnotationEntry[] entries, int numEntries, AttrContainer container) Add a new AnnotationAttr to a Member. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an annotation to this attribute.void
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
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 Details
-
RuntimeAnnotationsAttr
public RuntimeAnnotationsAttr(String name, AnnotationEntry[] entries, int numEntries, AttrContainer container) Add a new AnnotationAttr to a Member.
-
-
Method Details
-
getAnnotationsAttr
-
getRuntimeVisibleAnnotations
Get or create a RuntimeVisibleAnnotations attribute. -
getRuntimeInvisibleAnnotations
Get or create a RuntimeInvisibleAnnotations attribute. -
getAnnotation
-
getAnnotation
-
maybeAddAnnotation
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
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
-
assignConstants
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
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
-