diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java b/byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java index 3371c8ce4f0..3cb43ab1a81 100644 --- a/byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java +++ b/byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java @@ -4457,22 +4457,19 @@ protected abstract ForInstrumentedMethod resolve(MethodDescription instrumentedM */ public interface PostProcessor { - /** - * Indicates that an advice method has no return value stored at a given offset. - */ - int NO_RETURN = -1; - /** * Resolves this post processor for a given instrumented method. * * @param instrumentedType The instrumented type. * @param instrumentedMethod The instrumented method. * @param assigner The assigner to use. - * @param offset The offset that stores the advice method's return value or {@link PostProcessor#NO_RETURN} - * if the advice method does not return a value. + * @param argumentHandler The argument handler for the instrumented method. * @return The stack manipulation to apply. */ - StackManipulation resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, int offset); + StackManipulation resolve(TypeDescription instrumentedType, + MethodDescription instrumentedMethod, + Assigner assigner, + ArgumentHandler argumentHandler); /** * A factory for creating a {@link PostProcessor}. @@ -4550,7 +4547,10 @@ enum NoOp implements PostProcessor, Factory { /** * {@inheritDoc} */ - public StackManipulation resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, int offset) { + public StackManipulation resolve(TypeDescription instrumentedType, + MethodDescription instrumentedMethod, + Assigner assigner, + ArgumentHandler argumentHandler) { return StackManipulation.Trivial.INSTANCE; } @@ -4585,10 +4585,13 @@ protected Compound(List postProcessors) { /** * {@inheritDoc} */ - public StackManipulation resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, int offset) { + public StackManipulation resolve(TypeDescription instrumentedType, + MethodDescription instrumentedMethod, + Assigner assigner, + ArgumentHandler argumentHandler) { List stackManipulations = new ArrayList(postProcessors.size()); for (PostProcessor postProcessor : postProcessors) { - stackManipulations.add(postProcessor.resolve(instrumentedType, instrumentedMethod, assigner, offset)); + stackManipulations.add(postProcessor.resolve(instrumentedType, instrumentedMethod, assigner, argumentHandler)); } return new StackManipulation.Compound(stackManipulations); } @@ -8705,9 +8708,9 @@ public void visitEnd() { } methodSizeHandler.requireStackSize(relocationHandler.apply(methodVisitor, getReturnValueOffset())); stackMapFrameHandler.injectCompletionFrame(methodVisitor); - methodSizeHandler.recordMaxima(postProcessor.resolve(instrumentedType, instrumentedMethod, assigner, adviceMethod.getReturnType().represents(void.class) - ? PostProcessor.NO_RETURN - : getReturnValueOffset()).apply(mv, implementationContext).getMaximalSize(), EMPTY); + methodSizeHandler.recordMaxima(postProcessor + .resolve(instrumentedType, instrumentedMethod, assigner, argumentHandler) + .apply(mv, implementationContext).getMaximalSize(), EMPTY); } @Override @@ -9178,9 +9181,9 @@ public void apply() { methodSizeHandler.requireStackSize(relocationHandler.apply(methodVisitor, getReturnValueOffset())); stackMapFrameHandler.injectCompletionFrame(methodVisitor); methodSizeHandler.recordMaxima(Math.max(maximumStackSize, adviceMethod.getReturnType().getStackSize().getSize()), EMPTY); - methodSizeHandler.recordMaxima(postProcessor.resolve(instrumentedType, instrumentedMethod, assigner, adviceMethod.getReturnType().represents(void.class) - ? PostProcessor.NO_RETURN - : getReturnValueOffset()).apply(methodVisitor, implementationContext).getMaximalSize(), EMPTY); + methodSizeHandler.recordMaxima(postProcessor + .resolve(instrumentedType, instrumentedMethod, assigner, argumentHandler) + .apply(methodVisitor, implementationContext).getMaximalSize(), EMPTY); } /**