Top Description Inners Fields Constructors Methods
org.objectweb.asm

pack-priv final Class SymbolTable

extends Object
Class Inheritance

The constant pool entries, the BootstrapMethods attribute entries and the (ASM specific) type table entries of a class.
Author
Eric Bruneton
See Also
JVMS 4.4, JVMS 4.7.23

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SymbolTable.Entry

An entry of a SymbolTable.

private static class
SymbolTable.LabelEntry

A label corresponding to a "forward uninitialized" type in the ASM specific SymbolTable#typeTable (see Symbol#FORWARD_UNINITIALIZED_TYPE_TAG).

Field Summary

Modifier and TypeField and Description
private int
bootstrapMethodCount

The number of bootstrap methods in bootstrapMethods.

private ByteVector
bootstrapMethods

The content of the BootstrapMethods attribute 'bootstrap_methods' array corresponding to this SymbolTable.

private String
className

The internal name of the class to which this symbol table belongs.

pack-priv final 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 in constantPool, 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 of Entry instances in entries.

private int
labelCount

The actual number of LabelEntry in labelTable.

private SymbolTable.LabelEntry[]
labelEntries

A hash set of all the LabelEntry elements in the labelTable.

private SymbolTable.LabelEntry[]
labelTable

The labels corresponding to the "forward uninitialized" types in the ASM specific typeTable (see Symbol#FORWARD_UNINITIALIZED_TYPE_TAG).

private int
majorVersion

The major version number of the class to which this symbol table belongs.

private final 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 in 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.

Constructor Summary

AccessConstructor and Description
pack-priv
SymbolTable(final ClassWriter
a ClassWriter.
classWriter
)

Constructs a new, empty SymbolTable for the given ClassWriter.

pack-priv
SymbolTable(final ClassWriter
a ClassWriter.
classWriter
,
final ClassReader
the ClassReader whose constant pool and bootstrap methods must be copied to initialize the SymbolTable.
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 TypeMethod and Description
private void
add(final SymbolTable.Entry
an Entry (which must not already be contained in entries).
entry
)

Adds the given entry in the entries hash set.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addBootstrapMethod
(final Handle
a bootstrap method handle.
bootstrapMethodHandle
,
final Object...
the bootstrap method arguments.
bootstrapMethodArguments
)

Adds a bootstrap method to the BootstrapMethods attribute of this symbol table.

private Symbol

Returns:

a new or already existing Symbol with the given value.
addBootstrapMethod
(final int
the offset of the last bootstrap method in bootstrapMethods, in bytes.
offset
,
final int
the length of this bootstrap method in bootstrapMethods, in bytes.
length
,
final int
the hash code of this bootstrap method.
hashCode
)

Adds a bootstrap method to the BootstrapMethods attribute of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstant
(final Object
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.
value
)

Adds a number or string constant to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantClass
(final String
the internal name of a class.
value
)

Adds a CONSTANT_Class_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantDouble
(final double
a double.
value
)

Adds a CONSTANT_Double_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantDynamic
(final String
a method name.
name
,
final String
a field descriptor.
descriptor
,
final Handle
a bootstrap method handle.
bootstrapMethodHandle
,
final Object...
the bootstrap method arguments.
bootstrapMethodArguments
)

Adds a CONSTANT_Dynamic_info to the constant pool of this symbol table.

private Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantDynamicOrInvokeDynamicReference
(final int tag, final String
a method name.
name
,
final String
a field descriptor for CONSTANT_DYNAMIC_TAG) or a method descriptor for CONSTANT_INVOKE_DYNAMIC_TAG.
descriptor
,
final int
the index of a bootstrap method in the BootstrapMethods attribute.
bootstrapMethodIndex
)

Adds a CONSTANT_Dynamic or a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.

private void
addConstantDynamicOrInvokeDynamicReference(final int tag, final int
the constant pool index of the new Symbol.
index
,
final String
a method name.
name
,
final String
a field descriptor for CONSTANT_DYNAMIC_TAG or a method descriptor for CONSTANT_INVOKE_DYNAMIC_TAG.
descriptor
,
final int
the index of a bootstrap method in the BootstrapMethods attribute.
bootstrapMethodIndex
)

Adds a new CONSTANT_Dynamic_info or CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantFieldref
(final String
the internal name of a class.
owner
,
final String
a field name.
name
,
final String
a field descriptor.
descriptor
)

Adds a CONSTANT_Fieldref_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantFloat
(final float
a float.
value
)

Adds a CONSTANT_Float_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantInteger
(final int
an int.
value
)

Adds a CONSTANT_Integer_info to the constant pool of this symbol table.

private Symbol

Returns:

a constant pool constant with the given tag and primitive values.
addConstantIntegerOrFloat
(final int tag, final int
an int or float.
value
)

Adds a CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol table.

private void
addConstantIntegerOrFloat(final int
the constant pool index of the new Symbol.
index
,
final int tag, final int
an int or float.
value
)

Adds a new CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantInvokeDynamic
(final String
a method name.
name
,
final String
a method descriptor.
descriptor
,
final Handle
a bootstrap method handle.
bootstrapMethodHandle
,
final Object...
the bootstrap method arguments.
bootstrapMethodArguments
)

Adds a CONSTANT_InvokeDynamic_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantLong
(final long
a long.
value
)

Adds a CONSTANT_Long_info to the constant pool of this symbol table.

private Symbol

Returns:

a constant pool constant with the given tag and primitive values.
addConstantLongOrDouble
(final int tag, final long
a long or double.
value
)

Adds a CONSTANT_Long_info or CONSTANT_Double_info to the constant pool of this symbol table.

private void
addConstantLongOrDouble(final int
the constant pool index of the new Symbol.
index
,
final int tag, final long
a long or double.
value
)

Adds a new CONSTANT_Long_info or CONSTANT_Double_info to the constant pool of this symbol table.

private SymbolTable.Entry

Returns:

a new or already existing Symbol with the given value.
addConstantMemberReference
(final int tag, final String
the internal name of a class.
owner
,
final String
a field or method name.
name
,
final String
a field or method descriptor.
descriptor
)

Adds a CONSTANT_Fieldref_info, CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.

private void
addConstantMemberReference(final int
the constant pool index of the new Symbol.
index
,
final int tag, final String
the internal name of a class.
owner
,
final String
a field or method name.
name
,
final String
a field or method descriptor.
descriptor
)

Adds a new CONSTANT_Fieldref_info, CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantMethodHandle
(final int referenceKind, final String
the internal name of a class of interface.
owner
,
final String
a field or method name.
name
,
final String
a field or method descriptor.
descriptor
,
final boolean
whether owner is an interface or not.
isInterface
)

Adds a CONSTANT_MethodHandle_info to the constant pool of this symbol table.

private void
addConstantMethodHandle(final int
the constant pool index of the new Symbol.
index
,
final int referenceKind, final String
the internal name of a class of interface.
owner
,
final String
a field or method name.
name
,
final String
a field or method descriptor.
descriptor
)

Adds a new CONSTANT_MethodHandle_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantMethodref
(final String
the internal name of a class.
owner
,
final String
a method name.
name
,
final String
a method descriptor.
descriptor
,
final boolean
whether owner is an interface or not.
isInterface
)

Adds a CONSTANT_Methodref_info or CONSTANT_InterfaceMethodref_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantMethodType
(final String
a method descriptor.
methodDescriptor
)

Adds a CONSTANT_MethodType_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantModule
(final String
a fully qualified name (using dots) of a module.
moduleName
)

Adds a CONSTANT_Module_info to the constant pool of this symbol table.

pack-priv int

Returns:

a new or already existing Symbol with the given value.
addConstantNameAndType
(final String
a field or method name.
name
,
final String
a field or method descriptor.
descriptor
)

Adds a CONSTANT_NameAndType_info to the constant pool of this symbol table.

private void
addConstantNameAndType(final int
the constant pool index of the new Symbol.
index
,
final String
a field or method name.
name
,
final String
a field or method descriptor.
descriptor
)

Adds a new CONSTANT_NameAndType_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantPackage
(final String
the internal name of a package.
packageName
)

Adds a CONSTANT_Package_info to the constant pool of this symbol table.

pack-priv Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantString
(final String
a string.
value
)

Adds a CONSTANT_String_info to the constant pool of this symbol table.

pack-priv int

Returns:

a new or already existing Symbol with the given value.
addConstantUtf8
(final String
a string.
value
)

Adds a CONSTANT_Utf8_info to the constant pool of this symbol table.

private void
addConstantUtf8(final int
the constant pool index of the new Symbol.
index
,
final String
a string.
value
)

Adds a new CONSTANT_String_info to the constant pool of this symbol table.

private Symbol

Returns:

a new or already existing Symbol with the given value.
addConstantUtf8Reference
(final int tag, final String
an internal class name, an arbitrary string, a method descriptor, a module or a package name, depending on tag.
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.

private void
addConstantUtf8Reference(final int
the constant pool index of the new Symbol.
index
,
final int tag, final String
an internal class name, an arbitrary string, a method descriptor, a module or a package name, depending on tag.
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.

pack-priv int

Returns:

the index of a new or already existing type Symbol with the given value.
addForwardUninitializedType
(final String
an internal class name.
value
,
final Label
the label of the NEW instruction that created this uninitialized type value. If the label is resolved, use the addUninitializedType method instead.
label
)

Adds a "forward uninitialized" type in the type table of this symbol table.

pack-priv int

Returns:

the index of a new or already existing Symbol#TYPE_TAG type Symbol, corresponding to the common super class of the given types.
addMergedType
(final int
a Symbol#TYPE_TAG type, specified by its index in the type table.
typeTableIndex1
,
final int
another Symbol#TYPE_TAG type, specified by its index in the type table.
typeTableIndex2
)

Adds a merged type in the type table of this symbol table.

pack-priv int

Returns:

the index of a new or already existing type Symbol with the given value.
addType
(final String
an internal class name.
value
)

Adds a type in the type table of this symbol table.

private int

Returns:

the index in typeTable where the given type was added, which is also equal to entry's index by hypothesis.
addTypeInternal
(final SymbolTable.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.
entry
)

Adds the given type Symbol to typeTable.

pack-priv int

Returns:

the index of a new or already existing type #@link Symbol} with the given value.
addUninitializedType
(final String
an internal class name.
value
,
final int
the bytecode offset of the NEW instruction that created this uninitialized type value.
bytecodeOffset
)

Adds an uninitialized type in the type table of this symbol table.

pack-priv int

Returns:

the size in bytes of this symbol table's BootstrapMethods attribute.
computeBootstrapMethodsSize
()

Returns the size in bytes of this symbol table's BootstrapMethods attribute.

private void
copyBootstrapMethods(final ClassReader
the ClassReader whose bootstrap methods must be copied to initialize the SymbolTable.
classReader
,
final char[]
a buffer used to read strings in the constant pool.
charBuffer
)

Read the BootstrapMethods 'bootstrap_methods' array binary content and add them as entries of the SymbolTable.

private SymbolTable.Entry

Returns:

the list of entries which can potentially have the given hash code. The list is stored via the Entry#next field.
get
(final int hashCode)

Returns the list of entries which can potentially have the given hash code.

pack-priv String

Returns:

the internal name of the class to which this symbol table belongs.
getClassName
()

Returns the internal name of the class to which this symbol table belongs.

pack-priv int

Returns:

the number of items in this symbol table's constant_pool array (plus 1).
getConstantPoolCount
()

Returns the number of items in this symbol table's constant_pool array (plus 1).

pack-priv int

Returns:

the length in bytes of this symbol table's constant_pool array.
getConstantPoolLength
()

Returns the length in bytes of this symbol table's constant_pool array.

pack-priv Label

Returns:

the label corresponding of the NEW instruction which created this "forward uninitialized" type.
getForwardUninitializedLabel
(final int
the type table index of a "forward uninitialized" type table element.
typeIndex
)

Returns the label corresponding to the "forward uninitialized" type table element whose index is given.

pack-priv int

Returns:

the major version of the class to which this symbol table belongs.
getMajorVersion
()

Returns the major version of the class to which this symbol table belongs.

private SymbolTable.LabelEntry

Returns:

the LabelEntry corresponding to label.
getOrAddLabelEntry
(final Label
the Label of 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). See Symbol#FORWARD_UNINITIALIZED_TYPE_TAG.
label
)

Returns the LabelEntry corresponding to the given label.

pack-priv ClassReader

Returns:

the ClassReader from which this SymbolTable was constructed, or null if it was constructed from scratch.
getSource
()

Returns the ClassReader from which this SymbolTable was constructed.

pack-priv Symbol

Returns:

the type table element whose index is given.
getType
(final int
a type table index.
typeIndex
)

Returns the type table element whose index is given.

private static int
hash(final int tag, final int value)

private static int
hash(final int tag, final long value)

private static int
hash(final int tag, final String value)

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

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

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

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

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

private SymbolTable.Entry

Returns:

the given entry
put
(final SymbolTable.Entry
an Entry (which must not already be contained in entries).
entry
)

Puts the given entry in the entries hash set.

pack-priv void
putBootstrapMethods(final ByteVector
where the JVMS BootstrapMethods attribute must be put.
output
)

Puts this symbol table's BootstrapMethods attribute in the given ByteVector.

pack-priv void
putConstantPool(final ByteVector
where the JVMS ClassFile's constant_pool array must be put.
output
)

Puts this symbol table's constant_pool array in the given ByteVector, preceded by the constant_pool_count value.

pack-priv int

Returns:

the constant pool index of a new or already existing Symbol with the given class name.
setMajorVersionAndClassName
(final int
a major ClassFile version number.
majorVersion
,
final String
an internal class name.
className
)

Sets the major version and the name of the class to which this symbol table belongs.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait