public class ConstantPool
extends java.lang.Object
Constructor and Description |
---|
ConstantPool()
Initialise the constant pool.
|
Modifier and Type | Method and Description |
---|---|
int |
addEntry(ConstantPoolEntry entry)
Add an entry to the constant pool.
|
int |
getClassEntry(java.lang.String className)
Get the index of a given CONSTANT_CLASS entry in the constant pool.
|
int |
getConstantEntry(java.lang.Object constantValue)
Get the index of a given constant value entry in the constant pool.
|
ConstantPoolEntry |
getEntry(int index)
Get an constant pool entry at a particular index.
|
int |
getFieldRefEntry(java.lang.String fieldClassName,
java.lang.String fieldName,
java.lang.String fieldType)
Get the index of a given CONSTANT_FIELDREF entry in the constant
pool.
|
int |
getInterfaceMethodRefEntry(java.lang.String interfaceMethodClassName,
java.lang.String interfaceMethodName,
java.lang.String interfaceMethodType)
Get the index of a given CONSTANT_INTERFACEMETHODREF entry in the
constant pool.
|
int |
getMethodRefEntry(java.lang.String methodClassName,
java.lang.String methodName,
java.lang.String methodType)
Get the index of a given CONSTANT_METHODREF entry in the constant
pool.
|
int |
getNameAndTypeEntry(java.lang.String name,
java.lang.String type)
Get the index of a given CONSTANT_NAMEANDTYPE entry in the constant
pool.
|
int |
getUTF8Entry(java.lang.String value)
Get the index of a given UTF8 constant pool entry.
|
void |
read(java.io.DataInputStream classStream)
Read the constant pool from a class input stream.
|
void |
resolve()
Resolve the entries in the constant pool.
|
int |
size()
Get the size of the constant pool.
|
java.lang.String |
toString()
Dump the constant pool to a string.
|
public void read(java.io.DataInputStream classStream) throws java.io.IOException
classStream
- the DataInputStream of a class file.java.io.IOException
- if there is a problem reading the constant pool
from the streampublic int size()
public int addEntry(ConstantPoolEntry entry)
entry
- the new entry to be added to the constant pool.public void resolve()
public ConstantPoolEntry getEntry(int index)
index
- the index into the constant pool.public int getUTF8Entry(java.lang.String value)
value
- the string value of the UTF8 entry.public int getClassEntry(java.lang.String className)
className
- the name of the class for which the class entry
index is required.public int getConstantEntry(java.lang.Object constantValue)
constantValue
- the constant value for which the index is
required.public int getMethodRefEntry(java.lang.String methodClassName, java.lang.String methodName, java.lang.String methodType)
methodClassName
- the name of the class which contains the
method being referenced.methodName
- the name of the method being referenced.methodType
- the type descriptor of the method being referenced.public int getInterfaceMethodRefEntry(java.lang.String interfaceMethodClassName, java.lang.String interfaceMethodName, java.lang.String interfaceMethodType)
interfaceMethodClassName
- the name of the interface which
contains the method being referenced.interfaceMethodName
- the name of the method being referenced.interfaceMethodType
- the type descriptor of the method being
referenced.public int getFieldRefEntry(java.lang.String fieldClassName, java.lang.String fieldName, java.lang.String fieldType)
fieldClassName
- the name of the class which contains the field
being referenced.fieldName
- the name of the field being referenced.fieldType
- the type descriptor of the field being referenced.public int getNameAndTypeEntry(java.lang.String name, java.lang.String type)
name
- the nametype
- the typepublic java.lang.String toString()
toString
in class java.lang.Object