public class ConstantPool extends Object implements VisitAcceptor
LongEntry
s and DoubleEntry
s each
occupy two indexes in the pool.Constructor and Description |
---|
ConstantPool()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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 one. |
int |
addEntry(Entry entry)
Add an entry to the pool.
|
void |
clear()
Clear all entries from the pool.
|
int |
findClassEntry(String name,
boolean add)
Return the constant pool index of the
ClassEntry for the given
class name, or 0 if it does not exist. |
int |
findDoubleEntry(double value,
boolean add)
Return the constant pool index of the
DoubleEntry for the given
value, or 0 if it does not exist. |
int |
findFieldEntry(String owner,
String name,
String desc,
boolean add)
Return the constant pool index of the
FieldEntry for the
given name, descriptor, and owner class name. |
int |
findFloatEntry(float value,
boolean add)
Return the constant pool index of the
FloatEntry for the given
value, or 0 if it does not exist. |
int |
findIntEntry(int value,
boolean add)
Return the constant pool index of the
IntEntry for the given
value, or 0 if it does not exist. |
int |
findInterfaceMethodEntry(String owner,
String name,
String desc,
boolean add)
Return the constant pool index of the
InterfaceMethodEntry for
the given name, descriptor, and owner class name. |
int |
findInvokeDynamicEntry(int bootstrapMethodIndex,
String name,
String desc,
boolean add) |
int |
findLongEntry(long value,
boolean add)
Return the constant pool index of the
LongEntry for the given
value, or 0 if it does not exist. |
int |
findMethodEntry(String owner,
String name,
String desc,
boolean add)
Return the constant pool index of the
MethodEntry for the
given name, descriptor, and owner class name. |
int |
findNameAndTypeEntry(String name,
String desc,
boolean add)
Return the constant pool index of the
NameAndTypeEntry for the
given name and descriptor, or 0 if it does not exist. |
int |
findStringEntry(String value,
boolean add)
Return the constant pool index of the
StringEntry for the given
string value, or 0 if it does not exist. |
int |
findUTF8Entry(String value,
boolean add)
Return the index of the
UTF8Entry with the given value, or
0 if it does not exist. |
Entry[] |
getEntries()
Return all the entries in the pool.
|
Entry |
getEntry(int index)
Retrieve the entry at the specified 1-based index.
|
int |
indexOf(Entry entry)
Return the index of the given entry, or 0 if it is not in the pool.
|
void |
read(DataInput in)
Fill the constant pool from the given bytecode stream.
|
boolean |
removeEntry(Entry entry)
Remove the given entry from the pool.
|
int |
size()
Return the number of places occupied in the pool, including the fact
that long and double entries occupy two places.
|
void |
write(DataOutput out)
Write the constant pool to the given bytecode stream.
|
public Entry[] getEntries()
public Entry getEntry(int index)
IndexOutOfBoundsException
- if index is invalid,
including the case that it points to the second slot of a
long or double entrypublic int indexOf(Entry entry)
public int addEntry(Entry entry)
public boolean removeEntry(Entry entry)
public void clear()
public int size()
public int findUTF8Entry(String value, boolean add)
UTF8Entry
with the given value, or
0 if it does not exist.add
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findDoubleEntry(double value, boolean add)
DoubleEntry
for the given
value, or 0 if it does not exist.value
- the value to findadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findFloatEntry(float value, boolean add)
FloatEntry
for the given
value, or 0 if it does not exist.value
- the value to findadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findIntEntry(int value, boolean add)
IntEntry
for the given
value, or 0 if it does not exist.value
- the value to findadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findLongEntry(long value, boolean add)
LongEntry
for the given
value, or 0 if it does not exist.value
- the value to findadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findStringEntry(String value, boolean add)
StringEntry
for the given
string value, or 0 if it does not exist.value
- the value to findadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findClassEntry(String name, boolean add)
ClassEntry
for the given
class name, or 0 if it does not exist.name
- the class name in internal formadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findNameAndTypeEntry(String name, String desc, boolean add)
NameAndTypeEntry
for the
given name and descriptor, or 0 if it does not exist.name
- the name of the entitydesc
- the descriptor of the entity in internal formadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findFieldEntry(String owner, String name, String desc, boolean add)
FieldEntry
for the
given name, descriptor, and owner class name.owner
- the name of the field's owning class in internal formname
- the name of the fielddesc
- the descriptor of the field in internal formadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findMethodEntry(String owner, String name, String desc, boolean add)
MethodEntry
for the
given name, descriptor, and owner class name.owner
- the name of the method's owning class in internal formname
- the name of the methoddesc
- the descriptor of the method in internal formadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findInterfaceMethodEntry(String owner, String name, String desc, boolean add)
InterfaceMethodEntry
for
the given name, descriptor, and owner class name.owner
- the name of the method's owning class in internal formname
- the name of the methoddesc
- the descriptor of the method in internal formadd
- if true, the entry will be added if it does not
already exist, and the new entry's index returnedpublic int findInvokeDynamicEntry(int bootstrapMethodIndex, String name, String desc, boolean add)
public void acceptVisit(BCVisitor visit)
VisitAcceptor
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 one.acceptVisit
in interface VisitAcceptor
public void read(DataInput in) throws IOException
IOException
public void write(DataOutput out) throws IOException
IOException
Copyright © 2002–2019. All rights reserved.