/** * {@inheritDoc} */ @Override public void visitLabel(Label label) { super.visitLabel(label); // any label is saved to the handlers set we must add call to beforeCatch // note that these are catch handling blocks so exception is on stack if (handlers.contains(label)) { // duplicate the exception on the stack and call dup(); generateBeforeCatchCall(); } }
/** * {@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); }
/** * {@inheritDoc} */ @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); // only generate the throw in body if exception sensor is active if (enhancedExceptionSensor) { // duplicate exception and call dup(); generateThrowInBodyCall(); } // generate code for calling after // push created object and call // this object or null if's static if (isStatic) { pushNull(); } else { loadThis(); } generateAfterBodyCall(); mv.visitInsn(ATHROW); // update the max stack stuff super.visitMaxs(maxStack, maxLocals); }
/** * {@inheritDoc} */ @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); // only generate the throw in body if exception sensor is active if (enhancedExceptionSensor) { // duplicate exception and call dup(); generateThrowInBodyCall(); } // generate code for calling first and second // push exception as we don't have a result dup(); dup(); // add true booleans to denote exception in the call generateAfterBodyCall("dispatchFirstMethodAfterBody", true); generateAfterBodyCall("dispatchSecondMethodAfterBody", true); mv.visitInsn(ATHROW); // update the max stack stuff super.visitMaxs(maxStack, maxLocals); }