|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.asm.MethodAdapter
org.objectweb.asm.commons.LocalVariablesSorter
org.objectweb.asm.commons.GeneratorAdapter
org.objectweb.asm.commons.AdviceAdapter
A MethodAdapter
to insert before, after and around
advices in methods and constructors.
The behavior for constructors is like this:
Field Summary | |
protected int |
methodAccess
|
protected String |
methodDesc
|
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 | |
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()
Starts the visit of the method's code, if any (i.e. |
void |
visitFieldInsn(int opcode,
String owner,
String name,
String desc)
Visits a field instruction. |
void |
visitInsn(int opcode)
Visits a zero operand instruction. |
void |
visitIntInsn(int opcode,
int operand)
Visits an instruction with a single int operand. |
void |
visitJumpInsn(int opcode,
Label label)
Visits a jump instruction. |
void |
visitLabel(Label label)
Visits a label. |
void |
visitLdcInsn(Object cst)
Visits a LDC instruction. |
void |
visitLookupSwitchInsn(Label dflt,
int[] keys,
Label[] labels)
Visits a LOOKUPSWITCH instruction. |
void |
visitMethodInsn(int opcode,
String owner,
String name,
String desc)
Visits a method instruction. |
void |
visitMultiANewArrayInsn(String desc,
int dims)
Visits a MULTIANEWARRAY instruction. |
void |
visitTableSwitchInsn(int min,
int max,
Label dflt,
Label[] labels)
Visits a TABLESWITCH instruction. |
void |
visitTypeInsn(int opcode,
String type)
Visits a type instruction. |
void |
visitVarInsn(int opcode,
int var)
Visits a local variable instruction. |
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, visitFrame, visitIincInsn, visitLocalVariable, visitMaxs |
Methods inherited from class org.objectweb.asm.MethodAdapter |
visitAnnotation, visitAnnotationDefault, visitAttribute, visitEnd, visitLineNumber, visitParameterAnnotation, visitTryCatchBlock |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int methodAccess
protected String methodDesc
Constructor Detail |
protected AdviceAdapter(MethodVisitor mv, int access, String name, String desc)
AdviceAdapter
.
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
).Method Detail |
public void visitCode()
MethodVisitor
visitCode
in interface MethodVisitor
visitCode
in class MethodAdapter
public void visitLabel(Label label)
MethodVisitor
visitLabel
in interface MethodVisitor
visitLabel
in class MethodAdapter
public void visitInsn(int opcode)
MethodVisitor
visitInsn
in interface MethodVisitor
visitInsn
in class MethodAdapter
public void visitVarInsn(int opcode, int var)
MethodVisitor
visitVarInsn
in interface MethodVisitor
visitVarInsn
in class LocalVariablesSorter
public void visitFieldInsn(int opcode, String owner, String name, String desc)
MethodVisitor
visitFieldInsn
in interface MethodVisitor
visitFieldInsn
in class MethodAdapter
public void visitIntInsn(int opcode, int operand)
MethodVisitor
visitIntInsn
in interface MethodVisitor
visitIntInsn
in class MethodAdapter
public void visitLdcInsn(Object cst)
MethodVisitor
visitLdcInsn
in interface MethodVisitor
visitLdcInsn
in class MethodAdapter
public void visitMultiANewArrayInsn(String desc, int dims)
MethodVisitor
visitMultiANewArrayInsn
in interface MethodVisitor
visitMultiANewArrayInsn
in class MethodAdapter
public void visitTypeInsn(int opcode, String type)
MethodVisitor
visitTypeInsn
in interface MethodVisitor
visitTypeInsn
in class MethodAdapter
public void visitMethodInsn(int opcode, String owner, String name, String desc)
MethodVisitor
visitMethodInsn
in interface MethodVisitor
visitMethodInsn
in class MethodAdapter
public void visitJumpInsn(int opcode, Label label)
MethodVisitor
visitJumpInsn
in interface MethodVisitor
visitJumpInsn
in class MethodAdapter
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)
MethodVisitor
visitLookupSwitchInsn
in interface MethodVisitor
visitLookupSwitchInsn
in class MethodAdapter
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels)
MethodVisitor
visitTableSwitchInsn
in interface MethodVisitor
visitTableSwitchInsn
in class MethodAdapter
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(int opcode, Object param) { ...
opcode
- one of the RETURN, IRETURN, FRETURN, ARETURN, LRETURN,
DRETURN or ATHROW
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |