/** * 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); }
int local = newLocal(IInstrumenterConstant.OBJECT_TYPE); storeLocal(local);
/** * Generates call for returning result on stack if needed. */ private void generateReturnIfResultNotNull() { // create new local and store result int local = newLocal(IInstrumenterConstant.OBJECT_TYPE); storeLocal(local); Label continueExecution = new Label(); // then load for null check loadLocal(local); ifNull(continueExecution); // we can only return result if return type is not Void if (!Type.VOID_TYPE.equals(returnType)) { // then load for instance of check if it's an object loadLocal(local); instanceOfSafe(returnType); // if zero compare // we compare the result of the instance of check with the 0 // so we will continue execution if the result is false (0) ifZCmp(EQ, continueExecution); // load again for return loadLocal(local); // we need to unbox here if needed as we are changing the result unbox(returnType); } // if method returned something, anyway return (also on void) returnValue(); visitLabel(continueExecution); }