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

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

Introduction

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

Prototype

public void visitFieldInsn(final int opcode, final String owner, final String name, final String descriptor) 

Source Link

Document

Visits a field 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;/*from   w w  w .j  a v a  2  s  . c o 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());
}