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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget(int n) Get thenth entry in the constant pool, which must be valid.get0Ok(int n) Get thenth entry in the constant pool, which must be valid unlessn == 0, in which casenullis returned.Constant[]Get all entries in this constant pool.getOrNull(int n) Get thenth entry in the constant pool, ornullif the index is in-range but invalid.voidSets the entry at the given index.intsize()Get the "size" of the constant pool.Methods inherited from class 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 element0is 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 element0is always invalid.- Specified by:
sizein interfaceConstantPool- Returns:
>= 1;the size
-
getOrNull
Get thenth entry in the constant pool, ornullif the index is in-range but invalid. In particular,nullis returned for index0as well as the index after any entry which is defined to take up two slots (that is,LongandDoubleentries).- Specified by:
getOrNullin interfaceConstantPool- Parameters:
n-n >= 0, n < size();the constant pool index- Returns:
null-ok;the corresponding entry, ornullif the index is in-range but invalid
-
get0Ok
Get thenth entry in the constant pool, which must be valid unlessn == 0, in which casenullis returned.- Specified by:
get0Okin interfaceConstantPool- Parameters:
n-n >= 0, n < size();the constant pool index- Returns:
null-ok;the corresponding entry, ifn != 0
-
get
Get thenth entry in the constant pool, which must be valid.- Specified by:
getin 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:
getEntriesin 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
-