Package net.bytebuddy.asm
Class Advice.MethodSizeHandler.Default
- java.lang.Object
-
- net.bytebuddy.asm.Advice.MethodSizeHandler.Default
-
- All Implemented Interfaces:
Advice.MethodSizeHandler
,Advice.MethodSizeHandler.ForInstrumentedMethod
- Direct Known Subclasses:
Advice.MethodSizeHandler.Default.WithCopiedArguments
,Advice.MethodSizeHandler.Default.WithRetainedArguments
- Enclosing interface:
- Advice.MethodSizeHandler
public abstract static class Advice.MethodSizeHandler.Default extends java.lang.Object implements Advice.MethodSizeHandler.ForInstrumentedMethod
A default implementation for a method size handler.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Advice.MethodSizeHandler.Default.ForAdvice
A method size handler for an advice method.protected static class
Advice.MethodSizeHandler.Default.WithCopiedArguments
A method size handler that expects that the original arguments were copied.protected static class
Advice.MethodSizeHandler.Default.WithRetainedArguments
A method size handler that expects that the original arguments are retained.-
Nested classes/interfaces inherited from interface net.bytebuddy.asm.Advice.MethodSizeHandler
Advice.MethodSizeHandler.Default, Advice.MethodSizeHandler.ForInstrumentedMethod, Advice.MethodSizeHandler.NoOp
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<? extends TypeDescription>
enterTypes
A list of virtual method arguments that are available before the instrumented method is executed.protected java.util.List<? extends TypeDescription>
exitTypes
A list of virtual method arguments that are available after the instrumented method has completed.protected MethodDescription
instrumentedMethod
The instrumented method.protected int
localVariableLength
The maximum length of the local variable array required by a visited advice method.protected int
stackSize
The maximum stack size required by a visited advice method.-
Fields inherited from interface net.bytebuddy.asm.Advice.MethodSizeHandler
UNDEFINED_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Default(MethodDescription instrumentedMethod, java.util.List<? extends TypeDescription> enterTypes, java.util.List<? extends TypeDescription> exitTypes)
Creates a new default meta data handler that recomputes the space requirements of an instrumented method.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Advice.MethodSizeHandler.ForAdvice
bindEnter(MethodDescription.InDefinedShape adviceMethod)
Binds a method size handler for the enter advice.Advice.MethodSizeHandler.ForAdvice
bindExit(MethodDescription.InDefinedShape adviceMethod, boolean skipThrowable)
Binds the method size handler for the exit advice.int
compoundLocalVariableLength(int localVariableLength)
Computes a compound local variable array length for the advice and the translated instrumented method.int
compoundStackSize(int stackSize)
Computes a compound stack size for the advice and the translated instrumented method.protected static Advice.MethodSizeHandler.ForInstrumentedMethod
of(MethodDescription instrumentedMethod, java.util.List<? extends TypeDescription> enterTypes, java.util.List<? extends TypeDescription> exitTypes, boolean copyArguments, int writerFlags)
Creates a method size handler applicable for the given instrumented method.void
requireLocalVariableLength(int localVariableLength)
Requires a minimum length of the local variable array.void
requireStackSize(int stackSize)
Records a minimum stack size required by the represented advice method.
-
-
-
Field Detail
-
instrumentedMethod
protected final MethodDescription instrumentedMethod
The instrumented method.
-
enterTypes
protected final java.util.List<? extends TypeDescription> enterTypes
A list of virtual method arguments that are available before the instrumented method is executed.
-
exitTypes
protected final java.util.List<? extends TypeDescription> exitTypes
A list of virtual method arguments that are available after the instrumented method has completed.
-
stackSize
protected int stackSize
The maximum stack size required by a visited advice method.
-
localVariableLength
protected int localVariableLength
The maximum length of the local variable array required by a visited advice method.
-
-
Constructor Detail
-
Default
protected Default(MethodDescription instrumentedMethod, java.util.List<? extends TypeDescription> enterTypes, java.util.List<? extends TypeDescription> exitTypes)
Creates a new default meta data handler that recomputes the space requirements of an instrumented method.- Parameters:
instrumentedMethod
- The instrumented method.enterTypes
- A list of virtual method arguments that are available before the instrumented method is executed.exitTypes
- A list of virtual method arguments that are available after the instrumented method has completed.
-
-
Method Detail
-
of
protected static Advice.MethodSizeHandler.ForInstrumentedMethod of(MethodDescription instrumentedMethod, java.util.List<? extends TypeDescription> enterTypes, java.util.List<? extends TypeDescription> exitTypes, boolean copyArguments, int writerFlags)
Creates a method size handler applicable for the given instrumented method.- Parameters:
instrumentedMethod
- The instrumented method.enterTypes
- A list of virtual method arguments that are available before the instrumented method is executed.exitTypes
- A list of virtual method arguments that are available after the instrumented method has completed.copyArguments
-true
if the original arguments are copied before invoking the instrumented method.writerFlags
- The flags supplied to the ASM class writer.- Returns:
- An appropriate method size handler.
-
bindEnter
public Advice.MethodSizeHandler.ForAdvice bindEnter(MethodDescription.InDefinedShape adviceMethod)
Description copied from interface:Advice.MethodSizeHandler.ForInstrumentedMethod
Binds a method size handler for the enter advice.- Specified by:
bindEnter
in interfaceAdvice.MethodSizeHandler.ForInstrumentedMethod
- Parameters:
adviceMethod
- The method representing the enter advice.- Returns:
- A method size handler for the enter advice.
-
bindExit
public Advice.MethodSizeHandler.ForAdvice bindExit(MethodDescription.InDefinedShape adviceMethod, boolean skipThrowable)
Description copied from interface:Advice.MethodSizeHandler.ForInstrumentedMethod
Binds the method size handler for the exit advice.- Specified by:
bindExit
in interfaceAdvice.MethodSizeHandler.ForInstrumentedMethod
- Parameters:
adviceMethod
- The method representing the exit advice.skipThrowable
-true
if the exit advice is not invoked on an exception.- Returns:
- A method size handler for the exit advice.
-
compoundStackSize
public int compoundStackSize(int stackSize)
Description copied from interface:Advice.MethodSizeHandler.ForInstrumentedMethod
Computes a compound stack size for the advice and the translated instrumented method.- Specified by:
compoundStackSize
in interfaceAdvice.MethodSizeHandler.ForInstrumentedMethod
- Parameters:
stackSize
- The required stack size of the instrumented method before translation.- Returns:
- The stack size required by the instrumented method and its advice methods.
-
compoundLocalVariableLength
public int compoundLocalVariableLength(int localVariableLength)
Description copied from interface:Advice.MethodSizeHandler.ForInstrumentedMethod
Computes a compound local variable array length for the advice and the translated instrumented method.- Specified by:
compoundLocalVariableLength
in interfaceAdvice.MethodSizeHandler.ForInstrumentedMethod
- Parameters:
localVariableLength
- The required local variable array length of the instrumented method before translation.- Returns:
- The local variable length required by the instrumented method and its advice methods.
-
requireStackSize
public void requireStackSize(int stackSize)
Description copied from interface:Advice.MethodSizeHandler
Records a minimum stack size required by the represented advice method.- Specified by:
requireStackSize
in interfaceAdvice.MethodSizeHandler
- Parameters:
stackSize
- The minimum size required by the represented advice method.
-
requireLocalVariableLength
public void requireLocalVariableLength(int localVariableLength)
Description copied from interface:Advice.MethodSizeHandler
Requires a minimum length of the local variable array.- Specified by:
requireLocalVariableLength
in interfaceAdvice.MethodSizeHandler
- Parameters:
localVariableLength
- The minimal required length of the local variable array.
-
-