public final class ConstPool extends Object
Modifier and Type | Field | Description |
---|---|---|
static int |
CONST_Class |
CONSTANT_Class |
static int |
CONST_Double |
CONSTANT_Double |
static int |
CONST_Fieldref |
CONSTANT_Fieldref |
static int |
CONST_Float |
CONSTANT_Float |
static int |
CONST_Integer |
CONSTANT_Integer |
static int |
CONST_InterfaceMethodref |
CONSTANT_InterfaceMethodref |
static int |
CONST_InvokeDynamic |
CONSTANT_MethodHandle |
static int |
CONST_Long |
CONSTANT_Long |
static int |
CONST_MethodHandle |
CONSTANT_MethodHandle |
static int |
CONST_Methodref |
CONSTANT_Methodref |
static int |
CONST_MethodType |
CONSTANT_MethodHandle |
static int |
CONST_Module |
CONSTANT_Module |
static int |
CONST_NameAndType |
CONSTANT_NameAndType |
static int |
CONST_Package |
CONSTANT_Package |
static int |
CONST_String |
CONSTANT_String |
static int |
CONST_Utf8 |
CONSTANT_Utf8 |
static int |
REF_getField |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_getStatic |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_invokeInterface |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_invokeSpecial |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_invokeStatic |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_invokeVirtual |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_newInvokeSpecial |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_putField |
reference_kind of CONSTANT_MethodHandle_info . |
static int |
REF_putStatic |
reference_kind of CONSTANT_MethodHandle_info . |
static CtClass |
THIS |
Represents the class using this constant pool table.
|
Constructor | Description |
---|---|
ConstPool(DataInputStream in) |
Constructs a constant pool table from the given byte stream.
|
ConstPool(String thisclass) |
Constructs a constant pool table.
|
Modifier and Type | Method | Description |
---|---|---|
int |
addClassInfo(String qname) |
Adds a new
CONSTANT_Class_info structure. |
int |
addClassInfo(CtClass c) |
Adds a new
CONSTANT_Class_info structure. |
int |
addDoubleInfo(double d) |
Adds a new
CONSTANT_Double_info
structure. |
int |
addFieldrefInfo(int classInfo,
int nameAndTypeInfo) |
Adds a new
CONSTANT_Fieldref_info structure. |
int |
addFieldrefInfo(int classInfo,
String name,
String type) |
Adds a new
CONSTANT_Fieldref_info structure. |
int |
addFloatInfo(float f) |
Adds a new
CONSTANT_Float_info
structure. |
int |
addIntegerInfo(int i) |
Adds a new
CONSTANT_Integer_info
structure. |
int |
addInterfaceMethodrefInfo(int classInfo,
int nameAndTypeInfo) |
Adds a new
CONSTANT_InterfaceMethodref_info
structure. |
int |
addInterfaceMethodrefInfo(int classInfo,
String name,
String type) |
Adds a new
CONSTANT_InterfaceMethodref_info
structure. |
int |
addInvokeDynamicInfo(int bootstrap,
int nameAndType) |
Adds a new
CONSTANT_InvokeDynamic_info
structure. |
int |
addLongInfo(long l) |
Adds a new
CONSTANT_Long_info
structure. |
int |
addMethodHandleInfo(int kind,
int index) |
Adds a new
CONSTANT_MethodHandle_info
structure. |
int |
addMethodrefInfo(int classInfo,
int nameAndTypeInfo) |
Adds a new
CONSTANT_Methodref_info structure. |
int |
addMethodrefInfo(int classInfo,
String name,
String type) |
Adds a new
CONSTANT_Methodref_info structure. |
int |
addMethodTypeInfo(int desc) |
Adds a new
CONSTANT_MethodType_info
structure. |
int |
addModuleInfo(int nameIndex) |
Adds a new
CONSTANT_Module_info |
int |
addNameAndTypeInfo(int name,
int type) |
Adds a new
CONSTANT_NameAndType_info structure. |
int |
addNameAndTypeInfo(String name,
String type) |
Adds a new
CONSTANT_NameAndType_info structure. |
int |
addPackageInfo(int nameIndex) |
Adds a new
CONSTANT_Package_info |
int |
addStringInfo(String str) |
Adds a new
CONSTANT_String_info
structure. |
int |
addUtf8Info(String utf8) |
Adds a new
CONSTANT_Utf8_info
structure. |
int |
copy(int n,
ConstPool dest,
Map<String,String> classnames) |
Copies the n-th item in this ConstPool object into the destination
ConstPool object.
|
String |
eqMember(String membername,
String desc,
int 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. |
String |
getClassInfo(int index) |
Reads
CONSTANT_Class_info structure
at the given index. |
String |
getClassInfoByDescriptor(int index) |
Reads
CONSTANT_Class_info structure
at the given index. |
String |
getClassName() |
Returns the name of the class using this constant pool table.
|
Set<String> |
getClassNames() |
Get all the class names.
|
double |
getDoubleInfo(int index) |
Reads
CONSTANT_Double_info structure
at the given index. |
int |
getFieldrefClass(int index) |
Reads the
class_index field of the
CONSTANT_Fieldref_info structure
at the given index. |
String |
getFieldrefClassName(int index) |
Reads the
class_index field of the
CONSTANT_Fieldref_info structure
at the given index. |
String |
getFieldrefName(int index) |
Reads the
name_index field of the
CONSTANT_NameAndType_info structure
indirectly specified by the given index. |
int |
getFieldrefNameAndType(int index) |
Reads the
name_and_type_index field of the
CONSTANT_Fieldref_info structure
at the given index. |
String |
getFieldrefType(int index) |
Reads the
descriptor_index field of the
CONSTANT_NameAndType_info structure
indirectly specified by the given index. |
float |
getFloatInfo(int index) |
Reads
CONSTANT_Float_info structure
at the given index. |
int |
getIntegerInfo(int index) |
Reads
CONSTANT_Integer_info structure
at the given index. |
int |
getInterfaceMethodrefClass(int index) |
Reads the
class_index field of the
CONSTANT_InterfaceMethodref_info structure
at the given index. |
String |
getInterfaceMethodrefClassName(int index) |
Reads the
class_index field of the
CONSTANT_InterfaceMethodref_info structure
at the given index. |
String |
getInterfaceMethodrefName(int index) |
Reads the
name_index field of the
CONSTANT_NameAndType_info structure
indirectly specified by the given index. |
int |
getInterfaceMethodrefNameAndType(int index) |
Reads the
name_and_type_index field of the
CONSTANT_InterfaceMethodref_info structure
at the given index. |
String |
getInterfaceMethodrefType(int index) |
Reads the
descriptor_index field of the
CONSTANT_NameAndType_info structure
indirectly specified by the given index. |
int |
getInvokeDynamicBootstrap(int index) |
Reads the
bootstrap_method_attr_index field of the
CONSTANT_InvokeDynamic_info structure
at the given index. |
int |
getInvokeDynamicNameAndType(int index) |
Reads the
name_and_type_index field of the
CONSTANT_InvokeDynamic_info structure
at the given index. |
String |
getInvokeDynamicType(int index) |
Reads the
descriptor_index field of the
CONSTANT_NameAndType_info structure
indirectly specified by the given index. |
Object |
getLdcValue(int index) |
Reads
CONSTANT_Integer_info , _Float_info ,
_Long_info , _Double_info , or
_String_info structure. |
long |
getLongInfo(int index) |
Reads
CONSTANT_Long_info structure
at the given index. |
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. |
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. |
int |
getMethodHandleIndex(int index) |
Reads the
reference_index field of the
CONSTANT_MethodHandle_info structure
at the given index. |
int |
getMethodHandleKind(int index) |
Reads the
reference_kind field of the
CONSTANT_MethodHandle_info structure
at the given index. |
int |
getMethodrefClass(int index) |
Reads the
class_index field of the
CONSTANT_Methodref_info structure
at the given index. |
String |
getMethodrefClassName(int index) |
Reads the
class_index field of the
CONSTANT_Methodref_info structure
at the given index. |
String |
getMethodrefName(int index) |
Reads the
name_index field of the
CONSTANT_NameAndType_info structure
indirectly specified by the given index. |
int |
getMethodrefNameAndType(int index) |
Reads the
name_and_type_index field of the
CONSTANT_Methodref_info structure
at the given index. |
String |
getMethodrefType(int index) |
Reads the
descriptor_index field of the
CONSTANT_NameAndType_info structure
indirectly specified by the given index. |
int |
getMethodTypeInfo(int index) |
Reads the
descriptor_index field of the
CONSTANT_MethodType_info structure
at the given index. |
String |
getModuleInfo(int index) |
Reads the
name_index field of the
CONSTANT_Module_info structure at the given index. |
int |
getNameAndTypeDescriptor(int index) |
Reads the
descriptor_index field of the
CONSTANT_NameAndType_info structure
at the given index. |
int |
getNameAndTypeName(int index) |
Reads the
name_index field of the
CONSTANT_NameAndType_info structure
at the given index. |
String |
getPackageInfo(int index) |
Reads the
name_index field of the
CONSTANT_Package_info structure at the given index. |
int |
getSize() |
Returns the number of entries in this table.
|
String |
getStringInfo(int index) |
Reads
CONSTANT_String_info structure
at the given index. |
int |
getTag(int index) |
Returns the
tag field of the constant pool table
entry at the given index. |
int |
getThisClassInfo() |
Returns the index of
CONSTANT_Class_info structure
specifying the class using this constant pool table. |
String |
getUtf8Info(int index) |
Reads
CONSTANT_utf8_info structure
at the given index. |
int |
isConstructor(String classname,
int index) |
Determines whether
CONSTANT_Methodref_info
structure at the given index represents the constructor
of the given class. |
int |
isMember(String classname,
String membername,
int 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. |
void |
print() |
Prints the contents of the constant pool table.
|
void |
print(PrintWriter out) |
Prints the contents of the constant pool table.
|
void |
renameClass(String oldName,
String newName) |
Replaces all occurrences of a class name.
|
void |
renameClass(Map<String,String> classnames) |
Replaces all occurrences of class names.
|
void |
write(DataOutputStream out) |
Writes the contents of the constant pool table.
|
public static final int CONST_Class
CONSTANT_Class
public static final int CONST_Fieldref
CONSTANT_Fieldref
public static final int CONST_Methodref
CONSTANT_Methodref
public static final int CONST_InterfaceMethodref
CONSTANT_InterfaceMethodref
public static final int CONST_String
CONSTANT_String
public static final int CONST_Integer
CONSTANT_Integer
public static final int CONST_Float
CONSTANT_Float
public static final int CONST_Long
CONSTANT_Long
public static final int CONST_Double
CONSTANT_Double
public static final int CONST_NameAndType
CONSTANT_NameAndType
public static final int CONST_Utf8
CONSTANT_Utf8
public static final int CONST_MethodHandle
CONSTANT_MethodHandle
public static final int CONST_MethodType
CONSTANT_MethodHandle
public static final int CONST_InvokeDynamic
CONSTANT_MethodHandle
public static final int CONST_Module
CONSTANT_Module
public static final int CONST_Package
CONSTANT_Package
public static final CtClass THIS
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_putField
reference_kind
of CONSTANT_MethodHandle_info
.public static final int REF_putStatic
reference_kind
of CONSTANT_MethodHandle_info
.public static final int REF_invokeVirtual
reference_kind
of CONSTANT_MethodHandle_info
.public static final int REF_invokeStatic
reference_kind
of CONSTANT_MethodHandle_info
.public static final int REF_invokeSpecial
reference_kind
of CONSTANT_MethodHandle_info
.public static final int REF_newInvokeSpecial
reference_kind
of CONSTANT_MethodHandle_info
.public static final int REF_invokeInterface
reference_kind
of CONSTANT_MethodHandle_info
.public ConstPool(String thisclass)
thisclass
- the name of the class using this constant
pool tablepublic ConstPool(DataInputStream in) throws IOException
in
- byte stream.IOException
public int getSize()
public String getClassName()
public int getThisClassInfo()
CONSTANT_Class_info
structure
specifying the class using this constant pool table.public int getTag(int index)
tag
field of the constant pool table
entry at the given index.CONST_Class
, CONST_Fieldref
,
CONST_Methodref
, or ...public String getClassInfo(int index)
CONSTANT_Class_info
structure
at the given index.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).ClassPool.getCtClass(String)
public String getClassInfoByDescriptor(int index)
CONSTANT_Class_info
structure
at the given index.name_index
.ClassPool.getCtClass(String)
public int getNameAndTypeName(int index)
name_index
field of the
CONSTANT_NameAndType_info
structure
at the given index.public int getNameAndTypeDescriptor(int index)
descriptor_index
field of the
CONSTANT_NameAndType_info
structure
at the given index.public int getMemberClass(int index)
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)
name_and_type_index
field of the
CONSTANT_Fieldref_info
,
CONSTANT_Methodref_info
,
or CONSTANT_Interfaceref_info
,
structure at the given index.public int getFieldrefClass(int index)
class_index
field of the
CONSTANT_Fieldref_info
structure
at the given index.public String getFieldrefClassName(int index)
class_index
field of the
CONSTANT_Fieldref_info
structure
at the given index.class_index
.public int getFieldrefNameAndType(int index)
name_and_type_index
field of the
CONSTANT_Fieldref_info
structure
at the given index.public String getFieldrefName(int index)
name_index
field of the
CONSTANT_NameAndType_info
structure
indirectly specified by the given index.index
- an index to a CONSTANT_Fieldref_info
.public String getFieldrefType(int index)
descriptor_index
field of the
CONSTANT_NameAndType_info
structure
indirectly specified by the given index.index
- an index to a CONSTANT_Fieldref_info
.public int getMethodrefClass(int index)
class_index
field of the
CONSTANT_Methodref_info
structure
at the given index.public String getMethodrefClassName(int index)
class_index
field of the
CONSTANT_Methodref_info
structure
at the given index.class_index
.public int getMethodrefNameAndType(int index)
name_and_type_index
field of the
CONSTANT_Methodref_info
structure
at the given index.public String getMethodrefName(int index)
name_index
field of the
CONSTANT_NameAndType_info
structure
indirectly specified by the given index.index
- an index to a CONSTANT_Methodref_info
.public String getMethodrefType(int index)
descriptor_index
field of the
CONSTANT_NameAndType_info
structure
indirectly specified by the given index.index
- an index to a CONSTANT_Methodref_info
.public int getInterfaceMethodrefClass(int index)
class_index
field of the
CONSTANT_InterfaceMethodref_info
structure
at the given index.public String getInterfaceMethodrefClassName(int index)
class_index
field of the
CONSTANT_InterfaceMethodref_info
structure
at the given index.class_index
.public int getInterfaceMethodrefNameAndType(int index)
name_and_type_index
field of the
CONSTANT_InterfaceMethodref_info
structure
at the given index.public String getInterfaceMethodrefName(int index)
name_index
field of the
CONSTANT_NameAndType_info
structure
indirectly specified by the given index.index
- an index to
a CONSTANT_InterfaceMethodref_info
.public String getInterfaceMethodrefType(int index)
descriptor_index
field of the
CONSTANT_NameAndType_info
structure
indirectly specified by the given index.index
- an index to
a CONSTANT_InterfaceMethodref_info
.public Object getLdcValue(int index)
CONSTANT_Integer_info
, _Float_info
,
_Long_info
, _Double_info
, or
_String_info
structure.
These are used with the LDC instruction.String
value or a wrapped primitive-type
value.public int getIntegerInfo(int index)
CONSTANT_Integer_info
structure
at the given index.public float getFloatInfo(int index)
CONSTANT_Float_info
structure
at the given index.public long getLongInfo(int index)
CONSTANT_Long_info
structure
at the given index.public double getDoubleInfo(int index)
CONSTANT_Double_info
structure
at the given index.public String getStringInfo(int index)
CONSTANT_String_info
structure
at the given index.string_index
.public String getUtf8Info(int index)
CONSTANT_utf8_info
structure
at the given index.public int getMethodHandleKind(int index)
reference_kind
field of the
CONSTANT_MethodHandle_info
structure
at the given index.REF_getField
,
REF_getStatic
,
REF_invokeInterface
,
REF_invokeSpecial
,
REF_invokeStatic
,
REF_invokeVirtual
,
REF_newInvokeSpecial
,
REF_putField
,
REF_putStatic
public int getMethodHandleIndex(int index)
reference_index
field of the
CONSTANT_MethodHandle_info
structure
at the given index.public int getMethodTypeInfo(int index)
descriptor_index
field of the
CONSTANT_MethodType_info
structure
at the given index.public int getInvokeDynamicBootstrap(int index)
bootstrap_method_attr_index
field of the
CONSTANT_InvokeDynamic_info
structure
at the given index.public int getInvokeDynamicNameAndType(int index)
name_and_type_index
field of the
CONSTANT_InvokeDynamic_info
structure
at the given index.public String getInvokeDynamicType(int index)
descriptor_index
field of the
CONSTANT_NameAndType_info
structure
indirectly specified by the given index.index
- an index to a CONSTANT_InvokeDynamic_info
.public String getModuleInfo(int index)
name_index
field of the
CONSTANT_Module_info
structure at the given index.name_index
.public String getPackageInfo(int index)
name_index
field of the
CONSTANT_Package_info
structure at the given index.name_index
. It is a slash-
separated name such as com/oracle/net.public int isConstructor(String classname, int index)
CONSTANT_Methodref_info
structure at the given index represents the constructor
of the given class.descriptor_index
specifying
the type descriptor of the that constructor.
If it is not that constructor,
isConstructor()
returns 0.public int isMember(String classname, String membername, int index)
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.classname
- the class declaring the membermembername
- the member nameindex
- the index into the constant pool tabledescriptor_index
specifying
the type descriptor of that member.
If it is not that member,
isMember()
returns 0.public String eqMember(String membername, String desc, int index)
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.membername
- the member namedesc
- the descriptor of the member.index
- the index into the constant pool table..._info
structure
at index
.
Otherwise, null if that structure does not
match the given member name and descriptor.public int copy(int n, ConstPool dest, Map<String,String> classnames)
n
- the n-th itemdest
- destination constant pool tableclassnames
- the map or null.public int addClassInfo(CtClass c)
CONSTANT_Class_info
structure.
This also adds a CONSTANT_Utf8_info
structure
for storing the class name.
public int addClassInfo(String qname)
CONSTANT_Class_info
structure.
This also adds a CONSTANT_Utf8_info
structure
for storing the class name.
qname
- a fully-qualified class name
(or the JVM-internal representation of that name).public int addNameAndTypeInfo(String name, String type)
CONSTANT_NameAndType_info
structure.
This also adds CONSTANT_Utf8_info
structures.
name
- name_index
type
- descriptor_index
public int addNameAndTypeInfo(int name, int type)
CONSTANT_NameAndType_info
structure.name
- name_index
type
- descriptor_index
public int addFieldrefInfo(int classInfo, String name, String type)
CONSTANT_Fieldref_info
structure.
This also adds a new CONSTANT_NameAndType_info
structure.
classInfo
- class_index
name
- name_index
of CONSTANT_NameAndType_info
.type
- descriptor_index
of CONSTANT_NameAndType_info
.public int addFieldrefInfo(int classInfo, int nameAndTypeInfo)
CONSTANT_Fieldref_info
structure.classInfo
- class_index
nameAndTypeInfo
- name_and_type_index
.public int addMethodrefInfo(int classInfo, String name, String type)
CONSTANT_Methodref_info
structure.
This also adds a new CONSTANT_NameAndType_info
structure.
classInfo
- class_index
name
- name_index
of CONSTANT_NameAndType_info
.type
- descriptor_index
of CONSTANT_NameAndType_info
.public int addMethodrefInfo(int classInfo, int nameAndTypeInfo)
CONSTANT_Methodref_info
structure.classInfo
- class_index
nameAndTypeInfo
- name_and_type_index
.public int addInterfaceMethodrefInfo(int classInfo, String name, String type)
CONSTANT_InterfaceMethodref_info
structure.
This also adds a new CONSTANT_NameAndType_info
structure.
classInfo
- class_index
name
- name_index
of CONSTANT_NameAndType_info
.type
- descriptor_index
of CONSTANT_NameAndType_info
.public int addInterfaceMethodrefInfo(int classInfo, int nameAndTypeInfo)
CONSTANT_InterfaceMethodref_info
structure.classInfo
- class_index
nameAndTypeInfo
- name_and_type_index
.public int addStringInfo(String str)
CONSTANT_String_info
structure.
This also adds a new CONSTANT_Utf8_info
structure.
public int addIntegerInfo(int i)
CONSTANT_Integer_info
structure.public int addFloatInfo(float f)
CONSTANT_Float_info
structure.public int addLongInfo(long l)
CONSTANT_Long_info
structure.public int addDoubleInfo(double d)
CONSTANT_Double_info
structure.public int addUtf8Info(String utf8)
CONSTANT_Utf8_info
structure.public int addMethodHandleInfo(int kind, int index)
CONSTANT_MethodHandle_info
structure.kind
- reference_kind
such as REF_invokeStatic
.index
- reference_index
.public int addMethodTypeInfo(int desc)
CONSTANT_MethodType_info
structure.desc
- descriptor_index
.public int addInvokeDynamicInfo(int bootstrap, int nameAndType)
CONSTANT_InvokeDynamic_info
structure.bootstrap
- bootstrap_method_attr_index
.nameAndType
- name_and_type_index
.public int addModuleInfo(int nameIndex)
CONSTANT_Module_info
nameIndex
- the index of the Utf8 entry.public int addPackageInfo(int nameIndex)
CONSTANT_Package_info
nameIndex
- the index of the Utf8 entry.public Set<String> getClassNames()
String
objects).public void renameClass(String oldName, String newName)
oldName
- the replaced name (JVM-internal representation).newName
- the substituted name (JVM-internal representation).public void renameClass(Map<String,String> classnames)
classnames
- specifies pairs of replaced and substituted
name.public void write(DataOutputStream out) throws IOException
IOException
public void print()
public void print(PrintWriter out)
Copyright © 2018 Shigeru Chiba, www.javassist.org. All rights reserved.