public abstract class AdviceAdapter extends GeneratorAdapter implements org.objectweb.asm.Opcodes
MethodVisitor
to insert before, after and around advices in methods
and constructors.
The behavior for constructors is like this:
Modifier and Type | Field and Description |
---|---|
protected int |
methodAccess |
protected java.lang.String |
methodDesc |
ADD, AND, DIV, EQ, GE, GT, LE, LT, MUL, NE, NEG, OR, REM, SHL, SHR, SUB, USHR, XOR
firstLocal, nextLocal
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_MANDATED, ACC_MODULE, ACC_NATIVE, ACC_OPEN, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STATIC_PHASE, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_TRANSITIVE, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM4, ASM5, ASM6, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, H_GETFIELD, H_GETSTATIC, H_INVOKEINTERFACE, H_INVOKESPECIAL, H_INVOKESTATIC, H_INVOKEVIRTUAL, H_NEWINVOKESPECIAL, H_PUTFIELD, H_PUTSTATIC, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8, V10, V9
Modifier | Constructor and Description |
---|---|
protected |
AdviceAdapter(int api,
org.objectweb.asm.MethodVisitor mv,
int access,
java.lang.String name,
java.lang.String desc)
Constructs a new
AdviceAdapter . |
Modifier and Type | Method and Description |
---|---|
protected void |
onMethodEnter()
Called at the beginning of the method or after super 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,
java.lang.String owner,
java.lang.String name,
java.lang.String desc) |
void |
visitInsn(int opcode) |
void |
visitIntInsn(int opcode,
int operand) |
void |
visitInvokeDynamicInsn(java.lang.String name,
java.lang.String desc,
org.objectweb.asm.Handle bsm,
java.lang.Object... bsmArgs) |
void |
visitJumpInsn(int opcode,
org.objectweb.asm.Label label) |
void |
visitLabel(org.objectweb.asm.Label label) |
void |
visitLdcInsn(java.lang.Object cst) |
void |
visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
int[] keys,
org.objectweb.asm.Label[] labels) |
void |
visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String desc)
Deprecated.
|
void |
visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String desc,
boolean itf) |
void |
visitMultiANewArrayInsn(java.lang.String desc,
int dims) |
void |
visitTableSwitchInsn(int min,
int max,
org.objectweb.asm.Label dflt,
org.objectweb.asm.Label... labels) |
void |
visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
java.lang.String type) |
void |
visitTypeInsn(int opcode,
java.lang.String type) |
void |
visitVarInsn(int opcode,
int var) |
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, invokeDynamic, 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, push, putField, putStatic, ret, returnValue, setLocalType, storeArg, storeLocal, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, valueOf
newLocal, newLocalMapping, updateNewLocals, visitFrame, visitIincInsn, visitLocalVariable, visitLocalVariableAnnotation, visitMaxs
protected int methodAccess
protected java.lang.String methodDesc
protected AdviceAdapter(int api, org.objectweb.asm.MethodVisitor mv, int access, java.lang.String name, java.lang.String desc)
AdviceAdapter
.api
- the ASM API version implemented by this visitor. Must be one of Opcodes.ASM4
, Opcodes.ASM5
or Opcodes.ASM6
.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 visitCode()
visitCode
in class org.objectweb.asm.MethodVisitor
public void visitLabel(org.objectweb.asm.Label label)
visitLabel
in class org.objectweb.asm.MethodVisitor
public void visitInsn(int opcode)
visitInsn
in class org.objectweb.asm.MethodVisitor
public void visitVarInsn(int opcode, int var)
visitVarInsn
in class LocalVariablesSorter
public void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
visitFieldInsn
in class org.objectweb.asm.MethodVisitor
public void visitIntInsn(int opcode, int operand)
visitIntInsn
in class org.objectweb.asm.MethodVisitor
public void visitLdcInsn(java.lang.Object cst)
visitLdcInsn
in class org.objectweb.asm.MethodVisitor
public void visitMultiANewArrayInsn(java.lang.String desc, int dims)
visitMultiANewArrayInsn
in class org.objectweb.asm.MethodVisitor
public void visitTypeInsn(int opcode, java.lang.String type)
visitTypeInsn
in class org.objectweb.asm.MethodVisitor
@Deprecated public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
visitMethodInsn
in class org.objectweb.asm.MethodVisitor
public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc, boolean itf)
visitMethodInsn
in class org.objectweb.asm.MethodVisitor
public void visitInvokeDynamicInsn(java.lang.String name, java.lang.String desc, org.objectweb.asm.Handle bsm, java.lang.Object... bsmArgs)
visitInvokeDynamicInsn
in class org.objectweb.asm.MethodVisitor
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label)
visitJumpInsn
in class org.objectweb.asm.MethodVisitor
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
visitLookupSwitchInsn
in class org.objectweb.asm.MethodVisitor
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
visitTableSwitchInsn
in class org.objectweb.asm.MethodVisitor
public void visitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, java.lang.String type)
visitTryCatchBlock
in class org.objectweb.asm.MethodVisitor
protected void onMethodEnter()
protected void onMethodExit(int opcode)
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(Object param, int opcode) { ...
opcode
- one of the RETURN, IRETURN, FRETURN, ARETURN, LRETURN, DRETURN or ATHROW