org.objectweb.asm.commons
public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes
MethodAdapter
to dispatch method body instruction
The behavior is like this:
Field Summary | |
---|---|
protected int | methodAccess |
protected String | methodDesc |
Constructor Summary | |
---|---|
AdviceAdapter(MethodVisitor mv, int access, String name, String desc)
Creates a new {@link AdviceAdapter}.
|
Method Summary | |
---|---|
protected abstract void | onMethodEnter()
Called at the beginning of the method or after super
class class call in the constructor.
|
protected abstract void | onMethodExit(int opcode)
Called before explicit exit from the method using either
return or throw. |
void | visitFieldInsn(int opcode, String owner, String name, String desc) |
void | visitInsn(int opcode) |
void | visitIntInsn(int opcode, int operand) |
void | visitJumpInsn(int opcode, Label label) |
void | visitLabel(Label label) |
void | visitLdcInsn(Object cst) |
void | visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) |
void | visitMethodInsn(int opcode, String owner, String name, String desc) |
void | visitMultiANewArrayInsn(String desc, int dims) |
void | visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) |
void | visitTypeInsn(int opcode, String name) |
void | visitVarInsn(int opcode, int var) |
Parameters: mv the method visitor to which this adapter delegates calls. access the method's access flags (see {@link Opcodes}). name the method's name. desc the method's descriptor (see {@link Type Type}).
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) { ...
Parameters: opcode one of the RETURN, IRETURN, FRETURN, ARETURN, LRETURN, DRETURN or ATHROW