Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.rop.cst

public final Class StdConstantPool

extends MutabilityControl
implements ConstantPool
Class Inheritance
All Implemented Interfaces
org.droidparts.dexmaker.dx.rop.cst.ConstantPool
Imports
org.droidparts.dexmaker.dx.util.ExceptionWithContext, .Hex, .MutabilityControl

Standard implementation of ConstantPool, which directly stores an array of Constant objects and can be made immutable.

Field Summary

Modifier and TypeField and Description
private final Constant[]
entries

non-null; array of entries

Constructor Summary

AccessConstructor and Description
public
StdConstantPool(int
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.
size
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public Constant
get(int
n >= 0, n < size(); the constant pool index
n
)

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.get.

Get the nth entry in the constant pool, which must be valid.
public Constant
get0Ok(int
n >= 0, n < size(); the constant pool index
n
)

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.get0Ok.

Get the nth entry in the constant pool, which must be valid unless n == 0, in which case null is returned.
public Constant
getOrNull(int
n >= 0, n < size(); the constant pool index
n
)

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.getOrNull.

Get the nth entry in the constant pool, or null if the index is in-range but invalid.
public void
set(int
>= 1, < size(); which entry
n
,
Constant
null-ok; the constant to store
cst
)

Sets the entry at the given index.

public int
size()

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.size.

Get the "size" of the constant pool.
private static Constant

Returns:

never
throwInvalid
(int
the bad cpi
idx
)

Throws the right exception for an invalid cpi.

Inherited from org.droidparts.dexmaker.dx.util.MutabilityControl:
isImmutableisMutablesetImmutablethrowIfImmutablethrowIfMutable

Field Detail

entriesback to summary
private final Constant[] entries

non-null; array of entries

Constructor Detail

StdConstantPoolback to summary
public StdConstantPool(int size)

Constructs an instance. All indices initially contain null.

Parameters
size:int

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.

Method Detail

getback to summary
public Constant get(int n)

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.get.

Doc from org.droidparts.dexmaker.dx.rop.cst.ConstantPool.get.

Get the nth entry in the constant pool, which must be valid.

Parameters
n:int

n >= 0, n < size(); the constant pool index

Returns:Constant

non-null; the corresponding entry

get0Okback to summary
public Constant get0Ok(int n)

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.get0Ok.

Doc from org.droidparts.dexmaker.dx.rop.cst.ConstantPool.get0Ok.

Get the nth entry in the constant pool, which must be valid unless n == 0, in which case null is returned.

Parameters
n:int

n >= 0, n < size(); the constant pool index

Returns:Constant

null-ok; the corresponding entry, if n != 0

getOrNullback to summary
public Constant getOrNull(int n)

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.getOrNull.

Doc from org.droidparts.dexmaker.dx.rop.cst.ConstantPool.getOrNull.

Get the 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).

Parameters
n:int

n >= 0, n < size(); the constant pool index

Returns:Constant

null-ok; the corresponding entry, or null if the index is in-range but invalid

setback to summary
public void set(int n, Constant cst)

Sets the entry at the given index.

Parameters
n:int

>= 1, < size(); which entry

cst:Constant

null-ok; the constant to store

sizeback to summary
public int size()

Implements org.droidparts.dexmaker.dx.rop.cst.ConstantPool.size.

Doc from org.droidparts.dexmaker.dx.rop.cst.ConstantPool.size.

Get the "size" of the constant 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.

Returns:int

>= 1; the size

throwInvalidback to summary
private static Constant throwInvalid(int idx)

Throws the right exception for an invalid cpi.

Parameters
idx:int

the bad cpi

Returns:Constant

never

Exceptions
ExceptionWithContext:
always thrown