|
TechTrader Bytecode Toolkit | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.techtrader.modules.tools.bytecode.lowlevel.ConstantPool
Represents a class constant pool, containing entries for all strings, constants, classes, etc referenced in the class structure and opcodes. In keeping with the low-level bytecode representation, all pool indexes are 1-based.
NOTE: Entries are not meant to be manipulated manually. If you change
entries by hand, make sure to call the rehash(com.techtrader.modules.tools.bytecode.lowlevel.Entry, int)
method of the
ConstantPool so that the entry is hashed correctly for quick lookups and
to avoid duplicates.
NOTE: LongEntries and DoubleEntries are always followed by a PlaceHolderEntry in the pool, as they take up 2 pool indeces. When manually adding a new entry of these types, it is not necessary to insert the PlaceHolder as well; the system will do this automatically.
Fields inherited from interface com.techtrader.modules.tools.bytecode.lowlevel.LowLevelConstants |
ENTRY_CLASS,
ENTRY_DOUBLE,
ENTRY_FIELD,
ENTRY_FLOAT,
ENTRY_INT,
ENTRY_INTMETHOD,
ENTRY_LONG,
ENTRY_METHOD,
ENTRY_NAME_AND_TYPE,
ENTRY_PLACEHOLDER,
ENTRY_STRING,
ENTRY_UTF8 |
Constructor Summary | |
ConstantPool(BCClass owner)
|
Method Summary | |
void |
acceptVisit(BCVisitor visit)
Accept a visit from a BCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this object. |
int |
addEntry(Entry entry)
Add an entry to the pool. |
void |
addEntry(int index,
Entry entry)
Set the entry at the given 1-based index. |
static Entry |
createEntry(int type)
Create an Entry based on its one-byte code: one of the constants in the LowLevelConstants class. |
int |
getClassIndex(String name)
Get the constant pool index of the entry for the given class name. |
String |
getClassName(int index)
Get the value of the entry at the given index. |
int |
getComplexIndex(String name,
String desc,
String owner,
Class type)
Get the constant pool index of the entry for the given complex entry. |
String |
getComplexName(int index)
Get the value of the entry at the given index. |
String |
getComplexOwnerTypeName(int index)
Get the value of the entry at the given index. |
String |
getComplexTypeName(int index)
Get the value of the entry at the given index. |
Object |
getConstant(int index)
Get the value of the entry at the given index. |
int |
getConstantIndex(Object value)
Get the constant pool index of the entry for the given constant value. |
Entry[] |
getEntries()
Get the entries in the pool. |
Entry |
getEntry(int index)
Retrieve the entry at the specified 1-based index. |
int |
getNameAndTypeIndex(String name,
String desc)
Get the constant pool index of the entry for the given name+type. |
String |
getUTF(int index)
Get the value of the entry at the given index. |
int |
getUTFIndex(String name)
Get the constant pool index of the entry for the given UTF value. |
void |
readData(DataInput in)
|
void |
rehash(Entry entry,
int poolIndex)
Rehash the given entry after modification; this allows for quick lookups and guarantees that entries won't be repeated in the pool. |
boolean |
removeEntry(Entry entry)
Remove the given entry from the pool. |
Entry |
removeEntry(int index)
Remove the entry at the given index. |
int |
setClassName(int index,
String name)
Set the entry at the given index; if the given index is <= 0, a search will be performed for an entry with the given value, and, if it fails, a new entry will be added to the pool. |
int |
setComplex(int index,
String name,
String desc,
String owner,
Class entryType)
Set the entry at the given index; if the given index is <= 0, a search will be performed for an entry with the given value, and, if it fails, a new entry will be added to the pool. |
int |
setConstant(int index,
Object value)
Set the entry at the given index; if the given index is <= 0, a search will be performed for an entry with the given value, and, if it fails, a new entry will be added to the pool. |
Entry |
setEntry(int index,
Entry entry)
Set the entry at the given 1-based index. |
int |
setNameAndType(int index,
String name,
String desc)
Set the entry at the given index; if the given index is <= 0, a search will be performed for an entry with the given value, and, if it fails, a new entry will be added to the pool. |
int |
setUTF(int index,
String name)
Set the entry at the given index; if the given index is <= 0, a search will be performed for an entry with the given value, and, if it fails, a new entry will be added to the pool. |
int |
size()
Return the number of entries in the pool, including placeholder entries. |
void |
writeData(DataOutput out)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ConstantPool(BCClass owner)
Method Detail |
public static Entry createEntry(int type)
public Entry[] getEntries()
public Entry getEntry(int index)
public Entry setEntry(int index, Entry entry)
public void addEntry(int index, Entry entry)
public int addEntry(Entry entry)
public Entry removeEntry(int index)
public boolean removeEntry(Entry entry)
public int size()
public int getUTFIndex(String name)
public String getUTF(int index)
public int setUTF(int index, String name)
public int getClassIndex(String name)
public String getClassName(int index)
public int setClassName(int index, String name)
public int getNameAndTypeIndex(String name, String desc)
public int setNameAndType(int index, String name, String desc)
public int getComplexIndex(String name, String desc, String owner, Class type)
public int setComplex(int index, String name, String desc, String owner, Class entryType)
public String getComplexName(int index)
public String getComplexTypeName(int index)
public String getComplexOwnerTypeName(int index)
public int getConstantIndex(Object value)
public Object getConstant(int index)
public int setConstant(int index, Object value)
public void rehash(Entry entry, int poolIndex)
public void readData(DataInput in) throws IOException
public void writeData(DataOutput out) throws IOException
public void acceptVisit(BCVisitor visit)
|
TechTrader Bytecode Toolkit | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |