Top Description Fields Constructors Methods
javassist.bytecode

public final Class ConstPool

Additional top-level classes in compilation unit: ConstInfo, ConstInfoPadding, ClassInfo, NameAndTypeInfo, MemberrefInfo, FieldrefInfo, MethodrefInfo, InterfaceMethodrefInfo, StringInfo, IntegerInfo, FloatInfo, LongInfo, DoubleInfo, Utf8Info, MethodHandleInfo, MethodTypeInfo, InvokeDynamicInfo, DynamicInfo, ModuleInfo, PackageInfo.

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .DataInputStream, .DataOutputStream, .IOException, .PrintWriter, java.util.HashMap, .HashSet, .Map, .Set, javassist.CtClass

Constant pool table.

Field Summary

Modifier and TypeField and Description
public static final int
CONST_Class

CONSTANT_Class

public static final int
CONST_Double

CONSTANT_Double

public static final int
CONST_Dynamic

CONSTANT_Dynamic

public static final int
CONST_DynamicCallSite

CONSTANT_DynamicCallSite, also known as CONSTANT_InvokeDynamic

public static final int
CONST_Fieldref

CONSTANT_Fieldref

public static final int
CONST_Float

CONSTANT_Float

public static final int
CONST_Integer

CONSTANT_Integer

public static final int
CONST_InterfaceMethodref

CONSTANT_InterfaceMethodref

public static final int
public static final int
CONST_Long

CONSTANT_Long

public static final int
CONST_MethodHandle

CONSTANT_MethodHandle

public static final int
CONST_Methodref

CONSTANT_Methodref

public static final int
CONST_MethodType

CONSTANT_MethodHandle

public static final int
CONST_Module

CONSTANT_Module

public static final int
CONST_NameAndType

CONSTANT_NameAndType

public static final int
CONST_Package

CONSTANT_Package

public static final int
CONST_String

CONSTANT_String

public static final int
CONST_Utf8

CONSTANT_Utf8

pack-priv LongVector
pack-priv Map<ConstInfo, ConstInfo>
pack-priv int
public static final int
REF_getField

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_getStatic

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_invokeInterface

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_invokeSpecial

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_invokeStatic

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_invokeVirtual

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_newInvokeSpecial

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_putField

reference_kind of CONSTANT_MethodHandle_info.

public static final int
REF_putStatic

reference_kind of CONSTANT_MethodHandle_info.

public static final CtClass
THIS

Represents the class using this constant pool table.

pack-priv int

Constructor Summary

AccessConstructor and Description
public
ConstPool(String
the name of the class using this constant pool table
thisclass
)

Constructs a constant pool table.

public
ConstPool(DataInputStream
byte stream.
in
)

Constructs a constant pool table from the given byte stream.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the index of the added entry.
addClassInfo
(CtClass c)

Adds a new CONSTANT_Class_info structure.

public int

Returns:

the index of the added entry.
addClassInfo
(String
a fully-qualified class name (or the JVM-internal representation of that name).
qname
)

Adds a new CONSTANT_Class_info structure.

pack-priv int
public int

Returns:

the index of the added entry.
addDoubleInfo
(double d)

Adds a new CONSTANT_Double_info structure.

public int

Returns:

the index of the added entry.
addDynamicInfo
(int
bootstrap_method_attr_index.
bootstrap
,
int
name_and_type_index.
nameAndType
)

Adds a new CONSTANT_Dynamic_info structure.

public int

Returns:

the index of the added entry.
addFieldrefInfo
(int
class_index
classInfo
,
String
name_index of CONSTANT_NameAndType_info.
name
,
String
descriptor_index of CONSTANT_NameAndType_info.
type
)

Adds a new CONSTANT_Fieldref_info structure.

public int

Returns:

the index of the added entry.
addFieldrefInfo
(int
class_index
classInfo
,
int
name_and_type_index.
nameAndTypeInfo
)

Adds a new CONSTANT_Fieldref_info structure.

