Package com.android.dx.rop.cst
Class StdConstantPool
java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.rop.cst.StdConstantPool
- All Implemented Interfaces:
ConstantPool
Standard implementation of
ConstantPool
, which directly stores
an array of Constant
objects and can be made immutable.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget
(int n) Get then
th entry in the constant pool, which must be valid.get0Ok
(int n) Get then
th entry in the constant pool, which must be valid unlessn == 0
, in which casenull
is returned.Constant[]
Get all entries in this constant pool.getOrNull
(int n) Get then
th entry in the constant pool, ornull
if the index is in-range but invalid.void
Sets the entry at the given index.int
size()
Get the "size" of the constant pool.Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
-
Constructor Details
-
StdConstantPool
public StdConstantPool(int size) Constructs an instance. All indices initially containnull
.- Parameters:
size
- the size of the pool; this corresponds to the class file fieldconstant_pool_count
, and is in fact always at least one more than the actual size of the constant pool, as element0
is always invalid.
-
-
Method Details
-
size
public int size()Get the "size" of the constant pool. This corresponds to the class file fieldconstant_pool_count
, and is in fact always at least one more than the actual size of the constant pool, as element0
is always invalid.- Specified by:
size
in interfaceConstantPool
- Returns:
>= 1;
the size
-
getOrNull
Get then
th entry in the constant pool, ornull
if the index is in-range but invalid. In particular,null
is returned for index0
as well as the index after any entry which is defined to take up two slots (that is,Long
andDouble
entries).- Specified by:
getOrNull
in interfaceConstantPool
- Parameters:
n
-n >= 0, n < size();
the constant pool index- Returns:
null-ok;
the corresponding entry, ornull
if the index is in-range but invalid
-
get0Ok
Get then
th entry in the constant pool, which must be valid unlessn == 0
, in which casenull
is returned.- Specified by:
get0Ok
in interfaceConstantPool
- Parameters:
n
-n >= 0, n < size();
the constant pool index- Returns:
null-ok;
the corresponding entry, ifn != 0
-
get
Get then
th entry in the constant pool, which must be valid.- Specified by:
get
in interfaceConstantPool
- Parameters:
n
-n >= 0, n < size();
the constant pool index- Returns:
non-null;
the corresponding entry
-
getEntries
Get all entries in this constant pool.- Specified by:
getEntries
in interfaceConstantPool
- Returns:
- the returned array may contain null entries.
-
set
Sets the entry at the given index.- Parameters:
n
->= 1, < size();
which entrycst
-null-ok;
the constant to store
-