Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.objectweb.asm.MethodAdapter
org.objectweb.asm.commons.LocalVariablesSorter
org.objectweb.asm.commons.GeneratorAdapter
org.objectweb.asm.commons.AdviceAdapter
MethodAdapter
to insert before, after and around
advices in methods and constructors. The behavior for constructors is
like this: Field Summary | |
protected int | |
protected String |
Fields inherited from class org.objectweb.asm.commons.GeneratorAdapter | |
ADD , AND , DIV , EQ , GE , GT , LE , LT , MUL , NE , NEG , OR , REM , SHL , SHR , SUB , USHR , XOR |
Fields inherited from class org.objectweb.asm.commons.LocalVariablesSorter | |
firstLocal , nextLocal |
Fields inherited from class org.objectweb.asm.MethodAdapter | |
mv |
Constructor Summary | |
|
Method Summary | |
protected void |
|
protected void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class org.objectweb.asm.commons.GeneratorAdapter | |
arrayLength , arrayLoad , arrayStore , box , cast , catchException , checkCast , dup , dup2 , dup2X1 , dup2X2 , dupX1 , dupX2 , endMethod , getField , getLocalType , getStatic , goTo , ifCmp , ifICmp , ifNonNull , ifNull , ifZCmp , iinc , instanceOf , invokeConstructor , invokeInterface , invokeStatic , invokeVirtual , loadArg , loadArgArray , loadArgs , loadArgs , loadLocal , loadLocal , loadThis , mark , mark , math , monitorEnter , monitorExit , newArray , newInstance , newLabel , not , pop , pop2 , push , push , push , push , push , push , push , putField , putStatic , ret , returnValue , setLocalType , storeArg , storeLocal , storeLocal , swap , swap , tableSwitch , tableSwitch , throwException , throwException , unbox |
Methods inherited from class org.objectweb.asm.commons.LocalVariablesSorter | |
newLocal , newLocalMapping , setLocalType , visitFrame , visitIincInsn , visitLocalVariable , visitMaxs , visitVarInsn |
Methods inherited from class org.objectweb.asm.MethodAdapter | |
visitAnnotation , visitAnnotationDefault , visitAttribute , visitCode , visitEnd , visitFieldInsn , visitFrame , visitIincInsn , visitInsn , visitIntInsn , visitJumpInsn , visitLabel , visitLdcInsn , visitLineNumber , visitLocalVariable , visitLookupSwitchInsn , visitMaxs , visitMethodInsn , visitMultiANewArrayInsn , visitParameterAnnotation , visitTableSwitchInsn , visitTryCatchBlock , visitTypeInsn , visitVarInsn |
protected AdviceAdapter(MethodVisitor mv, int access, String name, String desc)
Creates a newAdviceAdapter
.
protected void onMethodEnter()
Called at the beginning of the method or after super class class call in the constructor.
Custom code can use or change all the local variables, but should not change state of the stack.
protected void onMethodExit(int opcode)
Called before explicit exit from the method using either return or throw. Top element on the stack contains the return value or exception instance. For example:public void onMethodExit(int opcode) { if(opcode==RETURN) { visitInsn(ACONST_NULL); } else if(opcode==ARETURN || opcode==ATHROW) { dup(); } else { if(opcode==LRETURN || opcode==DRETURN) { dup2(); } else { dup(); } box(Type.getReturnType(this.methodDesc)); } visitIntInsn(SIPUSH, opcode); visitMethodInsn(INVOKESTATIC, owner, "onExit", "(Ljava/lang/Object;I)V"); } // an actual call back method public static void onExit(int opcode, Object param) { ...
Custom code can use or change all the local variables, but should not change state of the stack.
- Parameters:
opcode
- one of the RETURN, IRETURN, FRETURN, ARETURN, LRETURN, DRETURN or ATHROW
public void visitCode()
- Specified by:
- visitCode in interface MethodVisitor
- Overrides:
- visitCode in interface MethodAdapter
public void visitFieldInsn(int opcode, String owner, String name, String desc)
- Specified by:
- visitFieldInsn in interface MethodVisitor
- Overrides:
- visitFieldInsn in interface MethodAdapter
public void visitInsn(int opcode)
- Specified by:
- visitInsn in interface MethodVisitor
- Overrides:
- visitInsn in interface MethodAdapter
public void visitIntInsn(int opcode, int operand)
- Specified by:
- visitIntInsn in interface MethodVisitor
- Overrides:
- visitIntInsn in interface MethodAdapter
public void visitJumpInsn(int opcode, Label label)
- Specified by:
- visitJumpInsn in interface MethodVisitor
- Overrides:
- visitJumpInsn in interface MethodAdapter
public void visitLabel(Label label)
- Specified by:
- visitLabel in interface MethodVisitor
- Overrides:
- visitLabel in interface MethodAdapter
public void visitLdcInsn(Object cst)
- Specified by:
- visitLdcInsn in interface MethodVisitor
- Overrides:
- visitLdcInsn in interface MethodAdapter
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)
- Specified by:
- visitLookupSwitchInsn in interface MethodVisitor
- Overrides:
- visitLookupSwitchInsn in interface MethodAdapter
public void visitMethodInsn(int opcode, String owner, String name, String desc)
- Specified by:
- visitMethodInsn in interface MethodVisitor
- Overrides:
- visitMethodInsn in interface MethodAdapter
public void visitMultiANewArrayInsn(String desc, int dims)
- Specified by:
- visitMultiANewArrayInsn in interface MethodVisitor
- Overrides:
- visitMultiANewArrayInsn in interface MethodAdapter
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels)
- Specified by:
- visitTableSwitchInsn in interface MethodVisitor
- Overrides:
- visitTableSwitchInsn in interface MethodAdapter
public void visitTypeInsn(int opcode, String type)
- Specified by:
- visitTypeInsn in interface MethodVisitor
- Overrides:
- visitTypeInsn in interface MethodAdapter
public void visitVarInsn(int opcode, int var)
- Specified by:
- visitVarInsn in interface MethodVisitor
- Overrides:
- visitVarInsn in interface LocalVariablesSorter