Package org.datanucleus.enhancer.asm
Class SymbolTable
- java.lang.Object
-
- org.datanucleus.enhancer.asm.SymbolTable
-
final class SymbolTable extends java.lang.Object
The constant pool entries, the BootstrapMethods attribute entries and the (ASM specific) type table entries of a class.- See Also:
- JVMS 4.4, JVMS 4.7.23
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SymbolTable.Entry
An entry of a SymbolTable.
-
Field Summary
Fields Modifier and Type Field Description private int
bootstrapMethodCount
The number of bootstrap methods inbootstrapMethods
.private ByteVector
bootstrapMethods
The content of the BootstrapMethods attribute 'bootstrap_methods' array corresponding to this SymbolTable.private java.lang.String
className
The internal name of the class to which this symbol table belongs.(package private) ClassWriter
classWriter
The ClassWriter to which this SymbolTable belongs.private ByteVector
constantPool
The content of the ClassFile's constant_pool JVMS structure corresponding to this SymbolTable.private int
constantPoolCount
The number of constant pool items inconstantPool
, plus 1.private SymbolTable.Entry[]
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).private int
entryCount
The total number ofSymbolTable.Entry
instances inentries
.private int
majorVersion
The major version number of the class to which this symbol table belongs.private ClassReader
sourceClassReader
The ClassReader from which this SymbolTable was constructed, or null if it was constructed from scratch.private int
typeCount
The actual number of elements intypeTable
.private SymbolTable.Entry[]
typeTable
An ASM specific type table used to temporarily store internal names that will not necessarily be stored in the constant pool.
-
Constructor Summary
Constructors Constructor Description SymbolTable(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
add(SymbolTable.Entry entry)
Adds the given entry in theentries
hash set.private Symbol
addBootstrapMethod(int offset, int length, int hashCode)
Adds a bootstrap method to the BootstrapMethods attribute of this symbol table.(package private) Symbol
addBootstrapMethod(Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
Adds a bootstrap method to the BootstrapMethods attribute of this symbol table.(package private) Symbol
addConstant(java.lang.Object value)
Adds a number or string constant to the constant pool of this symbol table.(package private) Symbol
addConstantClass(java.lang.String value)
Adds a CONSTANT_Class_info to the constant pool of this symbol table.(package private) Symbol
addConstantDouble(double value)
Adds a CONSTANT_Double_info to the constant pool of this symbol table.(package private) Symbol
addConstantDynamic(java.lang.String name, java.lang.String descriptor, Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
Adds a CONSTANT_Dynamic_info to the constant pool of this symbol table.private void
addConstantDynamicOrInvokeDynamicReference(int tag, int index, java.lang.String name, java.lang.String descriptor, int bootstrapMethodIndex)
Adds a new CONSTANT_Dynamic_info or CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.private Symbol
addConstantDynamicOrInvokeDynamicReference(int tag, java.lang.String name, java.lang.String descriptor, int bootstrapMethodIndex)
Adds a CONSTANT_Dynamic or a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.(package private) Symbol
addConstantFieldref(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Adds a CONSTANT_Fieldref_info to the constant pool of this symbol table.(package private) Symbol
addConstantFloat(float value)
Adds a CONSTANT_Float_info to the constant pool of this symbol table.(package private) Symbol
addConstantInteger(int value)
Adds a CONSTANT_Integer_info to the constant pool of this symbol table.private Symbol
addConstantIntegerOrFloat(int tag, int value)
Adds a CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol table.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.(package private) Symbol
addConstantInvokeDynamic(java.lang.String name, java.lang.String descriptor, Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
Adds a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.(package private) Symbol
addConstantLong(long value)
Adds a CONSTANT_Long_info to the constant pool of this symbol table.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.private Symbol
addConstantLongOrDouble(int tag, long value)
Adds a CONSTANT_Long_info or CONSTANT_Double_info to the constant pool of this symbol table.private void
addConstantMemberReference(int index, int tag, java.lang.String owner, java.lang.String name, java.lang.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.Entry
addConstantMemberReference(int tag, java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Adds a CONSTANT_Fieldref_info, CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.private void
addConstantMethodHandle(int index, int referenceKind, java.lang.String owner, java.lang.String name, java.lang.String descriptor)
Adds a new CONSTANT_MethodHandle_info to the constant pool of this symbol table.(package private) Symbol
addConstantMethodHandle(int referenceKind, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Adds a CONSTANT_MethodHandle_info to the constant pool of this symbol table.(package private) Symbol
addConstantMethodref(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
Adds a CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.(package private) Symbol
addConstantMethodType(java.lang.String methodDescriptor)
Adds a CONSTANT_MethodType_info to the constant pool of this symbol table.(package private) Symbol
addConstantModule(java.lang.String moduleName)
Adds a CONSTANT_Module_info to the constant pool of this symbol table.private void
addConstantNameAndType(int index, java.lang.String name, java.lang.String descriptor)
Adds a new CONSTANT_NameAndType_info to the constant pool of this symbol table.(package private) int
addConstantNameAndType(java.lang.String name, java.lang.String descriptor)
Adds a CONSTANT_NameAndType_info to the constant pool of this symbol table.(package private) Symbol
addConstantPackage(java.lang.String packageName)
Adds a CONSTANT_Package_info to the constant pool of this symbol table.(package private) Symbol
addConstantString(java.lang.String value)
Adds a CONSTANT_String_info to the constant pool of this symbol table.private void
addConstantUtf8(int index, java.lang.String value)
Adds a new CONSTANT_String_info to the constant pool of this symbol table.(package private) int
addConstantUtf8(java.lang.String value)
Adds a CONSTANT_Utf8_info to the constant pool of this symbol table.private void
addConstantUtf8Reference(int index, int tag, java.lang.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 Symbol
addConstantUtf8Reference(int tag, java.lang.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) int
addMergedType(int typeTableIndex1, int typeTableIndex2)
Adds a merged type in the type table of this symbol table.(package private) int
addType(java.lang.String value)
Adds a type in the type table of this symbol table.private int
addTypeInternal(SymbolTable.Entry entry)
Adds the given type Symbol totypeTable
.(package private) int
addUninitializedType(java.lang.String value, int bytecodeOffset)
Adds anFrame.ITEM_UNINITIALIZED
type in the type table of this symbol table.(package private) int
computeBootstrapMethodsSize()
Returns the size in bytes of this symbol table's BootstrapMethods attribute.private void
copyBootstrapMethods(ClassReader classReader, char[] charBuffer)
Read the BootstrapMethods 'bootstrap_methods' array binary content and add them as entries of the SymbolTable.private SymbolTable.Entry
get(int hashCode)
Returns the list of entries which can potentially have the given hash code.(package private) java.lang.String
getClassName()
Returns the internal name of the class to which this symbol table belongs.(package private) int
getConstantPoolCount()
Returns the number of items in this symbol table's constant_pool array (plus 1).(package private) int
getConstantPoolLength()
Returns the length in bytes of this symbol table's constant_pool array.(package private) int
getMajorVersion()
Returns the major version of the class to which this symbol table belongs.(package private) ClassReader
getSource()
Returns the ClassReader from which this SymbolTable was constructed.(package private) Symbol
getType(int typeIndex)
Returns the type table element whose index is given.private static int
hash(int tag, int value)
private static int
hash(int tag, long value)
private static int
hash(int tag, java.lang.String value)
private static int
hash(int tag, java.lang.String value1, int value2)
private static int
hash(int tag, java.lang.String value1, java.lang.String value2)
private static int
hash(int tag, java.lang.String value1, java.lang.String value2, int value3)
private static int
hash(int tag, java.lang.String value1, java.lang.String value2, java.lang.String value3)
private static int
hash(int tag, java.lang.String value1, java.lang.String value2, java.lang.String value3, int value4)
private SymbolTable.Entry
put(SymbolTable.Entry entry)
Puts the given entry in theentries
hash set.(package private) void
putBootstrapMethods(ByteVector output)
Puts this symbol table's BootstrapMethods attribute in the given ByteVector.(package private) void
putConstantPool(ByteVector output)
Puts this symbol table's constant_pool array in the given ByteVector, preceded by the constant_pool_count value.(package private) int
setMajorVersionAndClassName(int majorVersion, java.lang.String className)
Sets the major version and the name of the class to which this symbol table belongs.
-
-
-
Field Detail
-
classWriter
final ClassWriter 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.datanucleus.enhancer.asm.ClassWriter, byte[], int, int, int)
.
-
sourceClassReader
private final ClassReader sourceClassReader
The ClassReader from which this SymbolTable was constructed, or null if it was constructed from scratch.
-
majorVersion
private int majorVersion
The major version number of the class to which this symbol table belongs.
-
className
private java.lang.String className
The internal name of the class to which this symbol table belongs.
-
entryCount
private int entryCount
The total number ofSymbolTable.Entry
instances inentries
. This includes entries that are accessible (recursively) viaSymbolTable.Entry.next
.
-
entries
private SymbolTable.Entry[] 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.Entry
instance 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.next
field. The factory methods of this class make sure that this table does not contain duplicated entries.
-
constantPoolCount
private int constantPoolCount
The 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
private ByteVector 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 bootstrapMethodCount
The number of bootstrap methods inbootstrapMethods
. Corresponds to the BootstrapMethods_attribute's num_bootstrap_methods field value.
-
bootstrapMethods
private ByteVector 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 typeCount
The actual number of elements intypeTable
. These elements are stored from index 0 to typeCount (excluded). The other array entries are empty.
-
typeTable
private SymbolTable.Entry[] 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
andSymbol.UNINITIALIZED_TYPE_TAG
) Symbol. The type symbol at indexi
has itsSymbol.index
equal toi
(and vice versa).
-
-
Constructor Detail
-
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 Detail
-
copyBootstrapMethods
private void copyBootstrapMethods(ClassReader classReader, char[] charBuffer)
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
java.lang.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
int setMajorVersionAndClassName(int majorVersion, java.lang.String className)
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
void putConstantPool(ByteVector output)
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
void putBootstrapMethods(ByteVector output)
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
private SymbolTable.Entry get(int hashCode)
Returns the list of entries which can potentially have the given hash code.- Parameters:
hashCode
- aSymbolTable.Entry.hashCode
value.- Returns:
- the list of entries which can potentially have the given hash code. The list is stored
via the
SymbolTable.Entry.next
field.
-
put
private SymbolTable.Entry put(SymbolTable.Entry entry)
Puts the given entry in theentries
hash set. This method does not check whetherentries
already contains a similar entry or not.entries
is resized if necessary to avoid hash collisions (multiple entries needing to be stored at the sameentries
array 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
private void add(SymbolTable.Entry entry)
Adds the given entry in theentries
hash set. This method does not check whetherentries
already contains a similar entry or not, and does not resizeentries
if necessary.- Parameters:
entry
- an Entry (which must not already be contained inentries
).
-
addConstant
Symbol addConstant(java.lang.Object value)
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
Symbol addConstantClass(java.lang.String value)
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
Symbol addConstantFieldref(java.lang.String owner, java.lang.String name, java.lang.String descriptor)
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
Symbol addConstantMethodref(java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)
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, java.lang.String owner, java.lang.String name, java.lang.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_TAG
orSymbol.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, java.lang.String owner, java.lang.String name, java.lang.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_TAG
orSymbol.CONSTANT_INTERFACE_METHODREF_TAG
.owner
- the internal name of a class.name
- a field or method name.descriptor
- a field or method descriptor.
-
addConstantString
Symbol addConstantString(java.lang.String value)
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
Symbol addConstantInteger(int value)
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
Symbol addConstantFloat(float value)
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
private Symbol addConstantIntegerOrFloat(int tag, int value)
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_TAG
orSymbol.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_TAG
orSymbol.CONSTANT_FLOAT_TAG
.value
- an int or float.
-
addConstantLong
Symbol addConstantLong(long value)
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
Symbol addConstantDouble(double value)
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
private Symbol addConstantLongOrDouble(int tag, long value)
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_TAG
orSymbol.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_TAG
orSymbol.CONSTANT_DOUBLE_TAG
.value
- a long or double.
-
addConstantNameAndType
int addConstantNameAndType(java.lang.String name, java.lang.String descriptor)
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
private void addConstantNameAndType(int index, java.lang.String name, java.lang.String descriptor)
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
int addConstantUtf8(java.lang.String value)
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
private void addConstantUtf8(int index, java.lang.String value)
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, java.lang.String owner, java.lang.String name, java.lang.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_NEWINVOKESPECIAL
orOpcodes.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, java.lang.String owner, java.lang.String name, java.lang.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_NEWINVOKESPECIAL
orOpcodes.H_INVOKEINTERFACE
.owner
- the internal name of a class of interface.name
- a field or method name.descriptor
- a field or method descriptor.
-
addConstantMethodType
Symbol addConstantMethodType(java.lang.String methodDescriptor)
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(java.lang.String name, java.lang.String descriptor, Handle bootstrapMethodHandle, java.lang.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(java.lang.String name, java.lang.String descriptor, Handle bootstrapMethodHandle, java.lang.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, java.lang.String name, java.lang.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_TAG
orSymbol.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, java.lang.String name, java.lang.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_TAG
orSymbol.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
Symbol addConstantModule(java.lang.String moduleName)
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
Symbol addConstantPackage(java.lang.String packageName)
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
private Symbol addConstantUtf8Reference(int tag, java.lang.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. 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_TAG
orSymbol.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
private void addConstantUtf8Reference(int index, int tag, java.lang.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.- 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_TAG
orSymbol.CONSTANT_PACKAGE_TAG
.value
- an internal class name, an arbitrary string, a method descriptor, a module or a package name, depending on tag.
-
addBootstrapMethod
Symbol addBootstrapMethod(Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
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
private Symbol addBootstrapMethod(int offset, int length, int hashCode)
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 ofbootstrapMethods
to 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
Symbol getType(int typeIndex)
Returns the type table element whose index is given.- Parameters:
typeIndex
- a type table index.- Returns:
- the type table element whose index is given.
-
addType
int addType(java.lang.String value)
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
int addUninitializedType(java.lang.String value, int bytecodeOffset)
Adds anFrame.ITEM_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 thisFrame.ITEM_UNINITIALIZED
type value.- Returns:
- the index of a new or already existing type Symbol with 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_TAG
type, specified by its index in the type table.typeTableIndex2
- anotherSymbol.TYPE_TAG
type, specified by its index in the type table.- Returns:
- the index of a new or already existing
Symbol.TYPE_TAG
type Symbol, corresponding to the common super class of the given types.
-
addTypeInternal
private int addTypeInternal(SymbolTable.Entry entry)
Adds the given type Symbol totypeTable
.- Parameters:
entry
- aSymbol.TYPE_TAG
orSymbol.UNINITIALIZED_TYPE_TAG
type symbol. The index of this Symbol must be equal to the current value oftypeCount
.- Returns:
- the index in
typeTable
where the given type was added, which is also equal to entry's index by hypothesis.
-
hash
private static int hash(int tag, int value)
-
hash
private static int hash(int tag, long value)
-
hash
private static int hash(int tag, java.lang.String value)
-
hash
private static int hash(int tag, java.lang.String value1, int value2)
-
hash
private static int hash(int tag, java.lang.String value1, java.lang.String value2)
-
hash
private static int hash(int tag, java.lang.String value1, java.lang.String value2, int value3)
-
hash
private static int hash(int tag, java.lang.String value1, java.lang.String value2, java.lang.String value3)
-
hash
private static int hash(int tag, java.lang.String value1, java.lang.String value2, java.lang.String value3, int value4)
-
-