Package org.objectweb.asm
Class SymbolTable
java.lang.Object
org.objectweb.asm.SymbolTable
The constant pool entries, the BootstrapMethods attribute entries and the (ASM specific) type
table entries of a class.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classAn entry of a SymbolTable.private static final classA label corresponding to a "forward uninitialized" type in the ASM specifictypeTable(seeSymbol.FORWARD_UNINITIALIZED_TYPE_TAG). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe number of bootstrap methods inbootstrapMethods.private ByteVectorThe content of the BootstrapMethods attribute 'bootstrap_methods' array corresponding to this SymbolTable.private StringThe internal name of the class to which this symbol table belongs.(package private) final ClassWriterThe ClassWriter to which this SymbolTable belongs.private ByteVectorThe content of the ClassFile's constant_pool JVMS structure corresponding to this SymbolTable.private intThe number of constant pool items inconstantPool, plus 1.private SymbolTable.Entry[]A hash set of all the entries in this SymbolTable (this includes the constant pool entries, the bootstrap method entries and the type table entries).private intThe total number ofSymbolTable.Entryinstances inentries.private intThe actual number ofSymbolTable.LabelEntryinlabelTable.private SymbolTable.LabelEntry[]A hash set of all theSymbolTable.LabelEntryelements in thelabelTable.private SymbolTable.LabelEntry[]The labels corresponding to the "forward uninitialized" types in the ASM specifictypeTable(seeSymbol.FORWARD_UNINITIALIZED_TYPE_TAG).private intThe major version number of the class to which this symbol table belongs.private final ClassReaderThe ClassReader from which this SymbolTable was constructed, or null if it was constructed from scratch.private intThe actual number of elements intypeTable.private SymbolTable.Entry[]An ASM specific type table used to temporarily store internal names that will not necessarily be stored in the constant pool. -
Constructor Summary
ConstructorsConstructorDescriptionSymbolTable(ClassWriter classWriter) Constructs a new, empty SymbolTable for the given ClassWriter.SymbolTable(ClassWriter classWriter, ClassReader classReader) Constructs a new SymbolTable for the given ClassWriter, initialized with the constant pool and bootstrap methods of the given ClassReader. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadd(SymbolTable.Entry entry) Adds the given entry in theentrieshash set.private SymboladdBootstrapMethod(int offset, int length, int hashCode) Adds a bootstrap method to the BootstrapMethods attribute of this symbol table.(package private) SymboladdBootstrapMethod(Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) Adds a bootstrap method to the BootstrapMethods attribute of this symbol table.(package private) SymboladdConstant(Object value) Adds a number or string constant to the constant pool of this symbol table.(package private) SymboladdConstantClass(String value) Adds a CONSTANT_Class_info to the constant pool of this symbol table.(package private) SymboladdConstantDouble(double value) Adds a CONSTANT_Double_info to the constant pool of this symbol table.(package private) SymboladdConstantDynamic(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) Adds a CONSTANT_Dynamic_info to the constant pool of this symbol table.private voidaddConstantDynamicOrInvokeDynamicReference(int tag, int index, String name, String descriptor, int bootstrapMethodIndex) Adds a new CONSTANT_Dynamic_info or CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.private SymboladdConstantDynamicOrInvokeDynamicReference(int tag, String name, String descriptor, int bootstrapMethodIndex) Adds a CONSTANT_Dynamic or a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.(package private) SymboladdConstantFieldref(String owner, String name, String descriptor) Adds a CONSTANT_Fieldref_info to the constant pool of this symbol table.(package private) SymboladdConstantFloat(float value) Adds a CONSTANT_Float_info to the constant pool of this symbol table.(package private) SymboladdConstantInteger(int value) Adds a CONSTANT_Integer_info to the constant pool of this symbol table.private SymboladdConstantIntegerOrFloat(int tag, int value) Adds a CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol table.private voidaddConstantIntegerOrFloat(int index, int tag, int value) Adds a new CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol table.(package private) SymboladdConstantInvokeDynamic(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) Adds a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.(package private) SymboladdConstantLong(long value) Adds a CONSTANT_Long_info to the constant pool of this symbol table.private voidaddConstantLongOrDouble(int index, int tag, long value) Adds a new CONSTANT_Long_info or CONSTANT_Double_info to the constant pool of this symbol table.private SymboladdConstantLongOrDouble(int tag, long value) Adds a CONSTANT_Long_info or CONSTANT_Double_info to the constant pool of this symbol table.private voidaddConstantMemberReference(int index, int tag, String owner, String name, String descriptor) Adds a new CONSTANT_Fieldref_info, CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.private SymbolTable.EntryaddConstantMemberReference(int tag, String owner, String name, String descriptor) Adds a CONSTANT_Fieldref_info, CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.private voidaddConstantMethodHandle(int index, int referenceKind, String owner, String name, String descriptor) Adds a new CONSTANT_MethodHandle_info to the constant pool of this symbol table.(package private) SymboladdConstantMethodHandle(int referenceKind, String owner, String name, String descriptor, boolean isInterface) Adds a CONSTANT_MethodHandle_info to the constant pool of this symbol table.(package private) SymboladdConstantMethodref(String owner, String name, String descriptor, boolean isInterface) Adds a CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.(package private) SymboladdConstantMethodType(String methodDescriptor) Adds a CONSTANT_MethodType_info to the constant pool of this symbol table.(package private) SymboladdConstantModule(String moduleName) Adds a CONSTANT_Module_info to the constant pool of this symbol table.private voidaddConstantNameAndType(int index, String name, String descriptor) Adds a new CONSTANT_NameAndType_info to the constant pool of this symbol table.(package private) intaddConstantNameAndType(String name, String descriptor) Adds a CONSTANT_NameAndType_info to the constant pool of this symbol table.(package private) SymboladdConstantPackage(String packageName) Adds a CONSTANT_Package_info to the constant pool of this symbol table.(package private) SymboladdConstantString(String value) Adds a CONSTANT_String_info to the constant pool of this symbol table.private voidaddConstantUtf8(int index, String value) Adds a new CONSTANT_String_info to the constant pool of this symbol table.(package private) intaddConstantUtf8(String value) Adds a CONSTANT_Utf8_info to the constant pool of this symbol table.private voidaddConstantUtf8Reference(int index, int tag, String value) Adds a new CONSTANT_Class_info, CONSTANT_String_info, CONSTANT_MethodType_info, CONSTANT_Module_info or CONSTANT_Package_info to the constant pool of this symbol table.private SymboladdConstantUtf8Reference(int tag, String value) Adds a CONSTANT_Class_info, CONSTANT_String_info, CONSTANT_MethodType_info, CONSTANT_Module_info or CONSTANT_Package_info to the constant pool of this symbol table.(package private) intaddForwardUninitializedType(String value, Label label) Adds a "forward uninitialized" type in the type table of this symbol table.(package private) intaddMergedType(int typeTableIndex1, int typeTableIndex2) Adds a merged type in the type table of this symbol table.(package private) intAdds a type in the type table of this symbol table.private intaddTypeInternal(SymbolTable.Entry entry) Adds the given type Symbol totypeTable.(package private) intaddUninitializedType(String value, int bytecodeOffset) Adds an uninitialized type in the type table of this symbol table.(package private) intReturns the size in bytes of this symbol table's BootstrapMethods attribute.private voidcopyBootstrapMethods(ClassReader classReader, char[] charBuffer) Read the BootstrapMethods 'bootstrap_methods' array binary content and add them as entries of the SymbolTable.private SymbolTable.Entryget(int hashCode) Returns the list of entries which can potentially have the given hash code.(package private) StringReturns the internal name of the class to which this symbol table belongs.(package private) intReturns the number of items in this symbol table's constant_pool array (plus 1).(package private) intReturns the length in bytes of this symbol table's constant_pool array.(package private) LabelgetForwardUninitializedLabel(int typeIndex) Returns the label corresponding to the "forward uninitialized" type table element whose index is given.(package private) intReturns the major version of the class to which this symbol table belongs.private SymbolTable.LabelEntrygetOrAddLabelEntry(Label label) Returns theSymbolTable.LabelEntrycorresponding to the given label.(package private) ClassReaderReturns the ClassReader from which this SymbolTable was constructed.(package private) SymbolgetType(int typeIndex) Returns the type table element whose index is given.private static inthash(int tag, int value) private static inthash(int tag, long value) private static intprivate static intprivate static intprivate static intprivate static intprivate static intprivate SymbolTable.Entryput(SymbolTable.Entry entry) Puts the given entry in theentrieshash set.(package private) voidputBootstrapMethods(ByteVector output) Puts this symbol table's BootstrapMethods attribute in the given ByteVector.(package private) voidputConstantPool(ByteVector output) Puts this symbol table's constant_pool array in the given ByteVector, preceded by the constant_pool_count value.(package private) intsetMajorVersionAndClassName(int majorVersion, String className) Sets the major version and the name of the class to which this symbol table belongs.
-
Field Details
-
classWriter
The ClassWriter to which this SymbolTable belongs. This is only used to get access toClassWriter.getCommonSuperClass(java.lang.String, java.lang.String)and to serialize custom attributes withAttribute.write(org.objectweb.asm.ClassWriter, byte[], int, int, int). -
sourceClassReader
The ClassReader from which this SymbolTable was constructed, or null if it was constructed from scratch. -
majorVersion
private int majorVersionThe major version number of the class to which this symbol table belongs. -
className
The internal name of the class to which this symbol table belongs. -
entryCount
private int entryCountThe total number ofSymbolTable.Entryinstances inentries. This includes entries that are accessible (recursively) viaSymbolTable.Entry.next. -
entries
A hash set of all the entries in this SymbolTable (this includes the constant pool entries, the bootstrap method entries and the type table entries). EachSymbolTable.Entryinstance is stored at the array index given by its hash code modulo the array size. If several entries must be stored at the same array index, they are linked together via theirSymbolTable.Entry.nextfield. The factory methods of this class make sure that this table does not contain duplicated entries. -
constantPoolCount
private int constantPoolCountThe number of constant pool items inconstantPool, plus 1. The first constant pool item has index 1, and long and double items count for two items. -
constantPool
The content of the ClassFile's constant_pool JVMS structure corresponding to this SymbolTable. The ClassFile's constant_pool_count field is not included. -
bootstrapMethodCount
private int bootstrapMethodCountThe number of bootstrap methods inbootstrapMethods. Corresponds to the BootstrapMethods_attribute's num_bootstrap_methods field value. -
bootstrapMethods
The content of the BootstrapMethods attribute 'bootstrap_methods' array corresponding to this SymbolTable. Note that the first 6 bytes of the BootstrapMethods_attribute, and its num_bootstrap_methods field, are not included. -
typeCount
private int typeCountThe actual number of elements intypeTable. These elements are stored from index 0 to typeCount (excluded). The other array entries are empty. -
typeTable
An ASM specific type table used to temporarily store internal names that will not necessarily be stored in the constant pool. This type table is used by the control flow and data flow analysis algorithm used to compute stack map frames from scratch. This array storesSymbol.TYPE_TAG,Symbol.UNINITIALIZED_TYPE_TAG,Symbol.FORWARD_UNINITIALIZED_TYPE_TAGandSymbol.MERGED_TYPE_TAGentries. The type symbol at indexihas itsSymbol.indexequal toi(and vice versa). -
labelCount
private int labelCountThe actual number ofSymbolTable.LabelEntryinlabelTable. These elements are stored from index 0 to labelCount (excluded). The other array entries are empty. These label entries are also stored in thelabelEntrieshash set. -
labelTable
The labels corresponding to the "forward uninitialized" types in the ASM specifictypeTable(seeSymbol.FORWARD_UNINITIALIZED_TYPE_TAG). The label entry at indexihas itsSymbolTable.LabelEntry.indexequal toi(and vice versa). -
labelEntries
A hash set of all theSymbolTable.LabelEntryelements in thelabelTable. EachSymbolTable.LabelEntryinstance is stored at the array index given by its hash code modulo the array size. If several entries must be stored at the same array index, they are linked together via theirSymbolTable.LabelEntry.nextfield. ThegetOrAddLabelEntry(Label)method ensures that this table does not contain duplicated entries.
-
-
Constructor Details
-
SymbolTable
SymbolTable(ClassWriter classWriter) Constructs a new, empty SymbolTable for the given ClassWriter.- Parameters:
classWriter- a ClassWriter.
-
SymbolTable
SymbolTable(ClassWriter classWriter, ClassReader classReader) Constructs a new SymbolTable for the given ClassWriter, initialized with the constant pool and bootstrap methods of the given ClassReader.- Parameters:
classWriter- a ClassWriter.classReader- the ClassReader whose constant pool and bootstrap methods must be copied to initialize the SymbolTable.
-
-
Method Details
-
copyBootstrapMethods
Read the BootstrapMethods 'bootstrap_methods' array binary content and add them as entries of the SymbolTable.- Parameters:
classReader- the ClassReader whose bootstrap methods must be copied to initialize the SymbolTable.charBuffer- a buffer used to read strings in the constant pool.
-
getSource
ClassReader getSource()Returns the ClassReader from which this SymbolTable was constructed.- Returns:
- the ClassReader from which this SymbolTable was constructed, or null if it was constructed from scratch.
-
getMajorVersion
int getMajorVersion()Returns the major version of the class to which this symbol table belongs.- Returns:
- the major version of the class to which this symbol table belongs.
-
getClassName
String getClassName()Returns the internal name of the class to which this symbol table belongs.- Returns:
- the internal name of the class to which this symbol table belongs.
-
setMajorVersionAndClassName
Sets the major version and the name of the class to which this symbol table belongs. Also adds the class name to the constant pool.- Parameters:
majorVersion- a major ClassFile version number.className- an internal class name.- Returns:
- the constant pool index of a new or already existing Symbol with the given class name.
-
getConstantPoolCount
int getConstantPoolCount()Returns the number of items in this symbol table's constant_pool array (plus 1).- Returns:
- the number of items in this symbol table's constant_pool array (plus 1).
-
getConstantPoolLength
int getConstantPoolLength()Returns the length in bytes of this symbol table's constant_pool array.- Returns:
- the length in bytes of this symbol table's constant_pool array.
-
putConstantPool
Puts this symbol table's constant_pool array in the given ByteVector, preceded by the constant_pool_count value.- Parameters:
output- where the JVMS ClassFile's constant_pool array must be put.
-
computeBootstrapMethodsSize
int computeBootstrapMethodsSize()Returns the size in bytes of this symbol table's BootstrapMethods attribute. Also adds the attribute name in the constant pool.- Returns:
- the size in bytes of this symbol table's BootstrapMethods attribute.
-
putBootstrapMethods
Puts this symbol table's BootstrapMethods attribute in the given ByteVector. This includes the 6 attribute header bytes and the num_bootstrap_methods value.- Parameters:
output- where the JVMS BootstrapMethods attribute must be put.
-
get
Returns the list of entries which can potentially have the given hash code.- Parameters:
hashCode- aSymbolTable.Entry.hashCodevalue.- Returns:
- the list of entries which can potentially have the given hash code. The list is stored
via the
SymbolTable.Entry.nextfield.
-
put
Puts the given entry in theentrieshash set. This method does not check whetherentriesalready contains a similar entry or not.entriesis resized if necessary to avoid hash collisions (multiple entries needing to be stored at the sameentriesarray index) as much as possible, with reasonable memory usage.- Parameters:
entry- an Entry (which must not already be contained inentries).- Returns:
- the given entry
-
add
Adds the given entry in theentrieshash set. This method does not check whetherentriesalready contains a similar entry or not, and does not resizeentriesif necessary.- Parameters:
entry- an Entry (which must not already be contained inentries).
-
addConstant
Adds a number or string constant to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item. -
addConstantClass
Adds a CONSTANT_Class_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
value- the internal name of a class.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantFieldref
Adds a CONSTANT_Fieldref_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
owner- the internal name of a class.name- a field name.descriptor- a field descriptor.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantMethodref
Adds a CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
owner- the internal name of a class.name- a method name.descriptor- a method descriptor.isInterface- whether owner is an interface or not.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantMemberReference
private SymbolTable.Entry addConstantMemberReference(int tag, String owner, String name, String descriptor) Adds a CONSTANT_Fieldref_info, CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
tag- one ofSymbol.CONSTANT_FIELDREF_TAG,Symbol.CONSTANT_METHODREF_TAGorSymbol.CONSTANT_INTERFACE_METHODREF_TAG.owner- the internal name of a class.name- a field or method name.descriptor- a field or method descriptor.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantMemberReference
private void addConstantMemberReference(int index, int tag, String owner, String name, String descriptor) Adds a new CONSTANT_Fieldref_info, CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.- Parameters:
index- the constant pool index of the new Symbol.tag- one ofSymbol.CONSTANT_FIELDREF_TAG,Symbol.CONSTANT_METHODREF_TAGorSymbol.CONSTANT_INTERFACE_METHODREF_TAG.owner- the internal name of a class.name- a field or method name.descriptor- a field or method descriptor.
-
addConstantString
Adds a CONSTANT_String_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
value- a string.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantInteger
Adds a CONSTANT_Integer_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
value- an int.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantFloat
Adds a CONSTANT_Float_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
value- a float.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantIntegerOrFloat
Adds a CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
tag- one ofSymbol.CONSTANT_INTEGER_TAGorSymbol.CONSTANT_FLOAT_TAG.value- an int or float.- Returns:
- a constant pool constant with the given tag and primitive values.
-
addConstantIntegerOrFloat
private void addConstantIntegerOrFloat(int index, int tag, int value) Adds a new CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol table.- Parameters:
index- the constant pool index of the new Symbol.tag- one ofSymbol.CONSTANT_INTEGER_TAGorSymbol.CONSTANT_FLOAT_TAG.value- an int or float.
-
addConstantLong
Adds a CONSTANT_Long_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
value- a long.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantDouble
Adds a CONSTANT_Double_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
value- a double.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantLongOrDouble
Adds a CONSTANT_Long_info or CONSTANT_Double_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
tag- one ofSymbol.CONSTANT_LONG_TAGorSymbol.CONSTANT_DOUBLE_TAG.value- a long or double.- Returns:
- a constant pool constant with the given tag and primitive values.
-
addConstantLongOrDouble
private void addConstantLongOrDouble(int index, int tag, long value) Adds a new CONSTANT_Long_info or CONSTANT_Double_info to the constant pool of this symbol table.- Parameters:
index- the constant pool index of the new Symbol.tag- one ofSymbol.CONSTANT_LONG_TAGorSymbol.CONSTANT_DOUBLE_TAG.value- a long or double.
-
addConstantNameAndType
Adds a CONSTANT_NameAndType_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
name- a field or method name.descriptor- a field or method descriptor.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantNameAndType
Adds a new CONSTANT_NameAndType_info to the constant pool of this symbol table.- Parameters:
index- the constant pool index of the new Symbol.name- a field or method name.descriptor- a field or method descriptor.
-
addConstantUtf8
Adds a CONSTANT_Utf8_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
value- a string.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantUtf8
Adds a new CONSTANT_String_info to the constant pool of this symbol table.- Parameters:
index- the constant pool index of the new Symbol.value- a string.
-
addConstantMethodHandle
Symbol addConstantMethodHandle(int referenceKind, String owner, String name, String descriptor, boolean isInterface) Adds a CONSTANT_MethodHandle_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
referenceKind- one ofOpcodes.H_GETFIELD,Opcodes.H_GETSTATIC,Opcodes.H_PUTFIELD,Opcodes.H_PUTSTATIC,Opcodes.H_INVOKEVIRTUAL,Opcodes.H_INVOKESTATIC,Opcodes.H_INVOKESPECIAL,Opcodes.H_NEWINVOKESPECIALorOpcodes.H_INVOKEINTERFACE.owner- the internal name of a class of interface.name- a field or method name.descriptor- a field or method descriptor.isInterface- whether owner is an interface or not.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantMethodHandle
private void addConstantMethodHandle(int index, int referenceKind, String owner, String name, String descriptor) Adds a new CONSTANT_MethodHandle_info to the constant pool of this symbol table.- Parameters:
index- the constant pool index of the new Symbol.referenceKind- one ofOpcodes.H_GETFIELD,Opcodes.H_GETSTATIC,Opcodes.H_PUTFIELD,Opcodes.H_PUTSTATIC,Opcodes.H_INVOKEVIRTUAL,Opcodes.H_INVOKESTATIC,Opcodes.H_INVOKESPECIAL,Opcodes.H_NEWINVOKESPECIALorOpcodes.H_INVOKEINTERFACE.owner- the internal name of a class of interface.name- a field or method name.descriptor- a field or method descriptor.
-
addConstantMethodType
Adds a CONSTANT_MethodType_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
methodDescriptor- a method descriptor.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantDynamic
Symbol addConstantDynamic(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) Adds a CONSTANT_Dynamic_info to the constant pool of this symbol table. Also adds the related bootstrap method to the BootstrapMethods of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
name- a method name.descriptor- a field descriptor.bootstrapMethodHandle- a bootstrap method handle.bootstrapMethodArguments- the bootstrap method arguments.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantInvokeDynamic
Symbol addConstantInvokeDynamic(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) Adds a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table. Also adds the related bootstrap method to the BootstrapMethods of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
name- a method name.descriptor- a method descriptor.bootstrapMethodHandle- a bootstrap method handle.bootstrapMethodArguments- the bootstrap method arguments.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantDynamicOrInvokeDynamicReference
private Symbol addConstantDynamicOrInvokeDynamicReference(int tag, String name, String descriptor, int bootstrapMethodIndex) Adds a CONSTANT_Dynamic or a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
tag- one ofSymbol.CONSTANT_DYNAMIC_TAGorSymbol.CONSTANT_INVOKE_DYNAMIC_TAG.name- a method name.descriptor- a field descriptor for CONSTANT_DYNAMIC_TAG) or a method descriptor for CONSTANT_INVOKE_DYNAMIC_TAG.bootstrapMethodIndex- the index of a bootstrap method in the BootstrapMethods attribute.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantDynamicOrInvokeDynamicReference
private void addConstantDynamicOrInvokeDynamicReference(int tag, int index, String name, String descriptor, int bootstrapMethodIndex) Adds a new CONSTANT_Dynamic_info or CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.- Parameters:
tag- one ofSymbol.CONSTANT_DYNAMIC_TAGorSymbol.CONSTANT_INVOKE_DYNAMIC_TAG.index- the constant pool index of the new Symbol.name- a method name.descriptor- a field descriptor for CONSTANT_DYNAMIC_TAG or a method descriptor for CONSTANT_INVOKE_DYNAMIC_TAG.bootstrapMethodIndex- the index of a bootstrap method in the BootstrapMethods attribute.
-
addConstantModule
Adds a CONSTANT_Module_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
moduleName- a fully qualified name (using dots) of a module.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantPackage
Adds a CONSTANT_Package_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
packageName- the internal name of a package.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantUtf8Reference
Adds a CONSTANT_Class_info, CONSTANT_String_info, CONSTANT_MethodType_info, CONSTANT_Module_info or CONSTANT_Package_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item.- Parameters:
tag- one ofSymbol.CONSTANT_CLASS_TAG,Symbol.CONSTANT_STRING_TAG,Symbol.CONSTANT_METHOD_TYPE_TAG,Symbol.CONSTANT_MODULE_TAGorSymbol.CONSTANT_PACKAGE_TAG.value- an internal class name, an arbitrary string, a method descriptor, a module or a package name, depending on tag.- Returns:
- a new or already existing Symbol with the given value.
-
addConstantUtf8Reference
Adds a new CONSTANT_Class_info, CONSTANT_String_info, CONSTANT_MethodType_info, CONSTANT_Module_info or CONSTANT_Package_info to the constant pool of this symbol table.- Parameters:
index- the constant pool index of the new Symbol.tag- one ofSymbol.CONSTANT_CLASS_TAG,Symbol.CONSTANT_STRING_TAG,Symbol.CONSTANT_METHOD_TYPE_TAG,Symbol.CONSTANT_MODULE_TAGorSymbol.CONSTANT_PACKAGE_TAG.value- an internal class name, an arbitrary string, a method descriptor, a module or a package name, depending on tag.
-
addBootstrapMethod
Adds a bootstrap method to the BootstrapMethods attribute of this symbol table. Does nothing if the BootstrapMethods already contains a similar bootstrap method.- Parameters:
bootstrapMethodHandle- a bootstrap method handle.bootstrapMethodArguments- the bootstrap method arguments.- Returns:
- a new or already existing Symbol with the given value.
-
addBootstrapMethod
Adds a bootstrap method to the BootstrapMethods attribute of this symbol table. Does nothing if the BootstrapMethods already contains a similar bootstrap method (more precisely, reverts the content ofbootstrapMethodsto remove the last, duplicate bootstrap method).- Parameters:
offset- the offset of the last bootstrap method inbootstrapMethods, in bytes.length- the length of this bootstrap method inbootstrapMethods, in bytes.hashCode- the hash code of this bootstrap method.- Returns:
- a new or already existing Symbol with the given value.
-
getType
Returns the type table element whose index is given.- Parameters:
typeIndex- a type table index.- Returns:
- the type table element whose index is given.
-
getForwardUninitializedLabel
Returns the label corresponding to the "forward uninitialized" type table element whose index is given.- Parameters:
typeIndex- the type table index of a "forward uninitialized" type table element.- Returns:
- the label corresponding of the NEW instruction which created this "forward uninitialized" type.
-
addType
Adds a type in the type table of this symbol table. Does nothing if the type table already contains a similar type.- Parameters:
value- an internal class name.- Returns:
- the index of a new or already existing type Symbol with the given value.
-
addUninitializedType
Adds an uninitialized type in the type table of this symbol table. Does nothing if the type table already contains a similar type.- Parameters:
value- an internal class name.bytecodeOffset- the bytecode offset of the NEW instruction that created this uninitialized type value.- Returns:
- the index of a new or already existing type #@link Symbol} with the given value.
-
addForwardUninitializedType
Adds a "forward uninitialized" type in the type table of this symbol table. Does nothing if the type table already contains a similar type.- Parameters:
value- an internal class name.label- the label of the NEW instruction that created this uninitialized type value. If the label is resolved, use theaddUninitializedType(java.lang.String, int)method instead.- Returns:
- the index of a new or already existing type
Symbolwith the given value.
-
addMergedType
int addMergedType(int typeTableIndex1, int typeTableIndex2) Adds a merged type in the type table of this symbol table. Does nothing if the type table already contains a similar type.- Parameters:
typeTableIndex1- aSymbol.TYPE_TAGtype, specified by its index in the type table.typeTableIndex2- anotherSymbol.TYPE_TAGtype, specified by its index in the type table.- Returns:
- the index of a new or already existing
Symbol.TYPE_TAGtype Symbol, corresponding to the common super class of the given types.
-
addTypeInternal
Adds the given type Symbol totypeTable.- Parameters:
entry- aSymbol.TYPE_TAGorSymbol.UNINITIALIZED_TYPE_TAGtype symbol. The index of this Symbol must be equal to the current value oftypeCount.- Returns:
- the index in
typeTablewhere the given type was added, which is also equal to entry's index by hypothesis.
-
getOrAddLabelEntry
Returns theSymbolTable.LabelEntrycorresponding to the given label. Creates a new one if there is no such entry.- Parameters:
label- theLabelof a NEW instruction which created an uninitialized type, in the case where this NEW instruction is after the <init> constructor call (in bytecode offset order). SeeSymbol.FORWARD_UNINITIALIZED_TYPE_TAG.- Returns:
- the
SymbolTable.LabelEntrycorresponding tolabel.
-
hash
private static int hash(int tag, int value) -
hash
private static int hash(int tag, long value) -
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-