/** * {@inheritDoc} */ @Override protected void onMethodExit(int opcode) { // we wont add any byte-code prior to athrow return // if exception is thrown we will execute calls in the finally block we are adding if (opcode == ATHROW) { // exception return return; } // after constructor we can load this object // just load on stack and generate call // this object or null if's static if (isStatic) { pushNull(); } else { loadThis(); } // generate code for calling first and second generateAfterBodyCall(); }
/** * {@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); }
pushNull(); } else { loadThis();