Methods Summary |
---|
public Constant | get(int n){@inheritDoc}
try {
Constant result = entries[n];
if (result == null) {
throwInvalid(n);
}
return result;
} catch (IndexOutOfBoundsException ex) {
// Translate the exception.
return throwInvalid(n);
}
|
public Constant | get0Ok(int n){@inheritDoc}
if (n == 0) {
return null;
}
return get(n);
|
public Constant | getOrNull(int n){@inheritDoc}
try {
return entries[n];
} catch (IndexOutOfBoundsException ex) {
// Translate the exception.
return throwInvalid(n);
}
|
public void | set(int n, Constant cst)Sets the entry at the given index.
throwIfImmutable();
boolean cat2 = (cst != null) && cst.isCategory2();
if (n < 1) {
throw new IllegalArgumentException("n < 1");
}
if (cat2) {
// Storing a category-2 entry nulls out the next index.
if (n == (entries.length - 1)) {
throw new IllegalArgumentException("(n == size - 1) && " +
"cst.isCategory2()");
}
entries[n + 1] = null;
}
if ((cst != null) && (entries[n] == null)) {
/*
* Overwriting the second half of a category-2 entry nulls out
* the first half.
*/
Constant prev = entries[n - 1];
if ((prev != null) && prev.isCategory2()) {
entries[n - 1] = null;
}
}
entries[n] = cst;
|
public int | size(){@inheritDoc}
return entries.length;
|
private static Constant | throwInvalid(int idx)Throws the right exception for an invalid cpi.
throw new ExceptionWithContext("invalid constant pool index " +
Hex.u2(idx));
|