public final class StdConstantPool extends MutabilityControl implements ConstantPool
ConstantPool, which directly stores
an array of Constant objects and can be made immutable.| Constructor and Description |
|---|
StdConstantPool(int size)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
Constant |
get(int n)
Get the
nth entry in the constant pool, which must
be valid. |
Constant |
get0Ok(int n)
Get the
nth entry in the constant pool, which must
be valid unless n == 0, in which case null
is returned. |
Constant[] |
getEntries()
Get all entries in this constant pool.
|
Constant |
getOrNull(int n)
Get the
nth entry in the constant pool, or
null if the index is in-range but invalid. |
void |
set(int n,
Constant cst)
Sets the entry at the given index.
|
int |
size()
Get the "size" of the constant pool.
|
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutablepublic StdConstantPool(int size)
null.size - the size of the pool; this corresponds to the
class file field constant_pool_count, and is in fact
always at least one more than the actual size of the constant pool,
as element 0 is always invalid.public int size()
constant_pool_count, and is in fact
always at least one more than the actual size of the constant pool,
as element 0 is always invalid.size in interface ConstantPool>= 1; the sizepublic Constant getOrNull(int n)
nth entry in the constant pool, or
null if the index is in-range but invalid. In
particular, null is returned for index 0
as well as the index after any entry which is defined to take up
two slots (that is, Long and Double
entries).getOrNull in interface ConstantPooln - n >= 0, n < size(); the constant pool indexnull-ok; the corresponding entry, or null if
the index is in-range but invalidpublic Constant get0Ok(int n)
nth entry in the constant pool, which must
be valid unless n == 0, in which case null
is returned.get0Ok in interface ConstantPooln - n >= 0, n < size(); the constant pool indexnull-ok; the corresponding entry, if n != 0public Constant get(int n)
nth entry in the constant pool, which must
be valid.get in interface ConstantPooln - n >= 0, n < size(); the constant pool indexnon-null; the corresponding entrypublic Constant[] getEntries()
getEntries in interface ConstantPoolpublic void set(int n,
Constant cst)
n - >= 1, < size(); which entrycst - null-ok; the constant to storeCopyright © 2020. All Rights Reserved.