public static String getExceptionSig(DismantleBytecode dbc, CodeException e) { if (e.getCatchType() == 0) { return "Ljava/lang/Throwable;"; } Constant c = dbc.getConstantPool().getConstant(e.getCatchType()); if (c instanceof ConstantClass) { return "L" + ((ConstantClass) c).getBytes(dbc.getConstantPool()) + ";"; } return "Ljava/lang/Throwable;"; }
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; }
@Override public void visit(CodeException obj) { int type = obj.getCatchType(); if (type == 0) { return; } String name = getConstantPool().constantToString(getConstantPool().getConstant(type)); if (DEBUG) { String msg = "Catching " + name + " in " + getFullyQualifiedMethodName(); if (msgs.add(msg)) { System.out.println(msg); } } if ("java.lang.IllegalMonitorStateException".equals(name)) { bugReporter.reportBug(new BugInstance(this, "IMSE_DONT_CATCH_IMSE", HIGH_PRIORITY).addClassAndMethod(this) .addSourceLine(this.classContext, this, obj.getHandlerPC())); } }
if (e.getCatchType() == 0) { int pc = e.getHandlerPC(); firstHandler = Math.min(firstHandler, pc);
Map<Integer, TryBlock> finallyTargets = new LinkedHashMap<>(); for(CodeException codeException : method.getCode().getExceptionTable()) { if(codeException.getCatchType() == 0) { TryBlock block = finallyTargets.get(codeException.getHandlerPC()); if(block == null) {
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;
private boolean uniqueLocations(Collection<Location> derefLocationSet) { boolean uniqueDereferenceLocations = false; CodeException[] exceptionTable = method.getCode().getExceptionTable(); if (exceptionTable == null) { return true; } checkForCatchAll: { for (CodeException e : exceptionTable) { if (e.getCatchType() == 0) { break checkForCatchAll; } } return true; } LineNumberTable table = method.getLineNumberTable(); if (table == null) { uniqueDereferenceLocations = true; } else { BitSet linesMentionedMultipleTimes = classContext.linesMentionedMultipleTimes(method); for (Location loc : derefLocationSet) { int lineNumber = table.getSourceLine(loc.getHandle().getPosition()); if (lineNumber > 0 && !linesMentionedMultipleTimes.get(lineNumber)) { uniqueDereferenceLocations = true; } } } return uniqueDereferenceLocations; }
Constant catchType = constantPool.getConstant(catchBlock.getCatchType()); if (catchType == null && !vmNameOfExceptionClass.isEmpty() || catchType instanceof ConstantClass && !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass)) {
int start = aExp.getStartPC(); int end = aExp.getEndPC(); int cause = aExp.getCatchType(); boolean exitInTryBlock = false; if (DEBUG) {
if(ex.getCatchType() == 0) { finallyTargets.add(ex.getHandlerPC());
continue; int catchTypeIndex = handler.getCatchType(); if (catchTypeIndex > 0) { ConstantPool cp = getThisClass().getConstantPool();
byte codeBytes[] = code.getCode(); for (CodeException e : code.getExceptionTable()) { ConstantClass cl = (ConstantClass) cp.getConstant(e.getCatchType()); int endPC = e.getEndPC(); int startPC = e.getStartPC();
try { super.visit(obj); int type = obj.getCatchType(); if (type == 0) { return;
public Type getCatchType(ConstantPool cp) { if (codeException.getCatchType() == 0) return null; String signature= cp.getConstantString(codeException.getCatchType(), Constants.CONSTANT_Class); return Type.getType("L" + signature + ";"); }
public static String getExceptionSig(DismantleBytecode dbc, CodeException e) { if (e.getCatchType() == 0) { return "Ljava/lang/Throwable;"; } Constant c = dbc.getConstantPool().getConstant(e.getCatchType()); if (c instanceof ConstantClass) { return "L" + ((ConstantClass) c).getBytes(dbc.getConstantPool()) + ";"; } return "Ljava/lang/Throwable;"; }
TryBlock(CodeException ce) { startPC = ce.getStartPC(); endPC = ce.getEndPC(); handlerPC = ce.getHandlerPC(); endHandlerPC = -1; catchTypes = new BitSet(); catchTypes.set(ce.getCatchType()); state = State.BEFORE; }
/** * 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()); }
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()); }