Class ConstantPool

java.lang.Object
org.openjdk.asmtools.jdis.ConstantPool

public class ConstantPool extends Object
ConstantPool Class representing the ConstantPool
  • Field Details

  • Constructor Details

    • ConstantPool

      public ConstantPool(ClassData cd)
    • ConstantPool

      public ConstantPool(ClassData cd, int size)
  • Method Details

    • setPrintTAG

      public void setPrintTAG(boolean value)
    • getPrintedTAG

      public String getPrintedTAG(ConstantPool.TAG tag)
    • read

      void read(DataInputStream in) throws IOException
      read decodes a ConstantPool and it's constants from a data stream.
      Throws:
      IOException
    • inbounds

      private boolean inbounds(int cpx)
      inbounds bounds-check a CP index.
    • getConst

      public ConstantPool.Constant getConst(int cpx)
      getConst Public getter - Safely gets a Constant from the CP at a given index.
    • StringTag

      public String StringTag(int cpx)
      StringTag Public string val - Safely gets the string-rep of a Constant from the CP at a given index.
    • getString

      public String getString(int cpx)
      getString Public string val - Safely gets the string-rep of a ConstantUTF8 from the CP at a given index. Returns either null (if invalid), or the string value of the UTF8
    • getModule

      public String getModule(int cpx)
      getModule Public string val - Safely gets the string-rep of a ConstantModule from the CP at a given index. Returns either null (if invalid), or the string value of the ConstantModule
    • getPackage

      public String getPackage(int cpx)
      getPackage Public string val - Safely gets the string-rep of a ConstantPackage from the CP at a given index. Returns either null (if invalid), or the string value of the ConstantPackage
    • getName

      public String getName(int cpx)
      getTypeName Safely gets a Java name from a ConstantUTF8 from the CP at a given index. Returns either null (if invalid), or the Java name value of the UTF8
    • getClassName

      public String getClassName(int cpx)
      getClassName Safely gets a Java class name from a ConstantClass from the CP at a given index. Returns either the Java class name, or a CP index reference string.
    • getClassName

      public String getClassName(ConstantPool.CPX2 classConst)
      getClassName Safely gets a Java class name from a ConstantClass from a CPX2 constant pool object. (eg. Method/Field/Interface Ref) Returns either the Java class name, or a CP index reference string.
    • getClassName

      public String getClassName(ConstantPool.CPX classConst)
      getClassName Safely gets a Java class name from a ConstantClass from a CPX constant pool object. (eg. Class Ref) Returns either the Java class name, or a CP index reference string.
    • _getClassName

      private String _getClassName(int nameIndex)
      _getClassName Helper for getting class name. Checks bounds, does name conversion.
    • getShortClassName

      public String getShortClassName(String className, String pkgPrefix)
      getShortClassName shortens a class name (if the class is in the given package). works with a string-encoded classname.
    • getShortClassName

      public String getShortClassName(int cpx, String pkgPrefix)
      getShortClassName shortens a class name (if the class is in the given package). works with a CP index to a ConstantClass.
    • decodeClassDescriptor

      public String decodeClassDescriptor(int cpx)
      decodeClassDescriptor Pulls the class name out of a string (at the CP index). (drops any array descriptors, and the class descriptors ("L" and ";")
    • subtagToString

      private String subtagToString(int subtag)
      subtagToString Getter that safely gets the string descriptor of a subtag
    • StringValue

      public String StringValue(int cpx)
      StringValue Safely gets the string value of any Constant at any CP index.
    • ConstantStrValue

      public String ConstantStrValue(int cpx)
      ConstantStrValue Safely gets the string value of any Constant at any CP index. This string is either a Constant's String value, or a CP index reference string. The Constant string has a tag descriptor in the beginning.
    • print

      public void print(PrintWriter out) throws IOException
      prints the entire constant pool.
      Throws:
      IOException
    • PrintConstant

      void PrintConstant(PrintWriter out, int cpx)
      prints the Constant value at a given CP index.
    • printlnClassId

      public void printlnClassId(PrintWriter out, int cpx) throws IOException
      prints a constant value, with the print format based on the print options.
      Throws:
      IOException
    • printlnClassId

      public void printlnClassId(PrintWriter out, int cpx, boolean addComma) throws IOException
      Throws:
      IOException