|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractCollection | +--java.util.AbstractList | +--java.util.Vector | +--edu.wisc.cs.java.ConstantPool
This class maintains a constant pool for a single class as specified by the Java Virtual Machine specification. Valid indices of constants range from one to (size() - 1) method. As per the Java Virtual Machine specification, the constant at index zero is not in the constant pool. Strange, but true.
Fields inherited from class java.util.Vector |
capacityIncrement,
elementCount,
elementData |
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary | |
ConstantPool(java.io.DataInputStream in)
Constructs a new constant pool object by reading the table from a stream. |
Method Summary | |
int |
addClass(java.lang.String classname)
Adds a new CLASS constant with the specified name. |
int |
addField(java.lang.String classname,
java.lang.String name,
java.lang.String desc)
Adds constants to describe another field. |
int |
addMethod(java.lang.String classname,
java.lang.String name,
java.lang.String desc)
Adds constants to describe another method. |
int |
addNameAndType(java.lang.String name,
java.lang.String type)
Adds a new NAME_AND_TYPE constant with the specified name and type values. |
int |
addUTFConstant(java.lang.String text)
Adds a new UTF8 constant to the constant pool. |
int |
getClassIndex(java.lang.String s)
Returns the index of a CLASS constant representing a class with the specified name. |
Constant |
getConstant(int i)
Returns a constant from the constant pool. |
int |
getMethodIndex(java.lang.String cls,
java.lang.String mname,
java.lang.String mdesc)
Searches for a reference to a method in the constant pool. |
int |
getNameAndTypeIndex(java.lang.String name,
java.lang.String type)
Returns the index of a NAME_AND_TYPE constant with the specified name and type strings. |
java.lang.String |
getString(int index)
Returns a string representation of the desired constant. |
int |
getUTFIndex(java.lang.String s)
Returns the index of an entry in the constant pool which contains the desired string. |
void |
printData(java.io.PrintStream out)
Writes textual information about the class represented by this ConstantPool object to the specified destination. |
int |
size()
Returns number of constants in this pool. |
void |
writeTo(java.io.DataOutputStream out)
Writes the constant pool to the specified stream in the format specified by the classfile format. |
Methods inherited from class java.util.Vector |
add,
add,
addAll,
addAll,
addElement,
capacity,
clear,
clone,
contains,
containsAll,
copyInto,
elementAt,
elements,
ensureCapacity,
equals,
firstElement,
get,
hashCode,
indexOf,
indexOf,
insertElementAt,
isEmpty,
lastElement,
lastIndexOf,
lastIndexOf,
remove,
remove,
removeAll,
removeAllElements,
removeElement,
removeElementAt,
removeRange,
retainAll,
set,
setElementAt,
setSize,
subList,
toArray,
toArray,
toString,
trimToSize |
Methods inherited from class java.util.AbstractList |
iterator,
listIterator,
listIterator |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ConstantPool(java.io.DataInputStream in) throws java.io.IOException
in
- the stream from which to read the constant pool information.Method Detail |
public Constant getConstant(int i)
i
- the index of the desired constant.public java.lang.String getString(int index)
index
- the index of the constant to be represented as a string.public int size()
public int getUTFIndex(java.lang.String s)
s
- the string to be located in the constant pool.public int addUTFConstant(java.lang.String text)
text
- the text for the new UTF8 constant.public int getClassIndex(java.lang.String s)
public int getNameAndTypeIndex(java.lang.String name, java.lang.String type)
public int addField(java.lang.String classname, java.lang.String name, java.lang.String desc)
classname
- the index into the constant pool containing the CLASS
of which the new field will be a member.name
- the name of the new field.desc
- a string describing the type of the field.public int addMethod(java.lang.String classname, java.lang.String name, java.lang.String desc)
classname
- the index into the constant pool containing the CLASS
of which the new method will be a member.name
- the name of the new method.desc
- a string describing the type of the method.public int addClass(java.lang.String classname)
classname
- the name of the class to be represented by the new
constant.public int addNameAndType(java.lang.String name, java.lang.String type)
name
- the name of the new variable.type
- the type of the new variable.public int getMethodIndex(java.lang.String cls, java.lang.String mname, java.lang.String mdesc)
cls
- the name of the class which the method is a member of.mname
- the name of the method.mdesc
- the descriptor for the method.public void printData(java.io.PrintStream out)
out
- a PrintStream connected to the desired destination.public void writeTo(java.io.DataOutputStream out) throws java.io.IOException
out
- a destination stream to write the classfile data to.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |