Package javassist.bytecode
Class ConstPool
- java.lang.Object
-
- javassist.bytecode.ConstPool
-
public final class ConstPool extends Object
Constant pool table.
-
-
Field Summary
Fields Modifier and Type Field Description static intCONST_ClassCONSTANT_Classstatic intCONST_DoubleCONSTANT_Doublestatic intCONST_DynamicCONSTANT_Dynamicstatic intCONST_DynamicCallSiteCONSTANT_DynamicCallSite, also known asCONSTANT_InvokeDynamicstatic intCONST_FieldrefCONSTANT_Fieldrefstatic intCONST_FloatCONSTANT_Floatstatic intCONST_IntegerCONSTANT_Integerstatic intCONST_InterfaceMethodrefCONSTANT_InterfaceMethodrefstatic intCONST_InvokeDynamicstatic intCONST_LongCONSTANT_Longstatic intCONST_MethodHandleCONSTANT_MethodHandlestatic intCONST_MethodrefCONSTANT_Methodrefstatic intCONST_MethodTypeCONSTANT_MethodHandlestatic intCONST_ModuleCONSTANT_Modulestatic intCONST_NameAndTypeCONSTANT_NameAndTypestatic intCONST_PackageCONSTANT_Packagestatic intCONST_StringCONSTANT_Stringstatic intCONST_Utf8CONSTANT_Utf8static intREF_getFieldreference_kindofCONSTANT_MethodHandle_info.static intREF_getStaticreference_kindofCONSTANT_MethodHandle_info.static intREF_invokeInterfacereference_kindofCONSTANT_MethodHandle_info.static intREF_invokeSpecialreference_kindofCONSTANT_MethodHandle_info.static intREF_invokeStaticreference_kindofCONSTANT_MethodHandle_info.static intREF_invokeVirtualreference_kindofCONSTANT_MethodHandle_info.static intREF_newInvokeSpecialreference_kindofCONSTANT_MethodHandle_info.static intREF_putFieldreference_kindofCONSTANT_MethodHandle_info.static intREF_putStaticreference_kindofCONSTANT_MethodHandle_info.static CtClassTHISRepresents the class using this constant pool table.
-
Constructor Summary
Constructors Constructor Description ConstPool(DataInputStream in)Constructs a constant pool table from the given byte stream.ConstPool(String thisclass)Constructs a constant pool table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddClassInfo(String qname)Adds a newCONSTANT_Class_infostructure.intaddClassInfo(CtClass c)Adds a newCONSTANT_Class_infostructure.intaddDoubleInfo(double d)Adds a newCONSTANT_Double_infostructure.intaddDynamicInfo(int bootstrap, int nameAndType)Adds a newCONSTANT_Dynamic_infostructure.intaddFieldrefInfo(int classInfo, int nameAndTypeInfo)Adds a newCONSTANT_Fieldref_infostructure.intaddFieldrefInfo(int classInfo, String name, String type)Adds a newCONSTANT_Fieldref_infostructure.intaddFloatInfo(float f)Adds a newCONSTANT_Float_infostructure.intaddIntegerInfo(int i)Adds a newCONSTANT_Integer_infostructure.intaddInterfaceMethodrefInfo(int classInfo, int nameAndTypeInfo)Adds a newCONSTANT_InterfaceMethodref_infostructure.intaddInterfaceMethodrefInfo(int classInfo, String name, String type)Adds a newCONSTANT_InterfaceMethodref_infostructure.intaddInvokeDynamicInfo(int bootstrap, int nameAndType)Adds a newCONSTANT_InvokeDynamic_infostructure.intaddLongInfo(long l)Adds a newCONSTANT_Long_infostructure.intaddMethodHandleInfo(int kind, int index)Adds a newCONSTANT_MethodHandle_infostructure.intaddMethodrefInfo(int classInfo, int nameAndTypeInfo)Adds a newCONSTANT_Methodref_infostructure.intaddMethodrefInfo(int classInfo, String name, String type)Adds a newCONSTANT_Methodref_infostructure.intaddMethodTypeInfo(int desc)Adds a newCONSTANT_MethodType_infostructure.intaddModuleInfo(int nameIndex)Adds a newCONSTANT_Module_infointaddNameAndTypeInfo(int name, int type)Adds a newCONSTANT_NameAndType_infostructure.intaddNameAndTypeInfo(String name, String type)Adds a newCONSTANT_NameAndType_infostructure.intaddPackageInfo(int nameIndex)Adds a newCONSTANT_Package_infointaddStringInfo(String str)Adds a newCONSTANT_String_infostructure.intaddUtf8Info(String utf8)Adds a newCONSTANT_Utf8_infostructure.intcopy(int n, ConstPool dest, Map<String,String> classnames)Copies the n-th item in this ConstPool object into the destination ConstPool object.StringeqMember(String membername, String desc, int index)Determines whetherCONSTANT_Methodref_info,CONSTANT_Fieldref_info, orCONSTANT_InterfaceMethodref_infostructure at the given index has the name and the descriptor given as the arguments.StringgetClassInfo(int index)ReadsCONSTANT_Class_infostructure at the given index.StringgetClassInfoByDescriptor(int index)ReadsCONSTANT_Class_infostructure at the given index.StringgetClassName()Returns the name of the class using this constant pool table.Set<String>getClassNames()Get all the class names.doublegetDoubleInfo(int index)ReadsCONSTANT_Double_infostructure at the given index.intgetDynamicBootstrap(int index)Reads thebootstrap_method_attr_indexfield of theCONSTANT_Dynamic_infostructure at the given index.intgetDynamicNameAndType(int index)Reads thename_and_type_indexfield of theCONSTANT_Dynamic_infostructure at the given index.StringgetDynamicType(int index)Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.intgetFieldrefClass(int index)Reads theclass_indexfield of theCONSTANT_Fieldref_infostructure at the given index.StringgetFieldrefClassName(int index)Reads theclass_indexfield of theCONSTANT_Fieldref_infostructure at the given index.StringgetFieldrefName(int index)Reads thename_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.intgetFieldrefNameAndType(int index)Reads thename_and_type_indexfield of theCONSTANT_Fieldref_infostructure at the given index.StringgetFieldrefType(int index)Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.floatgetFloatInfo(int index)ReadsCONSTANT_Float_infostructure at the given index.intgetIntegerInfo(int index)ReadsCONSTANT_Integer_infostructure at the given index.intgetInterfaceMethodrefClass(int index)Reads theclass_indexfield of theCONSTANT_InterfaceMethodref_infostructure at the given index.StringgetInterfaceMethodrefClassName(int index)Reads theclass_indexfield of theCONSTANT_InterfaceMethodref_infostructure at the given index.StringgetInterfaceMethodrefName(int index)Reads thename_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.intgetInterfaceMethodrefNameAndType(int index)Reads thename_and_type_indexfield of theCONSTANT_InterfaceMethodref_infostructure at the given index.StringgetInterfaceMethodrefType(int index)Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.intgetInvokeDynamicBootstrap(int index)Reads thebootstrap_method_attr_indexfield of theCONSTANT_InvokeDynamic_infostructure at the given index.intgetInvokeDynamicNameAndType(int index)Reads thename_and_type_indexfield of theCONSTANT_InvokeDynamic_infostructure at the given index.StringgetInvokeDynamicType(int index)Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.ObjectgetLdcValue(int index)ReadsCONSTANT_Integer_info,_Float_info,_Long_info,_Double_info, or_String_infostructure.longgetLongInfo(int index)ReadsCONSTANT_Long_infostructure at the given index.intgetMemberClass(int index)Reads theclass_indexfield of theCONSTANT_Fieldref_info,CONSTANT_Methodref_info, orCONSTANT_Interfaceref_info, structure at the given index.intgetMemberNameAndType(int index)Reads thename_and_type_indexfield of theCONSTANT_Fieldref_info,CONSTANT_Methodref_info, orCONSTANT_Interfaceref_info, structure at the given index.intgetMethodHandleIndex(int index)Reads thereference_indexfield of theCONSTANT_MethodHandle_infostructure at the given index.intgetMethodHandleKind(int index)Reads thereference_kindfield of theCONSTANT_MethodHandle_infostructure at the given index.intgetMethodrefClass(int index)Reads theclass_indexfield of theCONSTANT_Methodref_infostructure at the given index.StringgetMethodrefClassName(int index)Reads theclass_indexfield of theCONSTANT_Methodref_infostructure at the given index.StringgetMethodrefName(int index)Reads thename_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.intgetMethodrefNameAndType(int index)Reads thename_and_type_indexfield of theCONSTANT_Methodref_infostructure at the given index.StringgetMethodrefType(int index)Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.intgetMethodTypeInfo(int index)Reads thedescriptor_indexfield of theCONSTANT_MethodType_infostructure at the given index.StringgetModuleInfo(int index)Reads thename_indexfield of theCONSTANT_Module_infostructure at the given index.intgetNameAndTypeDescriptor(int index)Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure at the given index.intgetNameAndTypeName(int index)Reads thename_indexfield of theCONSTANT_NameAndType_infostructure at the given index.StringgetPackageInfo(int index)Reads thename_indexfield of theCONSTANT_Package_infostructure at the given index.intgetSize()Returns the number of entries in this table.StringgetStringInfo(int index)ReadsCONSTANT_String_infostructure at the given index.intgetTag(int index)Returns thetagfield of the constant pool table entry at the given index.intgetThisClassInfo()Returns the index ofCONSTANT_Class_infostructure specifying the class using this constant pool table.StringgetUtf8Info(int index)ReadsCONSTANT_utf8_infostructure at the given index.intisConstructor(String classname, int index)Determines whetherCONSTANT_Methodref_infostructure at the given index represents the constructor of the given class.intisMember(String classname, String membername, int index)Determines whetherCONSTANT_Methodref_info,CONSTANT_Fieldref_info, orCONSTANT_InterfaceMethodref_infostructure at the given index represents the member with the specified name and declaring class.voidprint()Prints the contents of the constant pool table.voidprint(PrintWriter out)Prints the contents of the constant pool table.voidrenameClass(String oldName, String newName)Replaces all occurrences of a class name.voidrenameClass(Map<String,String> classnames)Replaces all occurrences of class names.voidwrite(DataOutputStream out)Writes the contents of the constant pool table.
-
-
-
Field Detail
-
CONST_Class
public static final int CONST_Class
CONSTANT_Class- See Also:
- Constant Field Values
-
CONST_Fieldref
public static final int CONST_Fieldref
CONSTANT_Fieldref- See Also:
- Constant Field Values
-
CONST_Methodref
public static final int CONST_Methodref
CONSTANT_Methodref- See Also:
- Constant Field Values
-
CONST_InterfaceMethodref
public static final int CONST_InterfaceMethodref
CONSTANT_InterfaceMethodref- See Also:
- Constant Field Values
-
CONST_String
public static final int CONST_String
CONSTANT_String- See Also:
- Constant Field Values
-
CONST_Integer
public static final int CONST_Integer
CONSTANT_Integer- See Also:
- Constant Field Values
-
CONST_Float
public static final int CONST_Float
CONSTANT_Float- See Also:
- Constant Field Values
-
CONST_Long
public static final int CONST_Long
CONSTANT_Long- See Also:
- Constant Field Values
-
CONST_Double
public static final int CONST_Double
CONSTANT_Double- See Also:
- Constant Field Values
-
CONST_NameAndType
public static final int CONST_NameAndType
CONSTANT_NameAndType- See Also:
- Constant Field Values
-
CONST_Utf8
public static final int CONST_Utf8
CONSTANT_Utf8- See Also:
- Constant Field Values
-
CONST_MethodHandle
public static final int CONST_MethodHandle
CONSTANT_MethodHandle- See Also:
- Constant Field Values
-
CONST_MethodType
public static final int CONST_MethodType
CONSTANT_MethodHandle- See Also:
- Constant Field Values
-
CONST_Dynamic
public static final int CONST_Dynamic
CONSTANT_Dynamic- See Also:
- Constant Field Values
-
CONST_DynamicCallSite
public static final int CONST_DynamicCallSite
CONSTANT_DynamicCallSite, also known asCONSTANT_InvokeDynamic- See Also:
- Constant Field Values
-
CONST_InvokeDynamic
public static final int CONST_InvokeDynamic
- See Also:
- Constant Field Values
-
CONST_Module
public static final int CONST_Module
CONSTANT_Module- See Also:
- Constant Field Values
-
CONST_Package
public static final int CONST_Package
CONSTANT_Package- See Also:
- Constant Field Values
-
THIS
public static final CtClass THIS
Represents the class using this constant pool table.
-
REF_getField
public static final int REF_getField
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_getStatic
public static final int REF_getStatic
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_putField
public static final int REF_putField
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_putStatic
public static final int REF_putStatic
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_invokeVirtual
public static final int REF_invokeVirtual
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_invokeStatic
public static final int REF_invokeStatic
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_invokeSpecial
public static final int REF_invokeSpecial
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_newInvokeSpecial
public static final int REF_newInvokeSpecial
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
REF_invokeInterface
public static final int REF_invokeInterface
reference_kindofCONSTANT_MethodHandle_info.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConstPool
public ConstPool(String thisclass)
Constructs a constant pool table.- Parameters:
thisclass- the name of the class using this constant pool table
-
ConstPool
public ConstPool(DataInputStream in) throws IOException
Constructs a constant pool table from the given byte stream.- Parameters:
in- byte stream.- Throws:
IOException
-
-
Method Detail
-
getSize
public int getSize()
Returns the number of entries in this table.
-
getClassName
public String getClassName()
Returns the name of the class using this constant pool table.
-
getThisClassInfo
public int getThisClassInfo()
Returns the index ofCONSTANT_Class_infostructure specifying the class using this constant pool table.
-
getTag
public int getTag(int index)
Returns thetagfield of the constant pool table entry at the given index.- Returns:
- either
CONST_Class,CONST_Fieldref,CONST_Methodref, or ...
-
getClassInfo
public String getClassInfo(int index)
ReadsCONSTANT_Class_infostructure at the given index.- 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). - See Also:
ClassPool.getCtClass(String)
-
getClassInfoByDescriptor
public String getClassInfoByDescriptor(int index)
ReadsCONSTANT_Class_infostructure at the given index.- Returns:
- the descriptor of the type specified
by
name_index. - Since:
- 3.15
- See Also:
ClassPool.getCtClass(String)
-
getNameAndTypeName
public int getNameAndTypeName(int index)
Reads thename_indexfield of theCONSTANT_NameAndType_infostructure at the given index.
-
getNameAndTypeDescriptor
public int getNameAndTypeDescriptor(int index)
Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure at the given index.
-
getMemberClass
public int getMemberClass(int index)
Reads theclass_indexfield of theCONSTANT_Fieldref_info,CONSTANT_Methodref_info, orCONSTANT_Interfaceref_info, structure at the given index.- Since:
- 3.6
-
getMemberNameAndType
public int getMemberNameAndType(int index)
Reads thename_and_type_indexfield of theCONSTANT_Fieldref_info,CONSTANT_Methodref_info, orCONSTANT_Interfaceref_info, structure at the given index.- Since:
- 3.6
-
getFieldrefClass
public int getFieldrefClass(int index)
Reads theclass_indexfield of theCONSTANT_Fieldref_infostructure at the given index.
-
getFieldrefClassName
public String getFieldrefClassName(int index)
Reads theclass_indexfield of theCONSTANT_Fieldref_infostructure at the given index.- Returns:
- the name of the class at that
class_index.
-
getFieldrefNameAndType
public int getFieldrefNameAndType(int index)
Reads thename_and_type_indexfield of theCONSTANT_Fieldref_infostructure at the given index.
-
getFieldrefName
public String getFieldrefName(int index)
Reads thename_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_Fieldref_info.- Returns:
- the name of the field.
-
getFieldrefType
public String getFieldrefType(int index)
Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_Fieldref_info.- Returns:
- the type descriptor of the field.
-
getMethodrefClass
public int getMethodrefClass(int index)
Reads theclass_indexfield of theCONSTANT_Methodref_infostructure at the given index.
-
getMethodrefClassName
public String getMethodrefClassName(int index)
Reads theclass_indexfield of theCONSTANT_Methodref_infostructure at the given index.- Returns:
- the name of the class at that
class_index.
-
getMethodrefNameAndType
public int getMethodrefNameAndType(int index)
Reads thename_and_type_indexfield of theCONSTANT_Methodref_infostructure at the given index.
-
getMethodrefName
public String getMethodrefName(int index)
Reads thename_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_Methodref_info.- Returns:
- the name of the method.
-
getMethodrefType
public String getMethodrefType(int index)
Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_Methodref_info.- Returns:
- the descriptor of the method.
-
getInterfaceMethodrefClass
public int getInterfaceMethodrefClass(int index)
Reads theclass_indexfield of theCONSTANT_InterfaceMethodref_infostructure at the given index.
-
getInterfaceMethodrefClassName
public String getInterfaceMethodrefClassName(int index)
Reads theclass_indexfield of theCONSTANT_InterfaceMethodref_infostructure at the given index.- Returns:
- the name of the class at that
class_index.
-
getInterfaceMethodrefNameAndType
public int getInterfaceMethodrefNameAndType(int index)
Reads thename_and_type_indexfield of theCONSTANT_InterfaceMethodref_infostructure at the given index.
-
getInterfaceMethodrefName
public String getInterfaceMethodrefName(int index)
Reads thename_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_InterfaceMethodref_info.- Returns:
- the name of the method.
-
getInterfaceMethodrefType
public String getInterfaceMethodrefType(int index)
Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_InterfaceMethodref_info.- Returns:
- the descriptor of the method.
-
getLdcValue
public Object getLdcValue(int index)
ReadsCONSTANT_Integer_info,_Float_info,_Long_info,_Double_info, or_String_infostructure. These are used with the LDC instruction.- Returns:
- a
Stringvalue or a wrapped primitive-type value.
-
getIntegerInfo
public int getIntegerInfo(int index)
ReadsCONSTANT_Integer_infostructure at the given index.- Returns:
- the value specified by this entry.
-
getFloatInfo
public float getFloatInfo(int index)
ReadsCONSTANT_Float_infostructure at the given index.- Returns:
- the value specified by this entry.
-
getLongInfo
public long getLongInfo(int index)
ReadsCONSTANT_Long_infostructure at the given index.- Returns:
- the value specified by this entry.
-
getDoubleInfo
public double getDoubleInfo(int index)
ReadsCONSTANT_Double_infostructure at the given index.- Returns:
- the value specified by this entry.
-
getStringInfo
public String getStringInfo(int index)
ReadsCONSTANT_String_infostructure at the given index.- Returns:
- the string specified by
string_index.
-
getUtf8Info
public String getUtf8Info(int index)
ReadsCONSTANT_utf8_infostructure at the given index.- Returns:
- the string specified by this entry.
-
getMethodHandleKind
public int getMethodHandleKind(int index)
Reads thereference_kindfield of theCONSTANT_MethodHandle_infostructure at the given index.- Since:
- 3.17
- See Also:
REF_getField,REF_getStatic,REF_invokeInterface,REF_invokeSpecial,REF_invokeStatic,REF_invokeVirtual,REF_newInvokeSpecial,REF_putField,REF_putStatic
-
getMethodHandleIndex
public int getMethodHandleIndex(int index)
Reads thereference_indexfield of theCONSTANT_MethodHandle_infostructure at the given index.- Since:
- 3.17
-
getMethodTypeInfo
public int getMethodTypeInfo(int index)
Reads thedescriptor_indexfield of theCONSTANT_MethodType_infostructure at the given index.- Since:
- 3.17
-
getInvokeDynamicBootstrap
public int getInvokeDynamicBootstrap(int index)
Reads thebootstrap_method_attr_indexfield of theCONSTANT_InvokeDynamic_infostructure at the given index.- Since:
- 3.17
-
getInvokeDynamicNameAndType
public int getInvokeDynamicNameAndType(int index)
Reads thename_and_type_indexfield of theCONSTANT_InvokeDynamic_infostructure at the given index.- Since:
- 3.17
-
getInvokeDynamicType
public String getInvokeDynamicType(int index)
Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_InvokeDynamic_info.- Returns:
- the descriptor of the bootstrap method.
- Since:
- 3.17
-
getDynamicBootstrap
public int getDynamicBootstrap(int index)
Reads thebootstrap_method_attr_indexfield of theCONSTANT_Dynamic_infostructure at the given index.- Since:
- 3.26
-
getDynamicNameAndType
public int getDynamicNameAndType(int index)
Reads thename_and_type_indexfield of theCONSTANT_Dynamic_infostructure at the given index.- Since:
- 3.26
-
getDynamicType
public String getDynamicType(int index)
Reads thedescriptor_indexfield of theCONSTANT_NameAndType_infostructure indirectly specified by the given index.- Parameters:
index- an index to aCONSTANT_Dynamic_info.- Returns:
- the descriptor of the bootstrap method.
- Since:
- 3.26
-
getModuleInfo
public String getModuleInfo(int index)
Reads thename_indexfield of theCONSTANT_Module_infostructure at the given index.- Returns:
- the module name at
name_index. - Since:
- 3.22
-
getPackageInfo
public String getPackageInfo(int index)
Reads thename_indexfield of theCONSTANT_Package_infostructure at the given index.- Returns:
- the package name at
name_index. It is a slash- separated name such as com/oracle/net. - Since:
- 3.22
-
isConstructor
public int isConstructor(String classname, int index)
Determines whetherCONSTANT_Methodref_infostructure at the given index represents the constructor of the given class.- Returns:
- the
descriptor_indexspecifying the type descriptor of the that constructor. If it is not that constructor,isConstructor()returns 0.
-
isMember
public int isMember(String classname, String membername, int index)
Determines whetherCONSTANT_Methodref_info,CONSTANT_Fieldref_info, orCONSTANT_InterfaceMethodref_infostructure at the given index represents the member with the specified name and declaring class.- Parameters:
classname- the class declaring the membermembername- the member nameindex- the index into the constant pool table- Returns:
- the
descriptor_indexspecifying the type descriptor of that member. If it is not that member,isMember()returns 0.
-
eqMember
public String eqMember(String membername, String desc, int index)
Determines whetherCONSTANT_Methodref_info,CONSTANT_Fieldref_info, orCONSTANT_InterfaceMethodref_infostructure at the given index has the name and the descriptor given as the arguments.- Parameters:
membername- the member namedesc- the descriptor of the member.index- the index into the constant pool table- Returns:
- the name of the target class specified by
the
..._infostructure atindex. Otherwise, null if that structure does not match the given member name and descriptor.
-
copy
public int copy(int n, ConstPool dest, Map<String,String> classnames)Copies the n-th item in this ConstPool object into the destination ConstPool object. The class names that the item refers to are renamed according to the given map.- Parameters:
n- the n-th itemdest- destination constant pool tableclassnames- the map or null.- Returns:
- the index of the copied item into the destination ClassPool.
-
addClassInfo
public int addClassInfo(CtClass c)
Adds a newCONSTANT_Class_infostructure.This also adds a
CONSTANT_Utf8_infostructure for storing the class name.- Returns:
- the index of the added entry.
-
addClassInfo
public int addClassInfo(String qname)
Adds a newCONSTANT_Class_infostructure.This also adds a
CONSTANT_Utf8_infostructure for storing the class name.- Parameters:
qname- a fully-qualified class name (or the JVM-internal representation of that name).- Returns:
- the index of the added entry.
-
addNameAndTypeInfo
public int addNameAndTypeInfo(String name, String type)
Adds a newCONSTANT_NameAndType_infostructure.This also adds
CONSTANT_Utf8_infostructures.- Parameters:
name-name_indextype-descriptor_index- Returns:
- the index of the added entry.
-
addNameAndTypeInfo
public int addNameAndTypeInfo(int name, int type)Adds a newCONSTANT_NameAndType_infostructure.- Parameters:
name-name_indextype-descriptor_index- Returns:
- the index of the added entry.
-
addFieldrefInfo
public int addFieldrefInfo(int classInfo, String name, String type)Adds a newCONSTANT_Fieldref_infostructure.This also adds a new
CONSTANT_NameAndType_infostructure.- Parameters:
classInfo-class_indexname-name_indexofCONSTANT_NameAndType_info.type-descriptor_indexofCONSTANT_NameAndType_info.- Returns:
- the index of the added entry.
-
addFieldrefInfo
public int addFieldrefInfo(int classInfo, int nameAndTypeInfo)Adds a newCONSTANT_Fieldref_infostructure.- Parameters:
classInfo-class_indexnameAndTypeInfo-name_and_type_index.- Returns:
- the index of the added entry.
-
addMethodrefInfo
public int addMethodrefInfo(int classInfo, String name, String type)Adds a newCONSTANT_Methodref_infostructure.This also adds a new
CONSTANT_NameAndType_infostructure.- Parameters:
classInfo-class_indexname-name_indexofCONSTANT_NameAndType_info.type-descriptor_indexofCONSTANT_NameAndType_info.- Returns:
- the index of the added entry.
-
addMethodrefInfo
public int addMethodrefInfo(int classInfo, int nameAndTypeInfo)Adds a newCONSTANT_Methodref_infostructure.- Parameters:
classInfo-class_indexnameAndTypeInfo-name_and_type_index.- Returns:
- the index of the added entry.
-
addInterfaceMethodrefInfo
public int addInterfaceMethodrefInfo(int classInfo, String name, String type)Adds a newCONSTANT_InterfaceMethodref_infostructure.This also adds a new
CONSTANT_NameAndType_infostructure.- Parameters:
classInfo-class_indexname-name_indexofCONSTANT_NameAndType_info.type-descriptor_indexofCONSTANT_NameAndType_info.- Returns:
- the index of the added entry.
-
addInterfaceMethodrefInfo
public int addInterfaceMethodrefInfo(int classInfo, int nameAndTypeInfo)Adds a newCONSTANT_InterfaceMethodref_infostructure.- Parameters:
classInfo-class_indexnameAndTypeInfo-name_and_type_index.- Returns:
- the index of the added entry.
-
addStringInfo
public int addStringInfo(String str)
Adds a newCONSTANT_String_infostructure.This also adds a new
CONSTANT_Utf8_infostructure.- Returns:
- the index of the added entry.
-
addIntegerInfo
public int addIntegerInfo(int i)
Adds a newCONSTANT_Integer_infostructure.- Returns:
- the index of the added entry.
-
addFloatInfo
public int addFloatInfo(float f)
Adds a newCONSTANT_Float_infostructure.- Returns:
- the index of the added entry.
-
addLongInfo
public int addLongInfo(long l)
Adds a newCONSTANT_Long_infostructure.- Returns:
- the index of the added entry.
-
addDoubleInfo
public int addDoubleInfo(double d)
Adds a newCONSTANT_Double_infostructure.- Returns:
- the index of the added entry.
-
addUtf8Info
public int addUtf8Info(String utf8)
Adds a newCONSTANT_Utf8_infostructure.- Returns:
- the index of the added entry.
-
addMethodHandleInfo
public int addMethodHandleInfo(int kind, int index)Adds a newCONSTANT_MethodHandle_infostructure.- Parameters:
kind-reference_kindsuch as.REF_invokeStaticindex-reference_index.- Returns:
- the index of the added entry.
- Since:
- 3.17
-
addMethodTypeInfo
public int addMethodTypeInfo(int desc)
Adds a newCONSTANT_MethodType_infostructure.- Parameters:
desc-descriptor_index.- Returns:
- the index of the added entry.
- Since:
- 3.17
-
addInvokeDynamicInfo
public int addInvokeDynamicInfo(int bootstrap, int nameAndType)Adds a newCONSTANT_InvokeDynamic_infostructure.- Parameters:
bootstrap-bootstrap_method_attr_index.nameAndType-name_and_type_index.- Returns:
- the index of the added entry.
- Since:
- 3.17
-
addDynamicInfo
public int addDynamicInfo(int bootstrap, int nameAndType)Adds a newCONSTANT_Dynamic_infostructure.- Parameters:
bootstrap-bootstrap_method_attr_index.nameAndType-name_and_type_index.- Returns:
- the index of the added entry.
- Since:
- 3.26
-
addModuleInfo
public int addModuleInfo(int nameIndex)
Adds a newCONSTANT_Module_info- Parameters:
nameIndex- the index of the Utf8 entry.- Returns:
- the index of the added entry.
- Since:
- 3.22
-
addPackageInfo
public int addPackageInfo(int nameIndex)
Adds a newCONSTANT_Package_info- Parameters:
nameIndex- the index of the Utf8 entry.- Returns:
- the index of the added entry.
- Since:
- 3.22
-
getClassNames
public Set<String> getClassNames()
Get all the class names.- Returns:
- a set of class names (
Stringobjects).
-
renameClass
public void renameClass(String oldName, String newName)
Replaces all occurrences of a class name.- Parameters:
oldName- the replaced name (JVM-internal representation).newName- the substituted name (JVM-internal representation).
-
renameClass
public void renameClass(Map<String,String> classnames)
Replaces all occurrences of class names.- Parameters:
classnames- specifies pairs of replaced and substituted name.
-
write
public void write(DataOutputStream out) throws IOException
Writes the contents of the constant pool table.- Throws:
IOException
-
print
public void print()
Prints the contents of the constant pool table.
-
print
public void print(PrintWriter out)
Prints the contents of the constant pool table.
-
-