public int

Returns:

the index of the added entry.
addFloatInfo
(float f)

Adds a new CONSTANT_Float_info structure.

public int

Returns:

the index of the added entry.
addIntegerInfo
(int i)

Adds a new CONSTANT_Integer_info structure.

public int

Returns:

the index of the added entry.
addInterfaceMethodrefInfo
(int
class_index
classInfo
,
String
name_index of CONSTANT_NameAndType_info.
name
,
String
descriptor_index of CONSTANT_NameAndType_info.
type
)

Adds a new CONSTANT_InterfaceMethodref_info structure.

public int

Returns:

the index of the added entry.
addInterfaceMethodrefInfo
(int
class_index
classInfo
,
int
name_and_type_index.
nameAndTypeInfo
)

Adds a new CONSTANT_InterfaceMethodref_info structure.

public int

Returns:

the index of the added entry.
addInvokeDynamicInfo
(int
bootstrap_method_attr_index.
bootstrap
,
int
name_and_type_index.
nameAndType
)

Adds a new CONSTANT_InvokeDynamic_info structure.

private int
private int
public int

Returns:

the index of the added entry.
addLongInfo
(long l)

Adds a new CONSTANT_Long_info structure.

public int

Returns:

the index of the added entry.
addMethodHandleInfo
(int
reference_kind such as REF_invokeStatic.
kind
,
int
reference_index.
index
)

Adds a new CONSTANT_MethodHandle_info structure.

public int

Returns:

the index of the added entry.
addMethodrefInfo
(int
class_index
classInfo
,
String
name_index of CONSTANT_NameAndType_info.
name
,
String
descriptor_index of CONSTANT_NameAndType_info.
type
)

Adds a new CONSTANT_Methodref_info structure.

public int

Returns:

the index of the added entry.
addMethodrefInfo
(int
class_index
classInfo
,
int
name_and_type_index.
nameAndTypeInfo
)

Adds a new CONSTANT_Methodref_info structure.

public int

Returns:

the index of the added entry.
addMethodTypeInfo
(int
descriptor_index.
desc
)

Adds a new CONSTANT_MethodType_info structure.

public int

Returns:

the index of the added entry.
addModuleInfo
(int
the index of the Utf8 entry.
nameIndex
)

Adds a new CONSTANT_Module_info

public int

Returns:

the index of the added entry.
addNameAndTypeInfo
(String
name_index
name
,
String
descriptor_index
type
)

Adds a new CONSTANT_NameAndType_info structure.

public int

Returns:

the index of the added entry.
addNameAndTypeInfo
(int
name_index
name
,
int
descriptor_index
type
)

Adds a new CONSTANT_NameAndType_info structure.

public int

Returns:

the index of the added entry.
addPackageInfo
(int
the index of the Utf8 entry.
nameIndex
)

Adds a new CONSTANT_Package_info

public int

Returns:

the index of the added entry.
addStringInfo
(String str)

Adds a new CONSTANT_String_info structure.

public int

Returns:

the index of the added entry.
addUtf8Info
(String utf8)

Adds a new CONSTANT_Utf8_info structure.

public int

Returns:

the index of the copied item into the destination ClassPool.
copy
(int
the n-th item
n
,
ConstPool
destination constant pool table
dest
,
Map<String, String>
the map or null.
classnames
)

Copies the n-th item in this ConstPool object into the destination ConstPool object.

public String

Returns:

the name of the target class specified by the ..._info structure at index. Otherwise, null if that structure does not match the given member name and descriptor.
eqMember
(String
the member name
membername
,
String
the descriptor of the member.
desc
,
int
the index into the constant pool table
index
)

Determines whether CONSTANT_Methodref_info, CONSTANT_Fieldref_info, or CONSTANT_InterfaceMethodref_info structure at the given index has the name and the descriptor given as the arguments.

public String

Returns:

