Class SymbolTable

java.lang.Object
org.datanucleus.enhancer.asm.SymbolTable

final class SymbolTable extends Object
The constant pool entries, the BootstrapMethods attribute entries and the (ASM specific) type table entries of a class.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    An entry of a SymbolTable.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    The number of bootstrap methods in bootstrapMethods.
    private ByteVector
    The content of the BootstrapMethods attribute 'bootstrap_methods' array corresponding to this SymbolTable.
    private String
    The internal name of the class to which this symbol table belongs.
    (package private) final ClassWriter
    The ClassWriter to which this SymbolTable belongs.
    private ByteVector
    The content of the ClassFile's constant_pool JVMS structure corresponding to this SymbolTable.
    private int
    The number of constant pool items in constantPool, plus 1.
    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
    The total number of SymbolTable.Entry instances in entries.
    private int
    The major version number of the class to which this symbol table belongs.
    private final ClassReader
    The ClassReader from which this SymbolTable was constructed, or null if it was constructed from scratch.
    private int
    The actual number of elements in 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

    Modifier and Type
    Method
    Description
    private void
    Adds the given entry in the entries 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, Object... bootstrapMethodArguments)
    Adds a bootstrap method to the BootstrapMethods attribute of this symbol table.
    (package private) Symbol
    Adds a number or string constant to the constant pool of this symbol table.
    (package private) Symbol
    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(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)
    Adds a CONSTANT_Dynamic_info to the constant pool of this symbol table.
    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.
    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.
    (package private) Symbol
    addConstantFieldref(String owner, String name, 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(String name, String descriptor, Handle bootstrapMethodHandle, 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, 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.
    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.
    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.
    (package private) 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.
    (package private) Symbol
    addConstantMethodref(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) Symbol
    addConstantMethodType(String methodDescriptor)
    Adds a CONSTANT_MethodType_info to the constant pool of this symbol table.
    (package private) Symbol
    Adds a CONSTANT_Module_info to the constant pool of this symbol table.
    private void
    addConstantNameAndType(int index, String name, String descriptor)
    Adds a new CONSTANT_NameAndType_info to the constant pool of this symbol table.
    (package private) int
    Adds a CONSTANT_NameAndType_info to the constant pool of this symbol table.
    (package private) Symbol
    Adds a CONSTANT_Package_info to the constant pool of this symbol table.
    (package private) Symbol
    Adds a CONSTANT_String_info to the constant pool of this symbol table.
    private void
    addConstantUtf8(int index, String value)
    Adds a new CONSTANT_String_info to the constant pool of this symbol table.
    (package private) int
    Adds a CONSTANT_Utf8_info to the constant pool of this symbol table.
    private void
    addConstantUtf8Reference(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 Symbol
    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(String value)
    Adds a type in the type table of this symbol table.
    private int
    Adds the given type Symbol to typeTable.
    (package private) int
    addUninitializedType(String value, int bytecodeOffset)
    Adds an Frame.ITEM_UNINITIALIZED type in the type table of this symbol table.
    (package private) int
    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.
    get(int hashCode)
    Returns the list of entries which can potentially have the given hash code.
    (package private) String
    Returns the internal name of the class to which this symbol table belongs.
    (package private) int
    Returns the number of items in this symbol table's constant_pool array (plus 1).
    (package private) int
    Returns the length in bytes of this symbol table's constant_pool array.
    (package private) int
    Returns the major version of the class to which this symbol table belongs.
    (package private) ClassReader
    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, String value)
     
    private static int
    hash(int tag, String value1, int value2)
     
    private static int
    hash(int tag, String value1, String value2)
     
    private static int
    hash(int tag, String value1, String value2, int value3)
     
    private static int
    hash(int tag, String value1, String value2, String value3)
     
    private static int
    hash(int tag, String value1, String value2, String value3, int value4)
     
    Puts the given entry in the entries hash set.
    (package private) void
    Puts this symbol table's BootstrapMethods attribute in the given ByteVector.
    (package private) void
    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, String className)
    Sets the major version and the name of the class to which this symbol table belongs.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • classWriter

      final ClassWriter classWriter
      The ClassWriter to which this SymbolTable belongs. This is only used to get access to ClassWriter.getCommonSuperClass(java.lang.String, java.lang.String) and to serialize custom attributes with Attribute.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 String className
      The internal name of the class to which this symbol table belongs.
    • entryCount

      private int entryCount
      The total number of SymbolTable.Entry instances in entries. This includes entries that are accessible (recursively) via SymbolTable.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). Each SymbolTable.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 their SymbolTable.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 in constantPool, 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 in bootstrapMethods. 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 in typeTable. 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 stores Symbol.TYPE_TAG and Symbol.UNINITIALIZED_TYPE_TAG) Symbol. The type symbol at index i has its Symbol.index equal to i (and vice versa).
  • 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

      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

      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, 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 - a SymbolTable.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 the entries hash set. This method does not check whether entries already contains a similar entry or not. entries is resized if necessary to avoid hash collisions (multiple entries needing to be stored at the same entries array index) as much as possible, with reasonable memory usage.
      Parameters:
      entry - an Entry (which must not already be contained in entries).
      Returns:
      the given entry
    • add

      private void add(SymbolTable.Entry entry)
      Adds the given entry in the entries hash set. This method does not check whether entries already contains a similar entry or not, and does not resize entries if necessary.
      Parameters:
      entry - an Entry (which must not already be contained in entries).
    • addConstant

      Symbol addConstant(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.
      Parameters:
      value - the value of the constant to be added to the constant pool. This parameter must be an Integer, Byte, Character, Short, Boolean, Float, Long, Double, String, Type or Handle.
      Returns:
      a new or already existing Symbol with the given value.
    • addConstantClass

      Symbol addConstantClass(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(String owner, String name, 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(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. 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 of Symbol.CONSTANT_FIELDREF_TAG, Symbol.CONSTANT_METHODREF_TAG or Symbol.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 of Symbol.CONSTANT_FIELDREF_TAG, Symbol.CONSTANT_METHODREF_TAG or Symbol.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(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 of Symbol.CONSTANT_INTEGER_TAG or Symbol.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 of Symbol.CONSTANT_INTEGER_TAG or Symbol.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 of Symbol.CONSTANT_LONG_TAG or Symbol.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 of Symbol.CONSTANT_LONG_TAG or Symbol.CONSTANT_DOUBLE_TAG.
      value - a long or double.
    • addConstantNameAndType

      int addConstantNameAndType(String name, 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, String name, 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(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, 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, 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 of Opcodes.H_GETFIELD, Opcodes.H_GETSTATIC, Opcodes.H_PUTFIELD, Opcodes.H_PUTSTATIC, Opcodes.H_INVOKEVIRTUAL, Opcodes.H_INVOKESTATIC, Opcodes.H_INVOKESPECIAL, Opcodes.H_NEWINVOKESPECIAL or Opcodes.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 of Opcodes.H_GETFIELD, Opcodes.H_GETSTATIC, Opcodes.H_PUTFIELD, Opcodes.H_PUTSTATIC, Opcodes.H_INVOKEVIRTUAL, Opcodes.H_INVOKESTATIC, Opcodes.H_INVOKESPECIAL, Opcodes.H_NEWINVOKESPECIAL or Opcodes.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(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(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 of Symbol.CONSTANT_DYNAMIC_TAG or Symbol.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 of Symbol.CONSTANT_DYNAMIC_TAG or Symbol.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(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(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, 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 of Symbol.CONSTANT_CLASS_TAG, Symbol.CONSTANT_STRING_TAG, Symbol.CONSTANT_METHOD_TYPE_TAG, Symbol.CONSTANT_MODULE_TAG or Symbol.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, 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 of Symbol.CONSTANT_CLASS_TAG, Symbol.CONSTANT_STRING_TAG, Symbol.CONSTANT_METHOD_TYPE_TAG, Symbol.CONSTANT_MODULE_TAG or Symbol.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, 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 of bootstrapMethods to remove the last, duplicate bootstrap method).
      Parameters:
      offset - the offset of the last bootstrap method in bootstrapMethods, in bytes.
      length - the length of this bootstrap method in bootstrapMethods, 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(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(String value, int bytecodeOffset)
      Adds an Frame.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 this Frame.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 - a Symbol.TYPE_TAG type, specified by its index in the type table.
      typeTableIndex2 - another Symbol.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 to typeTable.
      Parameters:
      entry - a Symbol.TYPE_TAG or Symbol.UNINITIALIZED_TYPE_TAG type symbol. The index of this Symbol must be equal to the current value of typeCount.
      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, String value)
    • hash

      private static int hash(int tag, String value1, int value2)
    • hash

      private static int hash(int tag, String value1, String value2)
    • hash

      private static int hash(int tag, String value1, String value2, int value3)
    • hash

      private static int hash(int tag, String value1, String value2, String value3)
    • hash

      private static int hash(int tag, String value1, String value2, String value3, int value4)