public class MethodTransformer
extends org.objectweb.asm.commons.LocalVariablesSorter
| Modifier and Type | Field and Description |
|---|---|
static String |
LOGGER_CLASS |
static String |
METHOD_RECORD_EVENT |
| Constructor and Description |
|---|
MethodTransformer(WeaveLog w,
WeaveConfig config,
String sourceFileName,
String className,
String outerClassName,
int access,
String methodName,
String methodDesc,
String signature,
String[] exceptions,
org.objectweb.asm.MethodVisitor mv)
Initialize the instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
setup(List<?> localVariableNodes,
org.objectweb.asm.tree.InsnList instructions)
Receives local variables and instructions in this method.
|
void |
visitCode()
Visiting a method body.
|
void |
visitEnd()
End the weaving.
|
void |
visitFieldInsn(int opcode,
String owner,
String name,
String desc)
Insert logging code for field access instruction.
|
void |
visitFrame(int type,
int numLocal,
Object[] local,
int numStack,
Object[] stack)
Visits the current state of the local variables and operand stack elements.
|
void |
visitIincInsn(int var,
int increment)
Insert logging code for an IINC instruction.
|
void |
visitInsn(int opcode)
Insert logging code for various instructions.
|
void |
visitIntInsn(int opcode,
int operand)
Insert logging code for a NEWARRAY instruction.
|
void |
visitInvokeDynamicInsn(String name,
String desc,
org.objectweb.asm.Handle bsm,
Object... bsmArgs)
Insert logging code for INVOKEDYNAMIC instruction.
|
void |
visitJumpInsn(int opcode,
org.objectweb.asm.Label label)
Store a location for LABEL event if recordLabel is enabled.
|
void |
visitLabel(org.objectweb.asm.Label label)
Logging a jump instruction if recordLabel is enabled.
|
void |
visitLdcInsn(Object cst)
Insert logging code for a Load Constant instruction
in order to record the constant object.
|
void |
visitLineNumber(int line,
org.objectweb.asm.Label start) |
void |
visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
int[] keys,
org.objectweb.asm.Label[] labels)
No additional actions but count the number of instructions.
|
void |
visitMaxs(int maxStack,
int maxLocals)
Finalize the method.
|
void |
visitMethodInsn(int opcode,
String owner,
String name,
String desc,
boolean itf)
Insert logging code for INVOKE instructions.
|
void |
visitMultiANewArrayInsn(String desc,
int dims)
Insert logging code for a MultiANewArray instruction.
|
void |
visitTableSwitchInsn(int min,
int max,
org.objectweb.asm.Label dflt,
org.objectweb.asm.Label... labels)
No additional actions but count the number of instructions.
|
void |
visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
String type)
Store entry points of catch blocks for later visit* methods.
|
void |
visitTypeInsn(int opcode,
String type)
Insert logging code for NEW, ANEWARRAY, INSTANCEOF instructions.
|
void |
visitVarInsn(int opcode,
int var)
Insert logging code for local variable and RET instructions.
|
newLocal, newLocalMapping, setLocalType, updateNewLocals, visitLocalVariable, visitLocalVariableAnnotationpublic static final String LOGGER_CLASS
public static final String METHOD_RECORD_EVENT
public MethodTransformer(WeaveLog w, WeaveConfig config, String sourceFileName, String className, String outerClassName, int access, String methodName, String methodDesc, String signature, String[] exceptions, org.objectweb.asm.MethodVisitor mv)
w - is to log the progressconfig - is the configuration of the weavingsourceFileName - is a source file name (just for logging the progress)className - is a class nameouterClassName - is outer class name if this class is ineer classaccess - is modifiers of the methodmethodName - is a method namemethodDesc - is a descriptor (parameter types and a return type)signature - is a generics signatureexceptions - represents a throws clausemv - is the object for writing bytecodepublic void setup(List<?> localVariableNodes, org.objectweb.asm.tree.InsnList instructions)
localVariableNodes - list of LocalVariableNodeinstructions - list of instructions for which information is to be collectedpublic void visitEnd()
visitEnd in class org.objectweb.asm.MethodVisitorpublic void visitLineNumber(int line,
org.objectweb.asm.Label start)
visitLineNumber in class org.objectweb.asm.MethodVisitorline - line number from the source codestart - the current label under which this line number comes
Record current line number for other visit methodspublic void visitCode()
visitCode in class org.objectweb.asm.MethodVisitorpublic void visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
String type)
visitTryCatchBlock in class org.objectweb.asm.MethodVisitorstart - start label of the try catch blockend - end label of the try catch blockhandler - label of the catch handler of the try catch blocktype - try catch block has a finally block or notpublic void visitLabel(org.objectweb.asm.Label label)
visitLabel in class org.objectweb.asm.MethodVisitorlabel - the label instruction being visitedpublic void visitFrame(int type,
int numLocal,
Object[] local,
int numStack,
Object[] stack)
Opcodes.V1_6. Opcodes.F_SAME representing frame with exactly the same locals as the
previous frame and with the empty stack.
Opcodes.F_SAME1 representing frame with exactly the same locals as the
previous frame and with single value on the stack ( numStack is 1 and
stack[0] contains value for the type of the stack item).
Opcodes.F_APPEND representing frame with current locals are the same as the
locals in the previous frame, except that additional locals are defined (
numLocal is 1, 2 or 3 and local elements contains values
representing added types).
Opcodes.F_CHOP representing frame with current locals are the same as the
locals in the previous frame, except that the last 1-3 locals are absent and with
the empty stack (numLocal is 1, 2 or 3).
Opcodes.F_FULL representing complete frame data.
visitFrame in class org.objectweb.asm.commons.LocalVariablesSortertype - the type of this stack map frame. Must be Opcodes.F_NEW for expanded
frames, or Opcodes.F_FULL, Opcodes.F_APPEND, Opcodes.F_CHOP, Opcodes.F_SAME or Opcodes.F_APPEND, Opcodes.F_SAME1 for compressed frames.numLocal - the number of local variables in the visited frame.local - the local variable types in this frame. This array must not be modified. Primitive
types are represented by Opcodes.TOP, Opcodes.INTEGER, Opcodes.FLOAT, Opcodes.LONG, Opcodes.DOUBLE, Opcodes.NULL or
Opcodes.UNINITIALIZED_THIS (long and double are represented by a single element).
Reference types are represented by String objects (representing internal names), and
uninitialized types by Label objects (this label designates the NEW instruction that
created this uninitialized value).numStack - the number of operand stack elements in the visited frame.stack - the operand stack types in this frame. This array must not be modified. Its
content has the same format as the "local" array.IllegalStateException - if a frame is visited just after another one, without any
instruction between the two (unless this frame is a Opcodes#F_SAME frame, in which case it
is silently ignored).public void visitJumpInsn(int opcode,
org.objectweb.asm.Label label)
visitJumpInsn in class org.objectweb.asm.MethodVisitorpublic void visitMaxs(int maxStack,
int maxLocals)
visitMaxs in class org.objectweb.asm.commons.LocalVariablesSorterpublic void visitTypeInsn(int opcode,
String type)
visitTypeInsn in class org.objectweb.asm.MethodVisitorpublic void visitIntInsn(int opcode,
int operand)
visitIntInsn in class org.objectweb.asm.MethodVisitorpublic void visitMethodInsn(int opcode,
String owner,
String name,
String desc,
boolean itf)
visitMethodInsn in class org.objectweb.asm.MethodVisitorpublic void visitMultiANewArrayInsn(String desc, int dims)
visitMultiANewArrayInsn in class org.objectweb.asm.MethodVisitorpublic void visitIincInsn(int var,
int increment)
visitIincInsn in class org.objectweb.asm.commons.LocalVariablesSorterpublic void visitInsn(int opcode)
visitInsn in class org.objectweb.asm.MethodVisitorpublic void visitInvokeDynamicInsn(String name, String desc, org.objectweb.asm.Handle bsm, Object... bsmArgs)
visitInvokeDynamicInsn in class org.objectweb.asm.MethodVisitorpublic void visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
int[] keys,
org.objectweb.asm.Label[] labels)
visitLookupSwitchInsn in class org.objectweb.asm.MethodVisitorpublic void visitTableSwitchInsn(int min,
int max,
org.objectweb.asm.Label dflt,
org.objectweb.asm.Label... labels)
visitTableSwitchInsn in class org.objectweb.asm.MethodVisitorpublic void visitLdcInsn(Object cst)
visitLdcInsn in class org.objectweb.asm.MethodVisitorpublic void visitFieldInsn(int opcode,
String owner,
String name,
String desc)
visitFieldInsn in class org.objectweb.asm.MethodVisitorpublic void visitVarInsn(int opcode,
int var)
visitVarInsn in class org.objectweb.asm.commons.LocalVariablesSorterCopyright © 2023. All rights reserved.