Package net.bytebuddy.asm
Class Advice.AdviceVisitor
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- net.bytebuddy.utility.visitor.ExceptionTableSensitiveMethodVisitor
-
- net.bytebuddy.asm.Advice.AdviceVisitor
-
- All Implemented Interfaces:
Advice.Dispatcher.RelocationHandler.Relocation
- Direct Known Subclasses:
Advice.AdviceVisitor.WithExitAdvice,Advice.AdviceVisitor.WithoutExitAdvice
- Enclosing class:
- Advice
protected abstract static class Advice.AdviceVisitor extends ExceptionTableSensitiveMethodVisitor implements Advice.Dispatcher.RelocationHandler.Relocation
A method visitor that weaves the advice methods' byte codes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAdvice.AdviceVisitor.WithExitAdviceAn advice visitor that applies exit advice.protected static classAdvice.AdviceVisitor.WithoutExitAdviceAn advice visitor that does not apply exit advice.-
Nested classes/interfaces inherited from interface net.bytebuddy.asm.Advice.Dispatcher.RelocationHandler.Relocation
Advice.Dispatcher.RelocationHandler.Relocation.ForLabel
-
-
Field Summary
Fields Modifier and Type Field Description protected Advice.ArgumentHandler.ForInstrumentedMethodargumentHandlerThe handler for accessing arguments of the method's local variable array.protected MethodDescriptioninstrumentedMethodA description of the instrumented method.private Advice.Dispatcher.BoundmethodEnterThe dispatcher to be used for method enter.protected Advice.Dispatcher.BoundmethodExitThe dispatcher to be used for method exit.protected Advice.MethodSizeHandler.ForInstrumentedMethodmethodSizeHandlerA handler for computing the method size requirements.private org.objectweb.asm.LabelpreparationStartA label that indicates the start of the preparation of a user method execution.protected Advice.StackMapFrameHandler.ForInstrumentedMethodstackMapFrameHandlerA handler for translating and injecting stack map frames.private static intTHIS_VARIABLE_INDEXThe expected index for thethisvariable.private static java.lang.StringTHIS_VARIABLE_NAMEThe expected name for thethisvariable.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAdviceVisitor(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, Assigner assigner, StackManipulation exceptionHandler, TypeDescription instrumentedType, MethodDescription instrumentedMethod, Advice.Dispatcher.Resolved.ForMethodEnter methodEnter, Advice.Dispatcher.Resolved.ForMethodExit methodExit, java.util.List<? extends TypeDescription> postMethodTypes, int writerFlags, int readerFlags)Creates a new advice visitor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidonAfterExceptionTable()Invoked after the exception table was visited.protected abstract voidonUserEnd()Writes the advice for completing the instrumented method.protected abstract voidonUserPrepare()Invoked when the user method's exception handler (if any) is supposed to be prepared.protected abstract voidonUserStart()Writes the advice for entering the instrumented method.voidonVisitFrame(int type, int localVariableLength, java.lang.Object[] localVariable, int stackSize, java.lang.Object[] stack)Visits a stack map frame.protected voidonVisitIincInsn(int offset, int increment)Visits an increment instruction.protected voidonVisitVarInsn(int opcode, int offset)Visits an variable instruction.voidvisitLocalVariable(java.lang.String name, java.lang.String descriptor, java.lang.String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int offset)org.objectweb.asm.AnnotationVisitorvisitLocalVariableAnnotation(int typeReference, org.objectweb.asm.TypePath typePath, org.objectweb.asm.Label[] start, org.objectweb.asm.Label[] end, int[] offset, java.lang.String descriptor, boolean visible)voidvisitMaxs(int stackSize, int localVariableLength)-
Methods inherited from class net.bytebuddy.utility.visitor.ExceptionTableSensitiveMethodVisitor
onVisitFieldInsn, onVisitInsn, onVisitIntInsn, onVisitInvokeDynamicInsn, onVisitJumpInsn, onVisitLabel, onVisitLdcInsn, onVisitLookupSwitchInsn, onVisitMethodInsn, onVisitMethodInsn, onVisitMultiANewArrayInsn, onVisitTableSwitchInsn, onVisitTypeInsn, visitFieldInsn, visitFrame, visitIincInsn, visitInsn, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLookupSwitchInsn, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitTableSwitchInsn, visitTypeInsn, visitVarInsn
-
Methods inherited from class org.objectweb.asm.MethodVisitor
getDelegate, visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitInsnAnnotation, visitLineNumber, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.bytebuddy.asm.Advice.Dispatcher.RelocationHandler.Relocation
apply
-
-
-
-
Field Detail
-
THIS_VARIABLE_INDEX
private static final int THIS_VARIABLE_INDEX
The expected index for thethisvariable.- See Also:
- Constant Field Values
-
THIS_VARIABLE_NAME
private static final java.lang.String THIS_VARIABLE_NAME
The expected name for thethisvariable.- See Also:
- Constant Field Values
-
instrumentedMethod
protected final MethodDescription instrumentedMethod
A description of the instrumented method.
-
preparationStart
private final org.objectweb.asm.Label preparationStart
A label that indicates the start of the preparation of a user method execution.
-
methodEnter
private final Advice.Dispatcher.Bound methodEnter
The dispatcher to be used for method enter.
-
methodExit
protected final Advice.Dispatcher.Bound methodExit
The dispatcher to be used for method exit.
-
argumentHandler
protected final Advice.ArgumentHandler.ForInstrumentedMethod argumentHandler
The handler for accessing arguments of the method's local variable array.
-
methodSizeHandler
protected final Advice.MethodSizeHandler.ForInstrumentedMethod methodSizeHandler
A handler for computing the method size requirements.
-
stackMapFrameHandler
protected final Advice.StackMapFrameHandler.ForInstrumentedMethod stackMapFrameHandler
A handler for translating and injecting stack map frames.
-
-
Constructor Detail
-
AdviceVisitor
protected AdviceVisitor(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, Assigner assigner, StackManipulation exceptionHandler, TypeDescription instrumentedType, MethodDescription instrumentedMethod, Advice.Dispatcher.Resolved.ForMethodEnter methodEnter, Advice.Dispatcher.Resolved.ForMethodExit methodExit, java.util.List<? extends TypeDescription> postMethodTypes, int writerFlags, int readerFlags)Creates a new advice visitor.- Parameters:
methodVisitor- The actual method visitor that is underlying this method visitor to which all instructions are written.implementationContext- The implementation context to use.assigner- The assigner to use.exceptionHandler- The stack manipulation to apply within a suppression handler.instrumentedType- A description of the instrumented type.instrumentedMethod- The instrumented method.methodEnter- The method enter advice.methodExit- The method exit advice.postMethodTypes- A list of virtual method arguments that are available after the instrumented method has completed.writerFlags- The ASM writer flags that were set.readerFlags- The ASM reader flags that were set.
-
-
Method Detail
-
onAfterExceptionTable
protected void onAfterExceptionTable()
Description copied from class:ExceptionTableSensitiveMethodVisitorInvoked after the exception table was visited. Typically, the exception table is visited by ASM at the beginning of a method. It is however possible that a user adds exception table entries at a later point. Normally, this is however not meaningful use of ASM.- Specified by:
onAfterExceptionTablein classExceptionTableSensitiveMethodVisitor
-
onUserPrepare
protected abstract void onUserPrepare()
Invoked when the user method's exception handler (if any) is supposed to be prepared.
-
onUserStart
protected abstract void onUserStart()
Writes the advice for entering the instrumented method.
-
onVisitVarInsn
protected void onVisitVarInsn(int opcode, int offset)Description copied from class:ExceptionTableSensitiveMethodVisitorVisits an variable instruction.- Overrides:
onVisitVarInsnin classExceptionTableSensitiveMethodVisitor- Parameters:
opcode- The visited opcode.offset- The visited offset.
-
onVisitIincInsn
protected void onVisitIincInsn(int offset, int increment)Description copied from class:ExceptionTableSensitiveMethodVisitorVisits an increment instruction.- Overrides:
onVisitIincInsnin classExceptionTableSensitiveMethodVisitor- Parameters:
offset- The offset of the accessed variable.increment- The value with which to increment.
-
onVisitFrame
public void onVisitFrame(int type, int localVariableLength, @MaybeNull java.lang.Object[] localVariable, int stackSize, @MaybeNull java.lang.Object[] stack)Description copied from class:ExceptionTableSensitiveMethodVisitorVisits a stack map frame.- Overrides:
onVisitFramein classExceptionTableSensitiveMethodVisitor- Parameters:
type- The type of stack map frame.localVariableLength- The length of the local variable array.localVariable- An array containing type symbols for all values in the local variable array ornullif none.stackSize- The size of the operand stack.stack- An array containing type symbols for all values on the operand stack ornullif none.
-
visitMaxs
public void visitMaxs(int stackSize, int localVariableLength)- Overrides:
visitMaxsin classorg.objectweb.asm.MethodVisitor
-
visitLocalVariable
public void visitLocalVariable(java.lang.String name, java.lang.String descriptor, java.lang.String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int offset)- Overrides:
visitLocalVariablein classorg.objectweb.asm.MethodVisitor
-
visitLocalVariableAnnotation
public org.objectweb.asm.AnnotationVisitor visitLocalVariableAnnotation(int typeReference, org.objectweb.asm.TypePath typePath, org.objectweb.asm.Label[] start, org.objectweb.asm.Label[] end, int[] offset, java.lang.String descriptor, boolean visible)- Overrides:
visitLocalVariableAnnotationin classorg.objectweb.asm.MethodVisitor
-
onUserEnd
protected abstract void onUserEnd()
Writes the advice for completing the instrumented method.
-
-