/** * Generates call for {@link IHookDispatcher#dispatchConstructorBeforeCatch(long, Object)}. * Expects caught exception on the 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, "dispatchConstructorBeforeCatch", IInstrumenterConstant.DISPATCH_CONSTRUCTOR_BEFORE_CATCH_DESCRIPTOR, true); }
/** * Generates code for calling * {@link IHookDispatcher#dispatchConstructorAfterBody(long, Object, Object[])}. This method * expect that created instance is on the stack and can be consumed. */ private void generateAfterBodyCall() { // prepare for calls // we expect created object on stack so we must swap as object is argument after method id // 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 :) // then parameters, no need to swap loadArgArray(); // execute after body mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, IInstrumenterConstant.IHOOK_DISPATCHER_INTERNAL_NAME, "dispatchConstructorAfterBody", IInstrumenterConstant.DISPATCH_CONSTRUCTOR_AFTER_BODY_DESCRIPTOR, true); }