Class ConstantPool

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

public class ConstantPool extends Object
ConstantPool Class representing the ConstantPool
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Constant Base class of all constant entries
    static enum 
    SUBTAG A Tag descriptor of form method-handle constants
    static enum 
    TAG A Tag descriptor of constants in the constant pool
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The actual pool of Constants
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ConstantPool(ClassData cd, int size)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    ConstantStrValue Safely gets the string value of any Constant at any CP index.
    decodeClassDescriptor Pulls the class name out of a string (at the CP index).
    getClassName(int cpx)
    getClassName Safely gets a Java class name from a ConstantClass from the CP at a given index.
    getClassName(org.openjdk.asmtools.jdis.ConstantPool.CPX classConst)
    getClassName Safely gets a Java class name from a ConstantClass from a CPX constant pool object.
    getClassName(org.openjdk.asmtools.jdis.ConstantPool.CPX2 classConst)
    getClassName Safely gets a Java class name from a ConstantClass from a CPX2 constant pool object.
    getConst(int cpx)
    getConst Public getter - Safely gets a Constant from the CP at a given index.
    getModule(int cpx)
    getModule Public string val - Safely gets the string-rep of a ConstantModule from the CP at a given index.
    getName(int cpx)
    getTypeName Safely gets a Java name from a ConstantUTF8 from the CP at a given index.
    getPackage(int cpx)
    getPackage Public string val - Safely gets the string-rep of a ConstantPackage from the CP at a given index.
     
    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.
    getShortClassName(String className, String pkgPrefix)
    getShortClassName shortens a class name (if the class is in the given package). works with a string-encoded classname.
    getString(int cpx)
    getString Public string val - Safely gets the string-rep of a ConstantUTF8 from the CP at a given index.
    void
    prints the entire constant pool.
    void
    printlnClassId(PrintWriter out, int cpx)
    prints a constant value, with the print format based on the print options.
    void
    printlnClassId(PrintWriter out, int cpx, boolean addComma)
     
    void
    setPrintTAG(boolean value)
     
    StringTag(int cpx)
    StringTag Public string val - Safely gets the string-rep of a Constant from the CP at a given index.
    StringValue(int cpx)
    StringValue Safely gets the string value of any Constant at any CP index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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)
    • 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(org.openjdk.asmtools.jdis.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(org.openjdk.asmtools.jdis.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.
    • 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 ";")
    • 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
    • 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