Package serp.bytecode

Class Annotations

All Implemented Interfaces:
BCEntity, VisitAcceptor

public class Annotations extends Attribute
Java annotation data.
  • Field Details

    • _annotations

      private final List _annotations
  • Constructor Details

    • Annotations

      Annotations(int nameIndex, Attributes owner)
  • Method Details

    • isRuntime

      public boolean isRuntime()
      Whether these annotations are runtime-visible.
    • getAnnotations

      public Annotation[] getAnnotations()
      All declared annotations.
    • setAnnotations

      public void setAnnotations(Annotation[] annos)
      Set the annotations. This method is useful when importing annotations from another instance.
    • getAnnotation

      public Annotation getAnnotation(Class type)
      Return the annotation of the given type, or null if none.
    • getAnnotation

      public Annotation getAnnotation(BCClass type)
      Return the annotation of the given type, or null if none.
    • getAnnotation

      public Annotation getAnnotation(String type)
      Return the annotation of the given type, or null if none.
    • addAnnotation

      public Annotation addAnnotation(Annotation an)
      Import an annotation from another instance.
      Returns:
      the newly added annotation
    • addAnnotation

      public Annotation addAnnotation(Class type)
      Add a new annotation.
    • addAnnotation

      public Annotation addAnnotation(BCClass type)
      Add a new annotation.
    • addAnnotation

      public Annotation addAnnotation(String type)
      Add a new annotation.
    • clear

      public void clear()
      Remove all annotations.
    • removeAnnotation

      public boolean removeAnnotation(Annotation anno)
      Remove the given annotation.
      Returns:
      true if an annotation was removed, false otherwise
    • removeAnnotation

      public boolean removeAnnotation(Class type)
      Remove the annotation of the given type.
      Returns:
      true if an annotation was removed, false otherwise
    • removeAnnotation

      public boolean removeAnnotation(BCClass type)
      Remove the annotation of the given type.
      Returns:
      true if an annotation was removed, false otherwise
    • removeAnnotation

      public boolean removeAnnotation(String type)
      Remove the annotation of the given type.
      Returns:
      true if an annotation was removed, false otherwise
    • getLength

      int getLength()
      Description copied from class: Attribute
      Return the length of the bytecode representation of this attribute in bytes, excluding the name index.
      Overrides:
      getLength in class Attribute
    • read

      void read(Attribute other)
      Description copied from class: Attribute
      Copy the information from the given attribute to this one. Does nothing by default.
      Overrides:
      read in class Attribute
    • read

      void read(DataInput in, int length) throws IOException
      Description copied from class: Attribute
      Read the attribute bytecode from the given stream, up to length bytes, excluding the name index. Does nothing by default.
      Overrides:
      read in class Attribute
      Throws:
      IOException
    • write

      void write(DataOutput out, int length) throws IOException
      Description copied from class: Attribute
      Write the attribute bytecode to the given stream, up to length bytes, excluding the name index. Does nothing by default.
      Overrides:
      write in class Attribute
      Throws:
      IOException
    • acceptVisit

      public void acceptVisit(BCVisitor visit)
      Description copied from interface: VisitAcceptor
      Accept a visit from a BCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.