private void build(MethodGen methodGen) { CodeExceptionGen[] handlerList = methodGen.getExceptionHandlers(); // Map handler start instructions to the actual exception handlers for (CodeExceptionGen exceptionHandler : handlerList) { addExceptionHandler(exceptionHandler); } // For each instruction, determine which handlers it can reach InstructionHandle handle = methodGen.getInstructionList().getStart(); while (handle != null) { int offset = handle.getPosition(); handlerLoop: for (CodeExceptionGen exceptionHandler : handlerList) { int startOfRange = exceptionHandler.getStartPC().getPosition(); int endOfRange = exceptionHandler.getEndPC().getPosition(); if (offset >= startOfRange && offset <= endOfRange) { // This handler is reachable from the instruction addHandler(handle, exceptionHandler); // If this handler handles all exception types // i.e., an ANY handler, or catch(Throwable...), // then no further (lower-priority) // handlers are reachable from the instruction. if (Hierarchy.isUniversalExceptionHandler(exceptionHandler.getCatchType())) { break handlerLoop; } } } handle = handle.getNext(); } }
/** * Computes max. stack size by performing control flow analysis. */ public void setMaxStack() { if(il != null) max_stack = getMaxStack(cp, il, getExceptionHandlers()); else max_stack = 0; }
/** * Computes max. stack size by performing control flow analysis. */ public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { max_stack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); } else { max_stack = 0; } }
/** * Constructor. Creates a new ExceptionHandlers instance. */ public ExceptionHandlers(MethodGen mg){ exceptionhandlers = new Hashtable(); CodeExceptionGen[] cegs = mg.getExceptionHandlers(); for (int i=0; i<cegs.length; i++){ ExceptionHandler eh = new ExceptionHandler(cegs[i].getCatchType(), cegs[i].getHandlerPC()); for (InstructionHandle ih=cegs[i].getStartPC(); ih != cegs[i].getEndPC().getNext(); ih=ih.getNext()){ HashSet hs; hs = (HashSet) exceptionhandlers.get(ih); if (hs == null){ hs = new HashSet(); exceptionhandlers.put(ih, hs); } hs.add(eh); } } }
/** * Constructor. Creates a new ExceptionHandlers instance. */ public ExceptionHandlers(final MethodGen mg) { exceptionhandlers = new HashMap<>(); final CodeExceptionGen[] cegs = mg.getExceptionHandlers(); for (final CodeExceptionGen ceg : cegs) { final ExceptionHandler eh = new ExceptionHandler(ceg.getCatchType(), ceg.getHandlerPC()); for (InstructionHandle ih=ceg.getStartPC(); ih != ceg.getEndPC().getNext(); ih=ih.getNext()) { Set<ExceptionHandler> hs; hs = exceptionhandlers.get(ih); if (hs == null) { hs = new HashSet<>(); exceptionhandlers.put(ih, hs); } hs.add(eh); } } }
private void updateExceptionHandlers() { final CodeExceptionGen[] handlers = _mg.getExceptionHandlers(); for (final CodeExceptionGen h : handlers) { final String type = (h.getCatchType() == null) ? "null" : BCELifier.printType(h .getCatchType()); _out.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + ", " + "ih_" + h.getEndPC().getPosition() + ", " + "ih_" + h.getHandlerPC().getPosition() + ", " + type + ");"); } } }
CodeExceptionGen[] handlers = mg.getExceptionHandlers();
private void updateExceptionHandlers() { CodeExceptionGen[] handlers = _mg.getExceptionHandlers(); for(int i=0; i < handlers.length; i++) { CodeExceptionGen h = handlers[i]; String type = (h.getCatchType() == null)? "null" : BCELifier.printType(h.getCatchType()); _out.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + ", " + "ih_" + h.getEndPC().getPosition() + ", " + "ih_" + h.getHandlerPC().getPosition() + ", " + type + ");"); } } }
final CodeExceptionGen[] handlers = mg.getExceptionHandlers();
private void build(MethodGen methodGen) { CodeExceptionGen[] handlerList = methodGen.getExceptionHandlers(); // Map handler start instructions to the actual exception handlers for (CodeExceptionGen exceptionHandler : handlerList) { addExceptionHandler(exceptionHandler); } // For each instruction, determine which handlers it can reach InstructionHandle handle = methodGen.getInstructionList().getStart(); while (handle != null) { int offset = handle.getPosition(); handlerLoop: for (CodeExceptionGen exceptionHandler : handlerList) { int startOfRange = exceptionHandler.getStartPC().getPosition(); int endOfRange = exceptionHandler.getEndPC().getPosition(); if (offset >= startOfRange && offset <= endOfRange) { // This handler is reachable from the instruction addHandler(handle, exceptionHandler); // If this handler handles all exception types // i.e., an ANY handler, or catch(Throwable...), // then no further (lower-priority) // handlers are reachable from the instruction. if (Hierarchy.isUniversalExceptionHandler(exceptionHandler.getCatchType())) { break handlerLoop; } } } handle = handle.getNext(); } }
InstructionList list = mgen.getInstructionList(); InstructionFinder finder = new InstructionFinder(list); CodeExceptionGen[] exceptionGens = mgen.getExceptionHandlers(); for (Iterator<InstructionHandle[]> matches = finder.search( "ASTORE ALOAD (NEW DUP (PushInstruction InvokeInstruction)+ (ALOAD IfInstruction LDC GOTO LDC " +
String outlinedMethodName, ClassGenerator classGen) { if (getExceptionHandlers().length != 0) { String msg = (new ErrorMsg(ErrorMsg.OUTLINE_ERR_TRY_CATCH)) .toString();
String outlinedMethodName, ClassGenerator classGen) { if (getExceptionHandlers().length != 0) { String msg = (new ErrorMsg(ErrorMsg.OUTLINE_ERR_TRY_CATCH)) .toString();
InstructionList list = mgen.getInstructionList(); InstructionFinder finder = new InstructionFinder(list); CodeExceptionGen[] exceptionGens = mgen.getExceptionHandlers(); for (Iterator<InstructionHandle[]> matches = finder.search( "ASTORE ALOAD (NEW DUP (PushInstruction InvokeInstruction)+ (ALOAD IfInstruction LDC GOTO LDC " +