Example usage for org.objectweb.asm.commons LocalVariablesSorter visitMethodInsn

List of usage examples for org.objectweb.asm.commons LocalVariablesSorter visitMethodInsn

Introduction

In this page you can find the example usage for org.objectweb.asm.commons LocalVariablesSorter visitMethodInsn.

Prototype

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

Source Link

Document

Visits a method instruction.

Usage

From source file:rubah.bytecode.transformers.AddTraverseMethod.java

License:Open Source License

protected void generateFieldAccess(LocalVariablesSorter mv, Pair<String, String> field) {
    Type fieldType = Type.getType(field.getValue1());

    if (!isAllowed(fieldType.getClassName())) {
        return;/*w w  w. ja  v  a  2 s  .co m*/
    }

    this.getFieldOwner(mv);
    mv.visitInsn(DUP);

    mv.visitFieldInsn(GETFIELD, this.thisClass.getASMType().getInternalName(), field.getValue0(),
            field.getValue1());
    mv.visitMethodInsn(INVOKESTATIC, REGISTER_METHOD_OWNER_NAME, REGISTER_METHOD_NAME,
            REGISTER_METHOD_SIMPLE_DESC, false);
    if (this.version != null) {
        mv.visitTypeInsn(CHECKCAST, this.version.eraseUpdatableType(this.namespace.getClass(fieldType))
                .getASMType().getInternalName());
    } else {
        mv.visitTypeInsn(CHECKCAST, fieldType.getInternalName());
    }
    mv.visitFieldInsn(PUTFIELD, this.thisClass.getASMType().getInternalName(), field.getValue0(),
            field.getValue1());
}