Top Fields Constructors Methods
org.glassfish.pfl.tf.tools.enhancer

public Class SimpleMethodTracer

extends MethodVisitor
Class Inheritance
Imports
java.util.Arrays, .HashSet, .Set, org.glassfish.pfl.tf.spi.Util, org.objectweb.asm.AnnotationVisitor, .Attribute, .Label, .MethodVisitor, .Opcodes

Author
ken

Field Summary

Modifier and TypeField and Description
pack-priv final Util
pack-priv final Set<Label>
Inherited from org.objectweb.asm.MethodVisitor:
apimv

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String
getFrameType(int type)

private void
msg(String str)

public AnnotationVisitor
visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.MethodVisitor.visitAnnotation.

Visits an annotation of this method.

public AnnotationVisitor
visitAnnotationDefault()

Overrides org.objectweb.asm.MethodVisitor.visitAnnotationDefault.

Visits the default value of this annotation interface method.

public void
visitAttribute(Attribute attr)

Overrides org.objectweb.asm.MethodVisitor.visitAttribute.

Visits a non standard attribute of this method.

public void
visitCode()

Overrides org.objectweb.asm.MethodVisitor.visitCode.

Starts the visit of the method's code, if any (i.e. non abstract method).

public void
visitEnd()

Overrides org.objectweb.asm.MethodVisitor.visitEnd.

Visits the end of the method.

public void
visitFieldInsn(int opcode, String owner, String name, String desc)

Overrides org.objectweb.asm.MethodVisitor.visitFieldInsn.

Visits a field instruction.

public void
visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack)

Overrides org.objectweb.asm.MethodVisitor.visitFrame.

Visits the current state of the local variables and operand stack elements.

public void
visitIincInsn(int var, int increment)

Overrides org.objectweb.asm.MethodVisitor.visitIincInsn.

Visits an IINC instruction.

public void
visitInsn(int opcode)

Overrides org.objectweb.asm.MethodVisitor.visitInsn.

Visits a zero operand instruction.

public void
visitIntInsn(int opcode, int operand)

Overrides org.objectweb.asm.MethodVisitor.visitIntInsn.

Visits an instruction with a single int operand.

public void
visitJumpInsn(int opcode, Label label)

Overrides org.objectweb.asm.MethodVisitor.visitJumpInsn.

Visits a jump instruction.

public void
public void
visitLdcInsn(Object cst)

Overrides org.objectweb.asm.MethodVisitor.visitLdcInsn.

Visits a LDC instruction.

public void
visitLineNumber(int line, Label start)

Overrides org.objectweb.asm.MethodVisitor.visitLineNumber.

Visits a line number declaration.

public void
visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)

Overrides org.objectweb.asm.MethodVisitor.visitLocalVariable.

Visits a local variable declaration.

public void
visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)

Overrides org.objectweb.asm.MethodVisitor.visitLookupSwitchInsn.

Visits a LOOKUPSWITCH instruction.

public void
visitMaxs(int maxStack, int maxLocals)

Overrides org.objectweb.asm.MethodVisitor.visitMaxs.

Visits the maximum stack size and the maximum number of local variables of the method.

public void
visitMethodInsn(int opcode, String owner, String name, String desc, boolean isInterface)

Overrides org.objectweb.asm.MethodVisitor.visitMethodInsn.

Visits a method instruction.

public void
visitMultiANewArrayInsn(String desc, int dims)

Overrides org.objectweb.asm.MethodVisitor.visitMultiANewArrayInsn.

Visits a MULTIANEWARRAY instruction.

public AnnotationVisitor
visitParameterAnnotation(int parameter, String desc, boolean visible)

Overrides org.objectweb.asm.MethodVisitor.visitParameterAnnotation.

Visits an annotation of a parameter this method.

public void
visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels)

Overrides org.objectweb.asm.MethodVisitor.visitTableSwitchInsn.

Visits a TABLESWITCH instruction.

public void
visitTryCatchBlock(Label start, Label end, Label handler, String type)

Overrides org.objectweb.asm.MethodVisitor.visitTryCatchBlock.

Visits a try catch block.

public void
visitTypeInsn(int opcode, String type)

Overrides org.objectweb.asm.MethodVisitor.visitTypeInsn.

Visits a type instruction.

public void
visitVarInsn(int opcode, int var)

Overrides org.objectweb.asm.MethodVisitor.visitVarInsn.

Visits a local variable instruction.

