Package net.bytebuddy.asm
Class Advice.StackMapFrameHandler.Default
- java.lang.Object
-
- net.bytebuddy.asm.Advice.StackMapFrameHandler.Default
-
- All Implemented Interfaces:
Advice.StackMapFrameHandler
,Advice.StackMapFrameHandler.ForInstrumentedMethod
- Enclosing interface:
- Advice.StackMapFrameHandler
public static class Advice.StackMapFrameHandler.Default extends java.lang.Object implements Advice.StackMapFrameHandler.ForInstrumentedMethod
A default implementation of a stack map frame handler for an instrumented method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Advice.StackMapFrameHandler.Default.ForAdvice
A stack map frame handler for an advice method.protected static class
Advice.StackMapFrameHandler.Default.TranslationMode
A translation mode that determines how the fixed frames of the instrumented method are written.-
Nested classes/interfaces inherited from interface net.bytebuddy.asm.Advice.StackMapFrameHandler
Advice.StackMapFrameHandler.Default, Advice.StackMapFrameHandler.ForInstrumentedMethod, Advice.StackMapFrameHandler.NoOp
-
-
Field Summary
Fields Modifier and Type Field Description protected TypeList
enterTypes
A list of virtual method arguments that are available before the instrumented method is executed.protected TypeList
exitTypes
A list of virtual method arguments that are available after the instrumented method has completed.protected MethodDescription
instrumentedMethod
The instrumented method.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Default(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypeList enterTypes, TypeList exitTypes, boolean expandFrames)
Creates a new default meta data handler.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Advice.StackMapFrameHandler.ForAdvice
bindEntry(MethodDescription.InDefinedShape adviceMethod)
Binds this meta data handler for the entry advice.Advice.StackMapFrameHandler.ForAdvice
bindExit(MethodDescription.InDefinedShape adviceMethod)
Binds this meta data handler for the exit advice.int
getReaderHint()
Returns a hint to supply to aClassReader
when parsing an advice method.void
injectCompletionFrame(org.objectweb.asm.MethodVisitor methodVisitor, boolean secondary)
Injects a frame indicating the completion of the currently handled method, i.e.void
injectExceptionFrame(org.objectweb.asm.MethodVisitor methodVisitor)
Injects a frame indicating the beginning of an exception handler for the currently handled method.protected void
injectFullFrame(org.objectweb.asm.MethodVisitor methodVisitor, java.util.List<? extends TypeDescription> typesInArray, java.util.List<? extends TypeDescription> typesOnStack)
Injects a full stack map frame.void
injectReturnFrame(org.objectweb.asm.MethodVisitor methodVisitor)
Injects a frame indicating the beginning of a return value handler for the currently handled method.protected static Advice.StackMapFrameHandler.ForInstrumentedMethod
of(TypeDescription instrumentedType, MethodDescription instrumentedMethod, java.util.List<? extends TypeDescription> enterTypes, java.util.List<? extends TypeDescription> exitTypes, ClassFileVersion classFileVersion, int writerFlags, int readerFlags)
Creates an appropriate stack map frame handler for an instrumented method.protected static java.lang.Object
toFrame(TypeDescription typeDescription)
Translates a type into a representation of its form inside a stack map frame.void
translateFrame(org.objectweb.asm.MethodVisitor methodVisitor, int type, int localVariableLength, java.lang.Object[] localVariable, int stackSize, java.lang.Object[] stack)
Translates a frame.protected void
translateFrame(org.objectweb.asm.MethodVisitor methodVisitor, Advice.StackMapFrameHandler.Default.TranslationMode translationMode, MethodDescription methodDescription, TypeList additionalTypes, int type, int localVariableLength, java.lang.Object[] localVariable, int stackSize, java.lang.Object[] stack)
Translates a frame.
-
-
-
Field Detail
-
instrumentedMethod
protected final MethodDescription instrumentedMethod
The instrumented method.
-
enterTypes
protected final TypeList enterTypes
A list of virtual method arguments that are available before the instrumented method is executed.
-
exitTypes
protected final TypeList exitTypes
A list of virtual method arguments that are available after the instrumented method has completed.
-
-
Constructor Detail
-
Default
protected Default(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypeList enterTypes, TypeList exitTypes, boolean expandFrames)
Creates a new default meta data handler.- Parameters:
instrumentedType
- The instrumented type.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.expandFrames
-true
if the meta data handler is expected to expand its frames.
-
-
Method Detail
-
of
protected static Advice.StackMapFrameHandler.ForInstrumentedMethod of(TypeDescription instrumentedType, MethodDescription instrumentedMethod, java.util.List<? extends TypeDescription> enterTypes, java.util.List<? extends TypeDescription> exitTypes, ClassFileVersion classFileVersion, int writerFlags, int readerFlags)
Creates an appropriate stack map frame handler for an instrumented method.- Parameters:
instrumentedType
- The instrumented type.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.classFileVersion
- The instrumented type's class file version.writerFlags
- The flags supplied to the ASM writer.readerFlags
- The reader flags supplied to the ASM reader.- Returns:
- An appropriate stack map frame handler for an instrumented method.
-
toFrame
protected static java.lang.Object toFrame(TypeDescription typeDescription)
Translates a type into a representation of its form inside a stack map frame.- Parameters:
typeDescription
- The type to translate.- Returns:
- A stack entry representation of the supplied type.
-
bindEntry
public Advice.StackMapFrameHandler.ForAdvice bindEntry(MethodDescription.InDefinedShape adviceMethod)
Description copied from interface:Advice.StackMapFrameHandler.ForInstrumentedMethod
Binds this meta data handler for the entry advice.- Specified by:
bindEntry
in interfaceAdvice.StackMapFrameHandler.ForInstrumentedMethod
- Parameters:
adviceMethod
- The entry advice method.- Returns:
- An appropriate meta data handler for the enter method.
-
bindExit
public Advice.StackMapFrameHandler.ForAdvice bindExit(MethodDescription.InDefinedShape adviceMethod)
Description copied from interface:Advice.StackMapFrameHandler.ForInstrumentedMethod
Binds this meta data handler for the exit advice.- Specified by:
bindExit
in interfaceAdvice.StackMapFrameHandler.ForInstrumentedMethod
- Parameters:
adviceMethod
- The exit advice method.- Returns:
- An appropriate meta data handler for the enter method.
-
getReaderHint
public int getReaderHint()
Description copied from interface:Advice.StackMapFrameHandler.ForInstrumentedMethod
Returns a hint to supply to aClassReader
when parsing an advice method.- Specified by:
getReaderHint
in interfaceAdvice.StackMapFrameHandler.ForInstrumentedMethod
- Returns:
- The reader hint to supply to an ASM class reader.
-
translateFrame
public void translateFrame(org.objectweb.asm.MethodVisitor methodVisitor, int type, int localVariableLength, java.lang.Object[] localVariable, int stackSize, java.lang.Object[] stack)
Description copied from interface:Advice.StackMapFrameHandler
Translates a frame.- Specified by:
translateFrame
in interfaceAdvice.StackMapFrameHandler
- Parameters:
methodVisitor
- The method visitor to write the frame to.type
- The frame's type.localVariableLength
- The local variable length.localVariable
- An array containing the types of the current local variables.stackSize
- The size of the operand stack.stack
- An array containing the types of the current operand stack.
-
translateFrame
protected void translateFrame(org.objectweb.asm.MethodVisitor methodVisitor, Advice.StackMapFrameHandler.Default.TranslationMode translationMode, MethodDescription methodDescription, TypeList additionalTypes, int type, int localVariableLength, java.lang.Object[] localVariable, int stackSize, java.lang.Object[] stack)
Translates a frame.- Parameters:
methodVisitor
- The method visitor to write the frame to.translationMode
- The translation mode to apply.methodDescription
- The method description for which the frame is written.additionalTypes
- The additional types to consider part of the instrumented method's parameters.type
- The frame's type.localVariableLength
- The local variable length.localVariable
- An array containing the types of the current local variables.stackSize
- The size of the operand stack.stack
- An array containing the types of the current operand stack.
-
injectReturnFrame
public void injectReturnFrame(org.objectweb.asm.MethodVisitor methodVisitor)
Description copied from interface:Advice.StackMapFrameHandler
Injects a frame indicating the beginning of a return value handler for the currently handled method.- Specified by:
injectReturnFrame
in interfaceAdvice.StackMapFrameHandler
- Parameters:
methodVisitor
- The method visitor onto which to apply the stack map frame.
-
injectExceptionFrame
public void injectExceptionFrame(org.objectweb.asm.MethodVisitor methodVisitor)
Description copied from interface:Advice.StackMapFrameHandler
Injects a frame indicating the beginning of an exception handler for the currently handled method.- Specified by:
injectExceptionFrame
in interfaceAdvice.StackMapFrameHandler
- Parameters:
methodVisitor
- The method visitor onto which to apply the stack map frame.
-
injectCompletionFrame
public void injectCompletionFrame(org.objectweb.asm.MethodVisitor methodVisitor, boolean secondary)
Description copied from interface:Advice.StackMapFrameHandler
Injects a frame indicating the completion of the currently handled method, i.e. all yielded types were added.- Specified by:
injectCompletionFrame
in interfaceAdvice.StackMapFrameHandler
- Parameters:
methodVisitor
- The method visitor onto which to apply the stack map frame.secondary
-true
if another completion frame for this method was written previously.
-
injectFullFrame
protected void injectFullFrame(org.objectweb.asm.MethodVisitor methodVisitor, java.util.List<? extends TypeDescription> typesInArray, java.util.List<? extends TypeDescription> typesOnStack)
Injects a full stack map frame.- Parameters:
methodVisitor
- The method visitor onto which to write the stack map frame.typesInArray
- The types that were added to the local variable array additionally to the values of the instrumented method.typesOnStack
- The types currently on the operand stack.
-
-