org.objectweb.asm.commons
public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes
The behavior for constructors is like this:
| Field Summary | |
|---|---|
| protected int | methodAccess |
| protected String | methodDesc |
| Constructor Summary | |
|---|---|
| protected | AdviceAdapter(MethodVisitor mv, int access, String name, String desc)
Creates a new AdviceAdapter.
|
| Method Summary | |
|---|---|
| protected void | onMethodEnter()
Called at the beginning of the method or after super class class call in
the constructor. |
| protected void | onMethodExit(int opcode)
Called before explicit exit from the method using either return or throw.
|
| void | visitCode() |
| 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 type) |
| void | visitVarInsn(int opcode, int var) |
Parameters: mv the method visitor to which this adapter delegates calls. access the method's access flags (see Opcodes). name the method's name. desc the method's descriptor (see 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