Package org.openjdk.asmtools.jdis
Class ConstantPool
- java.lang.Object
-
- org.openjdk.asmtools.jdis.ConstantPool
-
public class ConstantPool extends java.lang.ObjectConstantPool Class representing the ConstantPool
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classConstantPool.ConstantConstant Base class of all constant entries(package private) classConstantPool.CP_DoubleCP_Double Constant entries that contain double-precision float data.(package private) classConstantPool.CP_FloatCP_Float Constant entries that contain Float data.(package private) classConstantPool.CP_IntCP_Int Constant entries that contain Integer data.(package private) classConstantPool.CP_LongCP_Long Constant entries that contain LongInteger data.(package private) classConstantPool.CP_StrCP_Str Constant entries that contain String data.(package private) classConstantPool.CPXCPX Constant entries that contain a single constant-pool index.(package private) classConstantPool.CPX2CPX2 Constant entries that contain two constant-pool indices.(package private) classConstantPool.Indentstatic classConstantPool.SUBTAGSUBTAG A Tag descriptor of form method-handle constantsstatic classConstantPool.TAGTAG A Tag descriptor of constants in the constant pool
-
Field Summary
Fields Modifier and Type Field Description private ClassDatacdReference to the class dataprivate ConstantPool.Indentindentjava.util.ArrayList<ConstantPool.Constant>poolThe actual pool of Constantsprivate booleanprintTAGprivate static java.util.Hashtable<java.lang.Byte,ConstantPool.SUBTAG>subtaghashprivate static java.util.Hashtable<java.lang.Byte,ConstantPool.TAG>taghash
-
Constructor Summary
Constructors Constructor Description ConstantPool(ClassData cd)ConstantPool(ClassData cd, int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String_getClassName(int nameIndex)_getClassName Helper for getting class name.java.lang.StringConstantStrValue(int cpx)ConstantStrValue Safely gets the string value of any Constant at any CP index.java.lang.StringdecodeClassDescriptor(int cpx)decodeClassDescriptor Pulls the class name out of a string (at the CP index).java.lang.StringgetClassName(int cpx)getClassName Safely gets a Java class name from a ConstantClass from the CP at a given index.java.lang.StringgetClassName(ConstantPool.CPX classConst)getClassName Safely gets a Java class name from a ConstantClass from a CPX constant pool object.java.lang.StringgetClassName(ConstantPool.CPX2 classConst)getClassName Safely gets a Java class name from a ConstantClass from a CPX2 constant pool object.ConstantPool.ConstantgetConst(int cpx)getConst Public getter - Safely gets a Constant from the CP at a given index.java.lang.StringgetModule(int cpx)getModule Public string val - Safely gets the string-rep of a ConstantModule from the CP at a given index.java.lang.StringgetName(int cpx)getTypeName Safely gets a Java name from a ConstantUTF8 from the CP at a given index.java.lang.StringgetPackage(int cpx)getPackage Public string val - Safely gets the string-rep of a ConstantPackage from the CP at a given index.java.lang.StringgetPrintedTAG(ConstantPool.TAG tag)java.lang.StringgetShortClassName(int cpx, java.lang.String pkgPrefix)getShortClassName shortens a class name (if the class is in the given package).java.lang.StringgetShortClassName(java.lang.String className, java.lang.String pkgPrefix)getShortClassName shortens a class name (if the class is in the given package).java.lang.StringgetString(int cpx)getString Public string val - Safely gets the string-rep of a ConstantUTF8 from the CP at a given index.private booleaninbounds(int cpx)inbounds bounds-check a CP index.voidprint(java.io.PrintWriter out)prints the entire constant pool.(package private) voidPrintConstant(java.io.PrintWriter out, int cpx)prints the Constant value at a given CP index.voidprintlnClassId(java.io.PrintWriter out, int cpx)prints a constant value, with the print format based on the print options.voidprintlnClassId(java.io.PrintWriter out, int cpx, boolean addComma)(package private) voidread(java.io.DataInputStream in)read decodes a ConstantPool and it's constants from a data stream.voidsetPrintTAG(boolean value)java.lang.StringStringTag(int cpx)StringTag Public string val - Safely gets the string-rep of a Constant from the CP at a given index.java.lang.StringStringValue(int cpx)StringValue Safely gets the string value of any Constant at any CP index.private java.lang.StringsubtagToString(int subtag)subtagToString Getter that safely gets the string descriptor of a subtag
-
-
-
Field Detail
-
taghash
private static final java.util.Hashtable<java.lang.Byte,ConstantPool.TAG> taghash
-
subtaghash
private static final java.util.Hashtable<java.lang.Byte,ConstantPool.SUBTAG> subtaghash
-
printTAG
private boolean printTAG
-
indent
private final ConstantPool.Indent indent
-
pool
public java.util.ArrayList<ConstantPool.Constant> pool
The actual pool of Constants
-
cd
private ClassData cd
Reference to the class data
-
-
Method Detail
-
setPrintTAG
public void setPrintTAG(boolean value)
-
getPrintedTAG
public java.lang.String getPrintedTAG(ConstantPool.TAG tag)
-
read
void read(java.io.DataInputStream in) throws java.io.IOException
read decodes a ConstantPool and it's constants from a data stream.- Throws:
java.io.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String _getClassName(int nameIndex)
_getClassName Helper for getting class name. Checks bounds, does name conversion.
-
getShortClassName
public java.lang.String getShortClassName(java.lang.String className, java.lang.String pkgPrefix)getShortClassName shortens a class name (if the class is in the given package). works with a string-encoded classname.
-
getShortClassName
public java.lang.String getShortClassName(int cpx, java.lang.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 java.lang.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 java.lang.String subtagToString(int subtag)
subtagToString Getter that safely gets the string descriptor of a subtag
-
StringValue
public java.lang.String StringValue(int cpx)
StringValue Safely gets the string value of any Constant at any CP index.
-
ConstantStrValue
public java.lang.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(java.io.PrintWriter out) throws java.io.IOExceptionprints the entire constant pool.- Throws:
java.io.IOException
-
PrintConstant
void PrintConstant(java.io.PrintWriter out, int cpx)prints the Constant value at a given CP index.
-
printlnClassId
public void printlnClassId(java.io.PrintWriter out, int cpx) throws java.io.IOExceptionprints a constant value, with the print format based on the print options.- Throws:
java.io.IOException
-
printlnClassId
public void printlnClassId(java.io.PrintWriter out, int cpx, boolean addComma) throws java.io.IOException- Throws:
java.io.IOException
-
-