Example usage for org.objectweb.asm Opcodes ASM4

List of usage examples for org.objectweb.asm Opcodes ASM4

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ASM4.

Prototype

int ASM4

To view the source code for org.objectweb.asm Opcodes ASM4.

Click Source Link

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);
    }/*from   w  ww  .j a va  2 s  .co 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();
}

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

License:Open Source License

private MethodUnresolver(Method m) {
    this.method = m;
    this.methodNode = new MethodNode(Opcodes.ASM4);
    this.registers = new IdentityHashMap<>();
    this.labels = new IdentityHashMap<>();
    TypeFactory tf = m.getParent().getParent().types();
    this.booleanType = tf.getPrimitiveType(boolean.class);
    this.byteType = tf.getPrimitiveType(byte.class);
    this.charType = tf.getPrimitiveType(char.class);
    this.shortType = tf.getPrimitiveType(short.class);
    this.intType = tf.getPrimitiveType(int.class);
    this.longType = tf.getPrimitiveType(long.class);
    this.floatType = tf.getPrimitiveType(float.class);
    this.doubleType = tf.getPrimitiveType(double.class);
}

From source file:edu.ubc.mirrors.holograms.FrameAnalyzerAdaptor.java

License:Open Source License

public FrameAnalyzerAdaptor(VirtualMachineMirror vm, ClassMirrorLoader loader, ClassVisitor cv,
        boolean insertFrames, boolean holograms) {
    super(Opcodes.ASM4, cv);
    this.vm = vm;
    this.loader = loader;
    this.insertFrames = insertFrames;
    this.holograms = holograms;
}

From source file:edu.ubc.mirrors.holograms.HologramClassGenerator.java

License:Open Source License

public HologramClassGenerator(ClassMirror classMirror, ClassVisitor output) {
    super(Opcodes.ASM4, output);
    this.classMirror = classMirror;
}

From source file:edu.ubc.mirrors.holograms.HologramMethodGenerator.java

License:Open Source License

public HologramMethodGenerator(String owner, int access, String name, String desc, MethodVisitor superVisitor,
        boolean isToString, boolean isGetStackTrace) {
    super(Opcodes.ASM4, null);
    this.analyzer = new AnalyzerAdapter(owner, access, name, desc, superVisitor);
    this.mv = analyzer;
    this.name = name;
    this.owner = Type.getObjectType(owner);
    this.access = access;
    this.methodType = Type.getMethodType(desc);
    this.isToString = isToString;
    this.isGetStackTrace = isGetStackTrace;

    activeMethod = name + desc;/*w ww.j  a  va 2s .  com*/
}

From source file:edu.ubc.mirrors.holograms.MainEntryAdaptor.java

License:Open Source License

public MainEntryAdaptor(ClassVisitor output) {
    super(Opcodes.ASM4, output);
}

From source file:edu.ubc.mirrors.test.NativeMethodCounter.java

License:Open Source License

public NativeMethodCounter() {
    super(Opcodes.ASM4);
}

From source file:fi.jumi.threadsafetyagent.AddThreadSafetyChecks.java

License:Open Source License

public AddThreadSafetyChecks(ClassVisitor cv) {
    super(Opcodes.ASM4, cv);
}

From source file:fi.jumi.threadsafetyagent.EnabledWhenAnnotatedWith.java

License:Open Source License

public EnabledWhenAnnotatedWith(String enablerAnnotation, ClassVisitor cv) {
    super(Opcodes.ASM4, cv);
    this.enablerAnnotationDesc = "L" + enablerAnnotation + ";";
}

From source file:instrumentj.impl.InstrumentClassVisitor.java

License:Apache License

/**
 *
 * @param cv//from   w  w  w .  j  a v a 2  s  .c o  m
 * @param className
 */
public InstrumentClassVisitor(final ClassVisitor cv, final String className) {
    super(Opcodes.ASM4, cv);

    if (className == null) {
        throw new NullPointerException("className");
    }

    this.className = className;
}