Package net.bytebuddy.asm
Class Advice.Dispatcher.Inlining.CodeTranslationVisitor
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- net.bytebuddy.asm.Advice.Dispatcher.Inlining.CodeTranslationVisitor
-
- All Implemented Interfaces:
Advice.Dispatcher.SuppressionHandler.ReturnValueProducer
- Direct Known Subclasses:
Advice.Dispatcher.Inlining.CodeTranslationVisitor.ForMethodEnter
,Advice.Dispatcher.Inlining.CodeTranslationVisitor.ForMethodExit
- Enclosing class:
- Advice.Dispatcher.Inlining
protected abstract static class Advice.Dispatcher.Inlining.CodeTranslationVisitor extends org.objectweb.asm.MethodVisitor implements Advice.Dispatcher.SuppressionHandler.ReturnValueProducer
A visitor for translating an advice method's byte code for inlining into the instrumented method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Advice.Dispatcher.Inlining.CodeTranslationVisitor.ForMethodEnter
A code translation visitor that retains the return value of the represented advice method.protected static class
Advice.Dispatcher.Inlining.CodeTranslationVisitor.ForMethodExit
A code translation visitor that discards the return value of the represented advice method.
-
Field Summary
Fields Modifier and Type Field Description protected MethodDescription.InDefinedShape
adviceMethod
The advice method.protected org.objectweb.asm.Label
endOfMethod
A label indicating the end of the advice byte code.protected Implementation.Context
implementationContext
The implementation context to use.protected MethodDescription
instrumentedMethod
The instrumented method.protected Advice.MethodSizeHandler.ForAdvice
methodSizeHandler
A handler for computing the method size requirements.protected org.objectweb.asm.MethodVisitor
methodVisitor
The original method visitor to which all instructions are eventually written to.protected Advice.StackMapFrameHandler.ForAdvice
stackMapFrameHandler
A handler for translating and injecting stack map frames.
-
Constructor Summary
Constructors Modifier Constructor Description protected
CodeTranslationVisitor(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, Advice.MethodSizeHandler.ForAdvice methodSizeHandler, Advice.StackMapFrameHandler.ForAdvice stackMapFrameHandler, MethodDescription instrumentedMethod, MethodDescription.InDefinedShape adviceMethod, java.util.Map<java.lang.Integer,Advice.OffsetMapping.Target> offsetMappings, Advice.Dispatcher.SuppressionHandler.Bound suppressionHandler)
Creates a new code translation visitor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract int
adjust(int offset)
Adjusts the offset of a variable instruction within the advice method such that no arguments to the instrumented method are overridden.protected abstract void
onMethodReturn()
Invoked after returning from the advice method.protected void
propagateHandler(org.objectweb.asm.Label label)
Propagates a label for an exception handler that is typically suppressed by the overlayingAdvice.Dispatcher.Inlining.Resolved.AdviceMethodInliner.ExceptionTableSubstitutor
.org.objectweb.asm.AnnotationVisitor
visitAnnotation(java.lang.String descriptor, boolean visible)
org.objectweb.asm.AnnotationVisitor
visitAnnotationDefault()
void
visitAttribute(org.objectweb.asm.Attribute attribute)
void
visitCode()
void
visitEnd()
void
visitFrame(int type, int localVariableLength, java.lang.Object[] localVariable, int stackSize, java.lang.Object[] stack)
void
visitIincInsn(int offset, int value)
abstract void
visitInsn(int opcode)
void
visitMaxs(int stackSize, int localVariableLength)
void
visitParameter(java.lang.String name, int modifiers)
org.objectweb.asm.AnnotationVisitor
visitParameterAnnotation(int index, java.lang.String descriptor, boolean visible)
org.objectweb.asm.AnnotationVisitor
visitTypeAnnotation(int typeReference, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)
void
visitVarInsn(int opcode, int offset)
-
Methods inherited from class org.objectweb.asm.MethodVisitor
visitAnnotableParameterCount, visitFieldInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLocalVariableAnnotation, visitLookupSwitchInsn, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeInsn
-
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.SuppressionHandler.ReturnValueProducer
onDefaultValue
-
-
-
-
Field Detail
-
methodVisitor
protected final org.objectweb.asm.MethodVisitor methodVisitor
The original method visitor to which all instructions are eventually written to.
-
implementationContext
protected final Implementation.Context implementationContext
The implementation context to use.
-
methodSizeHandler
protected final Advice.MethodSizeHandler.ForAdvice methodSizeHandler
A handler for computing the method size requirements.
-
stackMapFrameHandler
protected final Advice.StackMapFrameHandler.ForAdvice stackMapFrameHandler
A handler for translating and injecting stack map frames.
-
instrumentedMethod
protected final MethodDescription instrumentedMethod
The instrumented method.
-
adviceMethod
protected final MethodDescription.InDefinedShape adviceMethod
The advice method.
-
endOfMethod
protected final org.objectweb.asm.Label endOfMethod
A label indicating the end of the advice byte code.
-
-
Constructor Detail
-
CodeTranslationVisitor
protected CodeTranslationVisitor(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, Advice.MethodSizeHandler.ForAdvice methodSizeHandler, Advice.StackMapFrameHandler.ForAdvice stackMapFrameHandler, MethodDescription instrumentedMethod, MethodDescription.InDefinedShape adviceMethod, java.util.Map<java.lang.Integer,Advice.OffsetMapping.Target> offsetMappings, Advice.Dispatcher.SuppressionHandler.Bound suppressionHandler)
Creates a new code translation visitor.- Parameters:
methodVisitor
- A method visitor for writing the instrumented method's byte code.implementationContext
- The implementation context to use.methodSizeHandler
- A handler for computing the method size requirements.stackMapFrameHandler
- A handler for translating and injecting stack map frames.instrumentedMethod
- The instrumented method.adviceMethod
- The advice method.offsetMappings
- A mapping of offsets to resolved target offsets in the instrumented method.suppressionHandler
- The suppression handler to use.
-
-
Method Detail
-
propagateHandler
protected void propagateHandler(org.objectweb.asm.Label label)
Propagates a label for an exception handler that is typically suppressed by the overlayingAdvice.Dispatcher.Inlining.Resolved.AdviceMethodInliner.ExceptionTableSubstitutor
.- Parameters:
label
- The label to register as a target for an exception handler.
-
visitParameter
public void visitParameter(java.lang.String name, int modifiers)
- Overrides:
visitParameter
in classorg.objectweb.asm.MethodVisitor
-
visitAnnotationDefault
public org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
- Overrides:
visitAnnotationDefault
in classorg.objectweb.asm.MethodVisitor
-
visitAnnotation
public org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String descriptor, boolean visible)
- Overrides:
visitAnnotation
in classorg.objectweb.asm.MethodVisitor
-
visitTypeAnnotation
public org.objectweb.asm.AnnotationVisitor visitTypeAnnotation(int typeReference, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)
- Overrides:
visitTypeAnnotation
in classorg.objectweb.asm.MethodVisitor
-
visitParameterAnnotation
public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int index, java.lang.String descriptor, boolean visible)
- Overrides:
visitParameterAnnotation
in classorg.objectweb.asm.MethodVisitor
-
visitAttribute
public void visitAttribute(org.objectweb.asm.Attribute attribute)
- Overrides:
visitAttribute
in classorg.objectweb.asm.MethodVisitor
-
visitCode
public void visitCode()
- Overrides:
visitCode
in classorg.objectweb.asm.MethodVisitor
-
visitFrame
public void visitFrame(int type, int localVariableLength, java.lang.Object[] localVariable, int stackSize, java.lang.Object[] stack)
- Overrides:
visitFrame
in classorg.objectweb.asm.MethodVisitor
-
visitEnd
public void visitEnd()
- Overrides:
visitEnd
in classorg.objectweb.asm.MethodVisitor
-
visitMaxs
public void visitMaxs(int stackSize, int localVariableLength)
- Overrides:
visitMaxs
in classorg.objectweb.asm.MethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int offset)
- Overrides:
visitVarInsn
in classorg.objectweb.asm.MethodVisitor
-
visitIincInsn
public void visitIincInsn(int offset, int value)
- Overrides:
visitIincInsn
in classorg.objectweb.asm.MethodVisitor
-
adjust
protected abstract int adjust(int offset)
Adjusts the offset of a variable instruction within the advice method such that no arguments to the instrumented method are overridden.- Parameters:
offset
- The original offset.- Returns:
- The adjusted offset.
-
visitInsn
public abstract void visitInsn(int opcode)
- Overrides:
visitInsn
in classorg.objectweb.asm.MethodVisitor
-
onMethodReturn
protected abstract void onMethodReturn()
Invoked after returning from the advice method.
-
-