Inherited from org.objectweb.asm.MethodVisitor:
getDelegatevisitAnnotableParameterCountvisitInsnAnnotationvisitInvokeDynamicInsnvisitLocalVariableAnnotationvisitMethodInsnvisitParametervisitTryCatchAnnotationvisitTypeAnnotation

Field Detail

utilback to summary
pack-priv final Util util
visitedLablesback to summary
pack-priv final Set<Label> visitedLables

Constructor Detail

SimpleMethodTracerback to summary
public SimpleMethodTracer(MethodVisitor mv, Util util)

Method Detail

getFrameTypeback to summary
private String getFrameType(int type)
msgback to summary
private void msg(String str)
visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.MethodVisitor.visitAnnotation.

Doc from org.objectweb.asm.MethodVisitor.visitAnnotation.

Visits an annotation of this method.

visitAnnotationDefaultback to summary
public AnnotationVisitor visitAnnotationDefault()

Overrides org.objectweb.asm.MethodVisitor.visitAnnotationDefault.

Doc from org.objectweb.asm.MethodVisitor.visitAnnotationDefault.

Visits the default value of this annotation interface method.

visitAttributeback to summary
public void visitAttribute(Attribute attr)

Overrides org.objectweb.asm.MethodVisitor.visitAttribute.

Doc from org.objectweb.asm.MethodVisitor.visitAttribute.

Visits a non standard attribute of this method.

visitCodeback to summary
public void visitCode()

Overrides org.objectweb.asm.MethodVisitor.visitCode.

Doc from org.objectweb.asm.MethodVisitor.visitCode.

Starts the visit of the method's code, if any (i.e. non abstract method).

visitEndback to summary
public void visitEnd()

Overrides org.objectweb.asm.MethodVisitor.visitEnd.

Doc from org.objectweb.asm.MethodVisitor.visitEnd.

Visits the end of the method. This method, which is the last one to be called, is used to inform the visitor that all the annotations and attributes of the method have been visited.

visitFieldInsnback to summary
public void visitFieldInsn(int opcode, String owner, String name, String desc)

Overrides org.objectweb.asm.MethodVisitor.visitFieldInsn.

Doc from org.objectweb.asm.MethodVisitor.visitFieldInsn.

Visits a field instruction. A field instruction is an instruction that loads or stores the value of a field of an object.

visitFrameback to summary
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack)

Overrides org.objectweb.asm.MethodVisitor.visitFrame.

Doc from org.objectweb.asm.MethodVisitor.visitFrame.

Visits the current state of the local variables and operand stack elements. This method must(*) be called just before any instruction i that follows an unconditional branch instruction such as GOTO or THROW, that is the target of a jump instruction, or that starts an exception handler block. The visited types must describe the values of the local variables and of the operand stack elements just before i is executed.

(*) this is mandatory only for classes whose version is greater than or equal to Opcodes#V1_6.

The frames of a method must be given either in expanded form, or in compressed form (all frames must use the same format, i.e. you must not mix expanded and compressed frames within a single method):

  • In expanded form, all frames must have the F_NEW type.
  • In compressed form, frames are basically "deltas" from the state of the previous frame:
    • 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.

In both cases the first frame, corresponding to the method's parameters and access flags, is implicit and must not be visited. Also, it is illegal to visit two or more frames for the same code location (i.e., at least one instruction must be visited between two calls to visitFrame).
visitIincInsnback to summary
public void visitIincInsn(int var, int increment)

Overrides org.objectweb.asm.MethodVisitor.visitIincInsn.

Doc from org.objectweb.asm.MethodVisitor.visitIincInsn.

Visits an IINC instruction.

visitInsnback to summary
public void visitInsn(int opcode)

Overrides org.objectweb.asm.MethodVisitor.visitInsn.

Doc from org.objectweb.asm.MethodVisitor.visitInsn.

Visits a zero operand instruction.

visitIntInsnback to summary
public void visitIntInsn(int opcode, int operand)

Overrides org.objectweb.asm.MethodVisitor.visitIntInsn.

Doc from org.objectweb.asm.MethodVisitor.visitIntInsn.

Visits an instruction with a single int operand.

visitJumpInsnback to summary
public void visitJumpInsn(int opcode, Label label)

Overrides org.objectweb.asm.MethodVisitor.visitJumpInsn.

Doc from org.objectweb.asm.MethodVisitor.visitJumpInsn.

Visits a jump instruction. A jump instruction is an instruction that may jump to another instruction.

visitLabelback to summary
public void visitLabel(Label label)

Overrides org.objectweb.asm.MethodVisitor.visitLabel.

