public Set<String> getSurroundingCaughtExceptions(int pc, int maxTryBlockSize) { HashSet<String> result = new HashSet<>(); if (code == null) { throw new IllegalStateException("Not visiting Code"); } int size = maxTryBlockSize; if (code.getExceptionTable() == null) { return result; } for (CodeException catchBlock : code.getExceptionTable()) { int startPC = catchBlock.getStartPC(); int endPC = catchBlock.getEndPC(); if (pc >= startPC && pc <= endPC) { int thisSize = endPC - startPC; if (size > thisSize) { result.clear(); size = thisSize; result.add("C" + catchBlock.getCatchType()); } else if (size == thisSize) { result.add("C" + catchBlock.getCatchType()); } } } return result; }
public static @CheckForNull CodeException getSurroundingTryBlock(ConstantPool constantPool, Code code, @CheckForNull String vmNameOfExceptionClass, int pc) { int size = Integer.MAX_VALUE; if (code.getExceptionTable() == null) { return null; } CodeException result = null; for (CodeException catchBlock : code.getExceptionTable()) { if (vmNameOfExceptionClass != null) { Constant catchType = constantPool.getConstant(catchBlock.getCatchType()); if (catchType == null && !vmNameOfExceptionClass.isEmpty() || catchType instanceof ConstantClass && !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass)) { continue; } } int startPC = catchBlock.getStartPC(); int endPC = catchBlock.getEndPC(); if (pc >= startPC && pc <= endPC) { int thisSize = endPC - startPC; if (size > thisSize) { size = thisSize; result = catchBlock; } } } return result; }
finallyTargets.put(codeException.getHandlerPC(), block); if(codeException.getStartPC() != codeException.getHandlerPC()) { block.normalBlocks.put(codeException.getStartPC(), codeException.getEndPC());
int pc = redundantBranch.location.getHandle().getPosition(); for (CodeException e : method.getCode().getExceptionTable()) { if (e.getCatchType() == 0 && e.getStartPC() != e.getHandlerPC() && e.getEndPC() <= pc && pc <= e.getEndPC() + 5) { reportIt = false;
int startPC = catchBlock.getStartPC(); int endPC = catchBlock.getEndPC(); if (pc >= startPC && pc <= endPC) {
int start = aExp.getStartPC(); int end = aExp.getEndPC(); int cause = aExp.getCatchType();
ConstantClass cl = (ConstantClass) cp.getConstant(e.getCatchType()); int endPC = e.getEndPC(); int startPC = e.getStartPC(); int handlerPC = e.getHandlerPC(); if (startPC == 0 && endPC + 1 == handlerPC && handlerPC == codeBytes.length - 3
ExceptionCaught caughtException = new ExceptionCaught(name, obj.getStartPC(), obj.getEndPC(), obj.getHandlerPC()); catchList.add(caughtException);
public int getStartPC() { return codeException.getStartPC(); }
TryBlock(CodeException ce) { startPC = ce.getStartPC(); endPC = ce.getEndPC(); handlerPC = ce.getHandlerPC(); endHandlerPC = -1; catchTypes = new BitSet(); catchTypes.set(ce.getCatchType()); state = State.BEFORE; }
TryBlock(CodeException ce) { startPC = ce.getStartPC(); endPC = ce.getEndPC(); handlerPC = ce.getHandlerPC(); endHandlerPC = -1; catchTypes = new BitSet(); catchTypes.set(ce.getCatchType()); state = State.BEFORE; }
public int[] getExceptionScope(){ try { CodeException[] exceptionTable = this.code.getExceptionTable(); int[] exception_scop = new int[exceptionTable.length * 2]; for (int i = 0; i < exceptionTable.length; i++) { exception_scop[i * 2] = exceptionTable[i].getStartPC(); exception_scop[i * 2 + 1] = exceptionTable[i].getEndPC(); } return exception_scop; }catch (Exception e){ // e.printStackTrace(); } return new int[0]; }
/** * collects all the valid exception objects (ones where start and finish are before the target * * @param exs * the exceptions from the class file * @return the filtered exceptions */ public CodeException[] collectExceptions(CodeException... exs) { List<CodeException> filteredEx = new ArrayList<>(); for (CodeException ce : exs) { if ((ce.getCatchType() != 0) && (ce.getStartPC() < ce.getEndPC()) && (ce.getEndPC() <= ce.getHandlerPC())) { filteredEx.add(ce); } } return filteredEx.toArray(new CodeException[filteredEx.size()]); }
/** * collects all the valid exception objects (ones where start and finish are before the target * * @param exs * the exceptions from the class file * @return the filtered exceptions */ public CodeException[] collectExceptions(CodeException... exs) { List<CodeException> filteredEx = new ArrayList<>(); for (CodeException ce : exs) { if ((ce.getCatchType() != 0) && (ce.getStartPC() < ce.getEndPC()) && (ce.getEndPC() <= ce.getHandlerPC())) { filteredEx.add(ce); } } return filteredEx.toArray(new CodeException[0]); }
/** * Initialize from another object. */ public CodeException(CodeException c) { this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); }
/** * Initialize from another object. */ public CodeException(final CodeException c) { this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); }
/** * returns the catch handler for a given try block * * @param pc * the current instruction * @return the pc of the handler for this pc if it's the start of a try block, or -1 * */ private int findCatchHandlerFor(int pc) { CodeException[] exceptions = getMethod().getCode().getExceptionTable(); if (exceptions != null) { for (CodeException ex : exceptions) { if (ex.getStartPC() == pc) { return ex.getHandlerPC(); } } } return -1; }
/** * returns the catch handler for a given try block * * @param pc * the current instruction * @return the pc of the handler for this pc if it's the start of a try block, or -1 * */ private int findCatchHandlerFor(int pc) { CodeException[] exceptions = getMethod().getCode().getExceptionTable(); if (exceptions != null) { for (CodeException ex : exceptions) { if (ex.getStartPC() == pc) { return ex.getHandlerPC(); } } } return -1; }
private boolean prescreen(Code obj) { if (getMethod().isNative()) { return false; } CodeException[] ces = obj.getExceptionTable(); if (CollectionUtils.isEmpty(ces)) { return false; } boolean hasFinally = false; for (CodeException ce : ces) { if (ce.getCatchType() == 0) { finallyBlocks.put(Integer.valueOf(ce.getHandlerPC()), new TryBlock(ce.getStartPC(), ce.getEndPC(), ce.getHandlerPC(), obj.getCode().length - 1)); hasFinally = true; } } return hasFinally; }
public CodeEntry(Code c) { super(c.getNameIndex(), c.getLength()); maxStack = c.getMaxStack(); maxLocals = c.getMaxLocals(); code = c.getCode(); for (CodeException i : c.getExceptionTable()) { exceptionPoolEntries.add(new ExceptionPoolEntry(i.getStartPC(), i.getEndPC(), i.getHandlerPC(), i.getCatchType())); } codeEntryAttributePool = new AttributePool(c.getAttributes(), getName()); }