Example usage for org.objectweb.asm.tree FieldNode FieldNode

List of usage examples for org.objectweb.asm.tree FieldNode FieldNode

Introduction

In this page you can find the example usage for org.objectweb.asm.tree FieldNode FieldNode.

Prototype

public FieldNode(final int api, final int access, final String name, final String descriptor,
        final String signature, final Object value) 

Source Link

Document

Constructs a new FieldNode .

Usage

From source file:edu.mit.streamjit.util.bytecode.KlassUnresolver.java

License:Open Source License

private byte[] unresolve() {
    this.classNode.version = Opcodes.V1_7;
    this.classNode.access = Modifier.toBits(klass.modifiers());
    this.classNode.name = internalName(klass);
    assert klass.getSuperclass() != null || Object.class.equals(klass.getBackingClass()) : klass;
    this.classNode.superName = internalName(klass.getSuperclass());
    for (Klass k : klass.interfaces())
        this.classNode.interfaces.add(internalName(k));

    for (Field f : klass.fields()) {
        FieldNode fn = new FieldNode(Opcodes.ASM4, Modifier.toBits(f.modifiers()), f.getName(),
                f.getType().getFieldType().getDescriptor(), null, null);
        this.classNode.fields.add(fn);
    }/*w  ww  .  j  a  v  a  2  s  .  c o  m*/

    for (Method m : klass.methods())
        this.classNode.methods.add(MethodUnresolver.unresolve(m));

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    ClassVisitor cv = cw;
    //      boolean assertionsEnabled = false;
    //      assert assertionsEnabled = true; //intentional side effect
    //      if (assertionsEnabled)
    //         cv = new CheckClassAdapter(cv, true);
    classNode.accept(cv);
    return cw.toByteArray();
}