/** * Gets the list of items active at the given address. The result is * automatically made immutable. * * @param pc which address * @return {@code non-null;} list of exception handlers active at * {@code pc} */ public ByteCatchList listFor(int pc) { 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; }
/** * Gets the indicated item. * * @param n {@code >= 0;} which item * @return {@code null-ok;} the indicated item */ public Item get(int n) { return (Item) get0(n); }
/** * Helper method used by all the visitor methods that deal with * opcodes that possibly throw. This method should be called after calling * {@link #visitCommon}. * * @param offset offset to the instruction * @param length length of the instruction, in bytes * @param nextIsLive {@code true} iff the instruction after * the indicated one is possibly-live (because this one isn't an * unconditional throw) */ private void visitThrowing(int offset, int length, boolean nextIsLive) { int next = offset + length; if (nextIsLive) { addWorkIfNecessary(next, true); } ByteCatchList catches = method.getCatches().listFor(offset); catchLists[offset] = catches; targetLists[offset] = catches.toTargetList(nextIsLive ? next : -1); }
/** * Returns a rop-style catches list equivalent to this one. * * @return {@code non-null;} the converted instance */ public TypeList toRopCatchList() { 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; }
ByteCatchList catches = (exceptionTableLength == 0) ? ByteCatchList.EMPTY : new ByteCatchList(exceptionTableLength); int catchTypeIdx = bytes.getUnsignedShort(offset + 6); CstType catchType = (CstType) pool.get0Ok(catchTypeIdx); catches.set(i, startPc, endPc, handlerPc, catchType); if (observer != null) { observer.parsed(bytes, offset, 8, catches.setImmutable();
machine.startBlock(catches.toRopCatchList()); int catchSz = catches.size(); IntList successors = block.getSuccessors(); IntList newSucc = new IntList(succSz); for (int i = 0; i < catchSz; i++) { ByteCatchList.Item one = catches.get(i); CstType exceptionClass = one.getExceptionClass(); int targ = one.getHandlerPc();
/** * 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 {@code >= 2;} the total length, in bytes */ public int byteLength() { return 2 + size() * 8; }
/** * Sets the item at the given index. * * @param n {@code >= 0, < size();} which entry to set * @param item {@code non-null;} the item */ public void set(int n, Item item) { if (item == null) { throw new NullPointerException("item == null"); } set0(n, item); }
@Override public int byteLength() { return 10 + code.byteLength() + catches.byteLength() + attributes.byteLength(); }
if (catches.isMutable()) { throw new MutabilityException("catches.isMutable()");
/** * Returns a rop-style catches list equivalent to this one. * * @return {@code non-null;} the converted instance */ public TypeList toRopCatchList() { 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; }
ByteCatchList catches = (exceptionTableLength == 0) ? ByteCatchList.EMPTY : new ByteCatchList(exceptionTableLength); int catchTypeIdx = bytes.getUnsignedShort(offset + 6); CstType catchType = (CstType) pool.get0Ok(catchTypeIdx); catches.set(i, startPc, endPc, handlerPc, catchType); if (observer != null) { observer.parsed(bytes, offset, 8, catches.setImmutable();
machine.startBlock(catches.toRopCatchList()); int catchSz = catches.size(); IntList successors = block.getSuccessors(); IntList newSucc = new IntList(succSz); for (int i = 0; i < catchSz; i++) { ByteCatchList.Item one = catches.get(i); CstType exceptionClass = one.getExceptionClass(); int targ = one.getHandlerPc();
/** * 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 {@code >= 2;} the total length, in bytes */ public int byteLength() { return 2 + size() * 8; }
/** * Sets the item at the given index. * * @param n {@code >= 0, < size();} which entry to set * @param item {@code non-null;} the item */ public void set(int n, Item item) { if (item == null) { throw new NullPointerException("item == null"); } set0(n, item); }
@Override public int byteLength() { return 10 + code.byteLength() + catches.byteLength() + attributes.byteLength(); }
if (catches.isMutable()) { throw new MutabilityException("catches.isMutable()");
/** * Gets the list of items active at the given address. The result is * automatically made immutable. * * @param pc which address * @return {@code non-null;} list of exception handlers active at * {@code pc} */ public ByteCatchList listFor(int pc) { 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; }
/** * Returns a rop-style catches list equivalent to this one. * * @return {@code non-null;} the converted instance */ public TypeList toRopCatchList() { 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; }
ByteCatchList catches = (exceptionTableLength == 0) ? ByteCatchList.EMPTY : new ByteCatchList(exceptionTableLength); int catchTypeIdx = bytes.getUnsignedShort(offset + 6); CstType catchType = (CstType) pool.get0Ok(catchTypeIdx); catches.set(i, startPc, endPc, handlerPc, catchType); if (observer != null) { observer.parsed(bytes, offset, 8, catches.setImmutable();