/** * {@inheritDoc} * <p> * Here we add code to catch the unexpected exception that can occur during method execution and * notify our hooks about it. We are sending the raised exception as the result of the method * invocation. */ @Override public void visitMaxs(int maxStack, int maxLocals) { // the definition of the end of the try block Label tryBlockEnd = new Label(); visitLabel(tryBlockEnd); // setup for the finally block super.visitTryCatchBlock(tryBlockStart, tryBlockEnd, finallyHandler, null); visitLabel(finallyHandler); // generate code for calling after body // push exception on the stack and pass to after body call as the result dup(); generateAfterBodyCall(); // we can not substitute the result when exception is thrown just pop pop(); mv.visitInsn(ATHROW); // update the max stack stuff super.visitMaxs(maxStack, maxLocals); }