Methods Summary |
---|
public int | byteLength()Gets the total length of this structure in bytes, when included in
a {@code Code} attribute. The returned value includes the
two bytes for {@code exception_table_length}.
return 2 + size() * 8;
|
public com.android.dx.cf.code.ByteCatchList$Item | get(int n)Gets the indicated item.
return (Item) get0(n);
|
public com.android.dx.cf.code.ByteCatchList | listFor(int pc)Gets the list of items active at the given address. The result is
automatically made immutable.
int sz = size();
Item[] resultArr = new Item[sz];
int resultSz = 0;
for (int i = 0; i < sz; i++) {
Item one = get(i);
if (one.covers(pc) && typeNotFound(one, resultArr, resultSz)) {
resultArr[resultSz] = one;
resultSz++;
}
}
if (resultSz == 0) {
return EMPTY;
}
ByteCatchList result = new ByteCatchList(resultSz);
for (int i = 0; i < resultSz; i++) {
result.set(i, resultArr[i]);
}
result.setImmutable();
return result;
|
public void | set(int n, com.android.dx.cf.code.ByteCatchList$Item item)Sets the item at the given index.
if (item == null) {
throw new NullPointerException("item == null");
}
set0(n, item);
|
public void | set(int n, int startPc, int endPc, int handlerPc, com.android.dx.rop.cst.CstType exceptionClass)Sets the item at the given index.
set0(n, new Item(startPc, endPc, handlerPc, exceptionClass));
|
public com.android.dx.rop.type.TypeList | toRopCatchList()Returns a rop-style catches list equivalent to this one.
int sz = size();
if (sz == 0) {
return StdTypeList.EMPTY;
}
StdTypeList result = new StdTypeList(sz);
for (int i = 0; i < sz; i++) {
result.set(i, get(i).getExceptionClass().getClassType());
}
result.setImmutable();
return result;
|
public com.android.dx.util.IntList | toTargetList(int noException)Returns a target list corresponding to this instance. The result
is a list of all the exception handler addresses, with the given
{@code noException} address appended if appropriate. The
result is automatically made immutable.
if (noException < -1) {
throw new IllegalArgumentException("noException < -1");
}
boolean hasDefault = (noException >= 0);
int sz = size();
if (sz == 0) {
if (hasDefault) {
/*
* The list is empty, but there is a no-exception
* address; so, the result is just that address.
*/
return IntList.makeImmutable(noException);
}
/*
* The list is empty and there isn't even a no-exception
* address.
*/
return IntList.EMPTY;
}
IntList result = new IntList(sz + (hasDefault ? 1 : 0));
for (int i = 0; i < sz; i++) {
result.add(get(i).getHandlerPc());
}
if (hasDefault) {
result.add(noException);
}
result.setImmutable();
return result;
|
private static boolean | typeNotFound(com.android.dx.cf.code.ByteCatchList$Item item, com.android.dx.cf.code.ByteCatchList$Item[] arr, int count)Helper method for {@link #listFor}, which tells whether a match
is not found for the exception type of the given item in
the given array. A match is considered to be either an exact type
match or the class {@code Object} which represents a catch-all.
CstType type = item.getExceptionClass();
for (int i = 0; i < count; i++) {
CstType one = arr[i].getExceptionClass();
if ((one == type) || (one == CstType.OBJECT)) {
return false;
}
}
return true;
|