Doc from org.objectweb.asm.MethodVisitor.visitLabel.

Visits a label. A label designates the instruction that will be visited just after it.

visitLdcInsnback to summary
public void visitLdcInsn(Object cst)

Overrides org.objectweb.asm.MethodVisitor.visitLdcInsn.

Doc from org.objectweb.asm.MethodVisitor.visitLdcInsn.

Visits a LDC instruction. Note that new constant types may be added in future versions of the Java Virtual Machine. To easily detect new constant types, implementations of this method should check for unexpected constant types, like this:

if (cst instanceof Integer) {
    // ...
} else if (cst instanceof Float) {
    // ...
} else if (cst instanceof Long) {
    // ...
} else if (cst instanceof Double) {
    // ...
} else if (cst instanceof String) {
    // ...
} else if (cst instanceof Type) {
    int sort = ((Type) cst).getSort();
    if (sort == Type.OBJECT) {
        // ...
    } else if (sort == Type.ARRAY) {
        // ...
    } else if (sort == Type.METHOD) {
        // ...
    } else {
        // throw an exception
    }
} else if (cst instanceof Handle) {
    // ...
} else if (cst instanceof ConstantDynamic) {
    // ...
} else {
    // throw an exception
}
visitLineNumberback to summary
public void visitLineNumber(int line, Label start)

Overrides org.objectweb.asm.MethodVisitor.visitLineNumber.

Doc from org.objectweb.asm.MethodVisitor.visitLineNumber.

Visits a line number declaration.

visitLocalVariableback to summary
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)

Overrides org.objectweb.asm.MethodVisitor.visitLocalVariable.

Doc from org.objectweb.asm.MethodVisitor.visitLocalVariable.

Visits a local variable declaration.

visitLookupSwitchInsnback to summary
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)

Overrides org.objectweb.asm.MethodVisitor.visitLookupSwitchInsn.

Doc from org.objectweb.asm.MethodVisitor.visitLookupSwitchInsn.

Visits a LOOKUPSWITCH instruction.

visitMaxsback to summary
public void visitMaxs(int maxStack, int maxLocals)

Overrides org.objectweb.asm.MethodVisitor.visitMaxs.

Doc from org.objectweb.asm.MethodVisitor.visitMaxs.

Visits the maximum stack size and the maximum number of local variables of the method.

visitMethodInsnback to summary
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean isInterface)

Overrides org.objectweb.asm.MethodVisitor.visitMethodInsn.

Doc from org.objectweb.asm.MethodVisitor.visitMethodInsn.

Visits a method instruction. A method instruction is an instruction that invokes a method.

visitMultiANewArrayInsnback to summary
public void visitMultiANewArrayInsn(String desc, int dims)

Overrides org.objectweb.asm.MethodVisitor.visitMultiANewArrayInsn.

Doc from org.objectweb.asm.MethodVisitor.visitMultiANewArrayInsn.

Visits a MULTIANEWARRAY instruction.

visitParameterAnnotationback to summary
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible)

Overrides org.objectweb.asm.MethodVisitor.visitParameterAnnotation.

Doc from org.objectweb.asm.MethodVisitor.visitParameterAnnotation.

Visits an annotation of a parameter this method.

visitTableSwitchInsnback to summary
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels)

Overrides org.objectweb.asm.MethodVisitor.visitTableSwitchInsn.

Doc from org.objectweb.asm.MethodVisitor.visitTableSwitchInsn.

Visits a TABLESWITCH instruction.

visitTryCatchBlockback to summary
public void visitTryCatchBlock(Label start, Label end, Label handler, String type)

Overrides org.objectweb.asm.MethodVisitor.visitTryCatchBlock.

Doc from org.objectweb.asm.MethodVisitor.visitTryCatchBlock.

Visits a try catch block.

visitTypeInsnback to summary
public void visitTypeInsn(int opcode, String type)

Overrides org.objectweb.asm.MethodVisitor.visitTypeInsn.

Doc from org.objectweb.asm.MethodVisitor.visitTypeInsn.

Visits a type instruction. A type instruction is an instruction that takes the internal name of a class as parameter (see Type#getInternalName()).

visitVarInsnback to summary
public void visitVarInsn(int opcode, int var)

Overrides org.objectweb.asm.MethodVisitor.visitVarInsn.

Doc from org.objectweb.asm.MethodVisitor.visitVarInsn.

Visits a local variable instruction. A local variable instruction is an instruction that loads or stores the value of a local variable.