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 Details

    • RuntimeAnnotationsAttr

      public RuntimeAnnotationsAttr(String name, AnnotationEntry[] entries, int numEntries, AttrContainer container)
      Add a new AnnotationAttr to a Member.
  • Method Details

    • 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 is RUNTIME, add to the RuntimeVisibleAnnotations attribute. If the annotation's retention policy is CLASS, add to the RuntimeInvisibleAnnotations 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).
      Specified by:
      getLength in class Attribute
    • print

      public void print(ClassTypeWriter dst)
      Overrides:
      print in class Attribute
    • 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 class Attribute
    • 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 class Attribute
      Throws:
      IOException