/** * {@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); }
/** * Generates before body call. */ private void generateBeforeBodyCall() { // load hook dispatcher loadHookDispatcher(); // first push method id push(methodId); // then this object or null if's static if (isStatic) { pushNull(); } else { loadThis(); } // then parameters loadArgArray(); if (substitutionDescriptor.isParameterValueSubstitution()) { // note here that we are saving the passed array as local variable // this enables us to substitute the parameters later on if they are changed in the // beforeBody passedArgumentsLocal = newLocal(IInstrumenterConstant.OBJECT_ARRAY_TYPE); storeLocal(passedArgumentsLocal); loadLocal(passedArgumentsLocal); } mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, IInstrumenterConstant.IHOOK_DISPATCHER_INTERNAL_NAME, "dispatchSpecialMethodBeforeBody", IInstrumenterConstant.DISPATCH_SPECIAL_METHOD_BEFORE_BODY_DESCRIPTOR, true); }