Methods Summary |
---|
public int | addEntry(ConstantPoolEntry entry)Add an entry to the constant pool.
int index = entries.size();
entries.addElement(entry);
int numSlots = entry.getNumEntries();
// add null entries for any additional slots required.
for (int j = 0; j < numSlots - 1; ++j) {
entries.addElement(null);
}
if (entry instanceof Utf8CPInfo) {
Utf8CPInfo utf8Info = (Utf8CPInfo) entry;
utf8Indexes.put(utf8Info.getValue(), new Integer(index));
}
return index;
|
public int | getClassEntry(java.lang.String className)Get the index of a given CONSTANT_CLASS entry in the constant pool.
int index = -1;
for (int i = 0; i < entries.size() && index == -1; ++i) {
Object element = entries.elementAt(i);
if (element instanceof ClassCPInfo) {
ClassCPInfo classinfo = (ClassCPInfo) element;
if (classinfo.getClassName().equals(className)) {
index = i;
}
}
}
return index;
|
public int | getConstantEntry(java.lang.Object constantValue)Get the index of a given constant value entry in the constant pool.
int index = -1;
for (int i = 0; i < entries.size() && index == -1; ++i) {
Object element = entries.elementAt(i);
if (element instanceof ConstantCPInfo) {
ConstantCPInfo constantEntry = (ConstantCPInfo) element;
if (constantEntry.getValue().equals(constantValue)) {
index = i;
}
}
}
return index;
|
public ConstantPoolEntry | getEntry(int index)Get an constant pool entry at a particular index.
return (ConstantPoolEntry) entries.elementAt(index);
|
public 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 index = -1;
for (int i = 0; i < entries.size() && index == -1; ++i) {
Object element = entries.elementAt(i);
if (element instanceof FieldRefCPInfo) {
FieldRefCPInfo fieldRefEntry = (FieldRefCPInfo) element;
if (fieldRefEntry.getFieldClassName().equals(fieldClassName)
&& fieldRefEntry.getFieldName().equals(fieldName)
&& fieldRefEntry.getFieldType().equals(fieldType)) {
index = i;
}
}
}
return index;
|
public 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 index = -1;
for (int i = 0; i < entries.size() && index == -1; ++i) {
Object element = entries.elementAt(i);
if (element instanceof InterfaceMethodRefCPInfo) {
InterfaceMethodRefCPInfo interfaceMethodRefEntry
= (InterfaceMethodRefCPInfo) element;
if (interfaceMethodRefEntry.getInterfaceMethodClassName().equals(
interfaceMethodClassName)
&& interfaceMethodRefEntry.getInterfaceMethodName().equals(
interfaceMethodName)
&& interfaceMethodRefEntry.getInterfaceMethodType().equals(
interfaceMethodType)) {
index = i;
}
}
}
return index;
|
public 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 index = -1;
for (int i = 0; i < entries.size() && index == -1; ++i) {
Object element = entries.elementAt(i);
if (element instanceof MethodRefCPInfo) {
MethodRefCPInfo methodRefEntry = (MethodRefCPInfo) element;
if (methodRefEntry.getMethodClassName().equals(methodClassName)
&& methodRefEntry.getMethodName().equals(methodName)
&& methodRefEntry.getMethodType().equals(methodType)) {
index = i;
}
}
}
return index;
|
public int | getNameAndTypeEntry(java.lang.String name, java.lang.String type)Get the index of a given CONSTANT_NAMEANDTYPE entry in the constant
pool.
int index = -1;
for (int i = 0; i < entries.size() && index == -1; ++i) {
Object element = entries.elementAt(i);
if (element instanceof NameAndTypeCPInfo) {
NameAndTypeCPInfo nameAndTypeEntry
= (NameAndTypeCPInfo) element;
if (nameAndTypeEntry.getName().equals(name)
&& nameAndTypeEntry.getType().equals(type)) {
index = i;
}
}
}
return index;
|
public int | getUTF8Entry(java.lang.String value)Get the index of a given UTF8 constant pool entry.
int index = -1;
Integer indexInteger = (Integer) utf8Indexes.get(value);
if (indexInteger != null) {
index = indexInteger.intValue();
}
return index;
|
public void | read(java.io.DataInputStream classStream)Read the constant pool from a class input stream.
int numEntries = classStream.readUnsignedShort();
for (int i = 1; i < numEntries;) {
ConstantPoolEntry nextEntry
= ConstantPoolEntry.readEntry(classStream);
i += nextEntry.getNumEntries();
addEntry(nextEntry);
}
|
public void | resolve()Resolve the entries in the constant pool. Resolution of the constant
pool involves transforming indexes to other constant pool entries
into the actual data for that entry.
for (Enumeration i = entries.elements(); i.hasMoreElements();) {
ConstantPoolEntry poolInfo = (ConstantPoolEntry) i.nextElement();
if (poolInfo != null && !poolInfo.isResolved()) {
poolInfo.resolve(this);
}
}
|
public int | size()Get the size of the constant pool.
return entries.size();
|
public java.lang.String | toString()Dump the constant pool to a string.
StringBuffer sb = new StringBuffer("\n");
int size = entries.size();
for (int i = 0; i < size; ++i) {
sb.append("[" + i + "] = " + getEntry(i) + "\n");
}
return sb.toString();
|