a fully-qualified class or interface name specified by name_index. If the type is an array type, this method returns an encoded name like [Ljava.lang.Object; (note that the separators are not slashes but dots).
getClassInfo
(int index)

Reads CONSTANT_Class_info structure at the given index.

public String

Returns:

the descriptor of the type specified by name_index.
getClassInfoByDescriptor
(int index)

Reads CONSTANT_Class_info structure at the given index.

public String
getClassName()

Returns the name of the class using this constant pool table.

public Set<String>

Returns:

a set of class names (String objects).
getClassNames
()

Get all the class names.

public double

Returns:

the value specified by this entry.
getDoubleInfo
(int index)

Reads CONSTANT_Double_info structure at the given index.

public int
getDynamicBootstrap(int index)

Reads the bootstrap_method_attr_index field of the CONSTANT_Dynamic_info structure at the given index.

public int
getDynamicNameAndType(int index)

Reads the name_and_type_index field of the CONSTANT_Dynamic_info structure at the given index.

public String

Returns:

the descriptor of the bootstrap method.
getDynamicType
(int
an index to a CONSTANT_Dynamic_info.
index
)

Reads the descriptor_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

public int
getFieldrefClass(int index)

Reads the class_index field of the CONSTANT_Fieldref_info structure at the given index.

public String

Returns:

the name of the class at that class_index.
getFieldrefClassName
(int index)

Reads the class_index field of the CONSTANT_Fieldref_info structure at the given index.

public String

Returns:

the name of the field.
getFieldrefName
(int
an index to a CONSTANT_Fieldref_info.
index
)

Reads the name_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

public int
getFieldrefNameAndType(int index)

Reads the name_and_type_index field of the CONSTANT_Fieldref_info structure at the given index.

public String

Returns:

the type descriptor of the field.
getFieldrefType
(int
an index to a CONSTANT_Fieldref_info.
index
)

Reads the descriptor_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

public float

Returns:

the value specified by this entry.
getFloatInfo
(int index)

Reads CONSTANT_Float_info structure at the given index.

public int

Returns:

the value specified by this entry.
getIntegerInfo
(int index)

Reads CONSTANT_Integer_info structure at the given index.

public int
getInterfaceMethodrefClass(int index)

Reads the class_index field of the CONSTANT_InterfaceMethodref_info structure at the given index.

public String

Returns:

the name of the class at that class_index.
getInterfaceMethodrefClassName
(int index)

Reads the class_index field of the CONSTANT_InterfaceMethodref_info structure at the given index.

public String

Returns:

the name of the method.
getInterfaceMethodrefName
(int
an index to a CONSTANT_InterfaceMethodref_info.
index
)

Reads the name_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

public int
getInterfaceMethodrefNameAndType(int index)

Reads the name_and_type_index field of the CONSTANT_InterfaceMethodref_info structure at the given index.

public String

Returns:

the descriptor of the method.
getInterfaceMethodrefType
(int
an index to a CONSTANT_InterfaceMethodref_info.
index
)

Reads the descriptor_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

public int
getInvokeDynamicBootstrap(int index)

Reads the bootstrap_method_attr_index field of the CONSTANT_InvokeDynamic_info structure at the given index.

public int
getInvokeDynamicNameAndType(int index)

Reads the name_and_type_index field of the CONSTANT_InvokeDynamic_info structure at the given index.

public String

Returns:

the descriptor of the bootstrap method.
getInvokeDynamicType
(int
an index to a CONSTANT_InvokeDynamic_info.
index
)

Reads the descriptor_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

pack-priv ConstInfo
getItem(int n)

public Object

Returns:

a String value or a wrapped primitive-type value.
getLdcValue
(int index)

Reads CONSTANT_Integer_info, _Float_info, _Long_info, _Double_info, or _String_info structure.

public long

Returns:

the value specified by this entry.
getLongInfo
(int index)

Reads CONSTANT_Long_info structure at the given index.

public int
getMemberClass(int index)

Reads the class_index field of the CONSTANT_Fieldref_info, CONSTANT_Methodref_info, or CONSTANT_Interfaceref_info, structure at the given index.

public int
getMemberNameAndType(int index)

Reads the name_and_type_index field of the CONSTANT_Fieldref_info, CONSTANT_Methodref_info, or CONSTANT_Interfaceref_info, structure at the given index.

public int
getMethodHandleIndex(int index)

Reads the reference_index field of the CONSTANT_MethodHandle_info structure at the given index.

public int
getMethodHandleKind(int index)

Reads the reference_kind field of the CONSTANT_MethodHandle_info structure at the given index.

public int
getMethodrefClass(int index)

Reads the class_index field of the CONSTANT_Methodref_info structure at the given index.

public String

Returns:

the name of the class at that class_index.
getMethodrefClassName
(int index)

Reads the class_index field of the CONSTANT_Methodref_info structure at the given index.

public String

Returns:

the name of the method.
getMethodrefName
(int
an index to a CONSTANT_Methodref_info.
index
)

Reads the name_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

public int
getMethodrefNameAndType(int index)

Reads the name_and_type_index field of the CONSTANT_Methodref_info structure at the given index.

public String

Returns:

the descriptor of the method.
getMethodrefType
(int
an index to a CONSTANT_Methodref_info.
index
)

Reads the descriptor_index field of the CONSTANT_NameAndType_info structure indirectly specified by the given index.

public int
getMethodTypeInfo(int index)

Reads the descriptor_index field of the CONSTANT_MethodType_info structure at the given index.

public String

Returns:

the module name at name_index.
getModuleInfo
(int index)

Reads the name_index field of the CONSTANT_Module_info structure at the given index.

public int
getNameAndTypeDescriptor(int index)

Reads the descriptor_index field of the CONSTANT_NameAndType_info structure at the given index.

public int
getNameAndTypeName(int index)

Reads the name_index field of the CONSTANT_NameAndType_info structure at the given index.

public String

Returns:

the package name at name_index. It is a slash- separated name such as com/oracle/net.
getPackageInfo
(int index)

Reads the name_index field of the CONSTANT_Package_info structure at the given index.

public int
getSize()

Returns the number of entries in this table.

public String

Returns:

the string specified by string_index.
getStringInfo
(int index)

Reads CONSTANT_String_info structure at the given index.

public int

Returns:

either CONST_Class, CONST_Fieldref, CONST_Methodref, or ...
getTag
(int index)

Returns the tag field of the constant pool table entry at the given index.

public int
getThisClassInfo()

Returns the index of CONSTANT_Class_info structure specifying the class using this constant pool table.

public String

Returns:

the string specified by this entry.
getUtf8Info
(int index)

Reads CONSTANT_utf8_info structure at the given index.

public int

Returns:

the descriptor_index specifying the type descriptor of the that constructor. If it is not that constructor, isConstructor() returns 0.
isConstructor
(String classname, int index)

Determines whether CONSTANT_Methodref_info structure at the given index represents the constructor of the given class.

public int

Returns:

the descriptor_index specifying the type descriptor of that member. If it is not that member, isMember() returns 0.
isMember
(String
the class declaring the member
classname
,
String
the member name
membername
,
int
the index into the constant pool table
index
)

Determines whether CONSTANT_Methodref_info, CONSTANT_Fieldref_info, or CONSTANT_InterfaceMethodref_info structure at the given index represents the member with the specified name and declaring class.

private static Map<ConstInfo, ConstInfo>
pack-priv void
private void
private int
public void
renameClass(String
the replaced name (JVM-internal representation).
oldName
,
String
the substituted name (JVM-internal representation).
newName
)

Replaces all occurrences of a class name.

public void
renameClass(Map<String, String>
specifies pairs of replaced and substituted name.
classnames
)

Replaces all occurrences of class names.

pack-priv void
public void
write(DataOutputStream out)

Writes the contents of the constant pool table.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait