/** * Generates code for the after body call. This method expects the result of the method call on * the stack that can be consumed. * * @param method * method to be called can be only * {@link IHookDispatcher#dispatchFirstMethodAfterBody(long, Object, Object[], Object, boolean)} * or * {@link IHookDispatcher#dispatchSecondMethodAfterBody(long, Object, Object[], Object, boolean)} * @param exception * Value of the exception argument pass to the dispatcher. */ private void generateAfterBodyCall(String method, boolean exception) { // prepare first everything up to exception boolean prepareAfterBodyCall(); // then push on stack info about exception push(exception); // execute after body mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, IInstrumenterConstant.IHOOK_DISPATCHER_INTERNAL_NAME, method, IInstrumenterConstant.DISPATCH_METHOD_AFTER_BODY_DESCRIPTOR, true); }
/** * 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(); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, IInstrumenterConstant.IHOOK_DISPATCHER_INTERNAL_NAME, "dispatchMethodBeforeBody", IInstrumenterConstant.DISPATCH_METHOD_BEFORE_BODY_DESCRIPTOR, true); }
push(methodId);
/** * {@inheritDoc} * <p> * Generates call for {@link IHookDispatcher#dispatchBeforeCatch(long, Object)}. This method * expects exception object on stack that can be consumed. */ @Override protected void generateBeforeCatchCall() { // prepare for calls // we expect exception on stack so we must swap as exception is last argument in the call loadHookDispatcher(); swap(); // first push method id push(methodId); // can not just swap because method id is long, thus a bit of gymnastic // r-l-l2 dup2X1(); // l-l2-r-l-l2 pop2(); // l-l2-r :) // execute before catch mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, IInstrumenterConstant.IHOOK_DISPATCHER_INTERNAL_NAME, "dispatchBeforeCatch", IInstrumenterConstant.DISPATCH_BEFORE_CATCH_DESCRIPTOR, true); }