Package org.openjdk.asmtools.jdis
Class ConstantPool
- java.lang.Object
-
- org.openjdk.asmtools.jdis.ConstantPool
-
public class ConstantPool extends java.lang.Object
ConstantPool Class representing the ConstantPool
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ConstantPool.Constant
Constant Base class of all constant entries(package private) class
ConstantPool.CP_Double
CP_Double Constant entries that contain double-precision float data.(package private) class
ConstantPool.CP_Float
CP_Float Constant entries that contain Float data.(package private) class
ConstantPool.CP_Int
CP_Int Constant entries that contain Integer data.(package private) class
ConstantPool.CP_Long
CP_Long Constant entries that contain LongInteger data.(package private) class
ConstantPool.CP_Str
CP_Str Constant entries that contain String data.(package private) class
ConstantPool.CPX
CPX Constant entries that contain a single constant-pool index.(package private) class
ConstantPool.CPX2
CPX2 Constant entries that contain two constant-pool indices.(package private) class
ConstantPool.Indent
static class
ConstantPool.SUBTAG
SUBTAG A Tag descriptor of form method-handle constantsstatic class
ConstantPool.TAG
TAG A Tag descriptor of constants in the constant pool
-
Field Summary
Fields Modifier and Type Field Description private ClassData
cd
Reference to the class dataprivate ConstantPool.Indent
indent
java.util.ArrayList<ConstantPool.Constant>
pool
The actual pool of Constantsprivate boolean
printTAG
private static java.util.Hashtable<java.lang.Byte,ConstantPool.SUBTAG>
subtaghash
private 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.String
ConstantStrValue(int cpx)
ConstantStrValue Safely gets the string value of any Constant at any CP index.java.lang.String
decodeClassDescriptor(int cpx)
decodeClassDescriptor Pulls the class name out of a string (at the CP index).java.lang.String
getClassName(int cpx)
getClassName Safely gets a Java class name from a ConstantClass from the CP at a given index.java.lang.String
getClassName(ConstantPool.CPX classConst)
getClassName Safely gets a Java class name from a ConstantClass from a CPX constant pool object.java.lang.String
getClassName(ConstantPool.CPX2 classConst)
getClassName Safely gets a Java class name from a ConstantClass from a CPX2 constant pool object.ConstantPool.Constant
getConst(int cpx)
getConst Public getter - Safely gets a Constant from the CP at a given index.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.java.lang.String
getName(int cpx)
getTypeName Safely gets a Java name from a ConstantUTF8 from the CP at a given index.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.java.lang.String
getPrintedTAG(ConstantPool.TAG tag)
java.lang.String
getShortClassName(int cpx, java.lang.String pkgPrefix)
getShortClassName shortens a class name (if the class is in the given package).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).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.private boolean
inbounds(int cpx)
inbounds bounds-check a CP index.void
print(java.io.PrintWriter out)
prints the entire constant pool.(package private) void
PrintConstant(java.io.PrintWriter out, int cpx)
prints the Constant value at a given CP index.void
printlnClassId(java.io.PrintWriter out, int cpx)
prints a constant value, with the print format based on the print options.void
printlnClassId(java.io.PrintWriter out, int cpx, boolean addComma)
(package private) void
read(java.io.DataInputStream in)
read decodes a ConstantPool and it's constants from a data stream.void
setPrintTAG(boolean value)
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.java.lang.String
StringValue(int cpx)
StringValue Safely gets the string value of any Constant at any CP index.private java.lang.String
subtagToString(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.IOException
prints 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.IOException
prints 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
-
-