loadLocal(passedArgumentsLocal); push(index); arrayLoad(IInstrumenterConstant.OBJECT_TYPE); int local = newLocal(IInstrumenterConstant.OBJECT_TYPE); storeLocal(local); loadLocal(local); instanceOfSafe(type); ifZCmp(EQ, continueExecution); loadLocal(local); unbox(type); storeArg(index); visitLabel(continueExecution);
pushNull(); } else if (opcode == ARETURN) { dup(); } else { dup2(); } else { dup(); box(returnType); generateAfterBodyCall(); generateReturnIfResultNotNull(); } else { pop();
loadHookDispatcher(); swap(); push(methodId); dup2X1(); pop2(); pushNull(); } else { loadThis(); swap(); loadArgArray(); swap();
/** * {@inheritDoc} */ @Override protected void onMethodEnter() { // generate code for calling before body generateBeforeBodyCall(); if (substitutionDescriptor.isReturnValueSubstitution()) { // and code for returning if result is not null generateReturnIfResultNotNull(); } else { // pop to clear result on stack pop(); } if (substitutionDescriptor.isParameterValueSubstitution()) { // add code for substituting the parameter generateParameterSubstitutionIfResultNotNull(); } // start our try block visitLabel(tryBlockStart); }
/** * {@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); }
return new SpecialMethodInstrumenter(superMethodVisitor, access, name, desc, specialInstrumentationPoint.getId(), specialInstrumentationPoint.getSubstitutionDescriptor());