Example usage for org.objectweb.asm Opcodes ASM5

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

Introduction

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

Prototype

int ASM5

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

Click Source Link

Usage

From source file:com.mogujie.instantrun.TransformAccessClassNode.java

License:Apache License

public TransformAccessClassNode() {
    super(Opcodes.ASM5);
}

From source file:com.navercorp.pinpoint.profiler.instrument.classreading.AnnotationMetadataVisitor.java

License:Apache License

public AnnotationMetadataVisitor() {
    super(Opcodes.ASM5);
}

From source file:com.offbynull.coroutines.instrumenter.asm.SimpleClassNode.java

License:Open Source License

/**
 * Constructs a {@link SimpleClassNode} object.
 */
public SimpleClassNode() {
    super(Opcodes.ASM5);
}

From source file:com.offbynull.coroutines.instrumenter.asm.SimpleVerifier.java

License:Open Source License

/**
 * Constructs a {@link SimpleVerifier} object.
 * @param repo repository to use for deriving class details
 * @throws NullPointerException if any argument is {@code null}
 *//*  ww  w . j av a 2 s.  c  om*/
public SimpleVerifier(ClassInformationRepository repo) {
    super(Opcodes.ASM5, null, null, null, false);

    Validate.notNull(repo);

    this.repo = repo;
}

From source file:com.redhat.byteman.jli.agentasm.JliClassVisitor.java

License:Open Source License

public JliClassVisitor(ClassVisitor cv) {
    super(Opcodes.ASM5, cv);
}

From source file:com.redhat.byteman.jli.agentasm.JliMethodVisitor.java

License:Open Source License

public JliMethodVisitor(MethodVisitor mv) {
    super(Opcodes.ASM5, mv);
}

From source file:com.taobao.android.builder.tools.asm.field.AsmFieldEditor.java

License:Apache License

private static byte[] rewriteBytes(List<Field> fields, ClassReader cr) {
    ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
    ModifyClassVisiter modifyClassVisiter = new ModifyClassVisiter(Opcodes.ASM5, cw);

    for (Field field : fields) {
        modifyClassVisiter.addRemoveField(field.name);
    }//from ww w  .  j a v  a  2s . c o  m
    cr.accept(modifyClassVisiter, Opcodes.ASM5);

    for (Field field : fields) {

        FieldVisitor fv = cw.visitField(field.flag, field.name, Type.getDescriptor(field.value.getClass()),
                null, field.value);
        fv.visitEnd();

    }

    return cw.toByteArray();
}

From source file:com.taobao.asm.AsmTest.java

License:Apache License

@Test
public void test() throws Throwable {

    ClassReader cr = new ClassReader(Config.class.getName());
    ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
    ClassVisitor cv = new MethodChangeClassAdapter(cw);
    cr.accept(cv, Opcodes.ASM5);

    ////from w  w  w .  ja v  a  2s  . c o  m
    MethodVisitor mw = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "add", "([Ljava/lang/String;)V", null, null);

    // pushes the 'out' field (of type PrintStream) of the System class
    mw.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
    // pushes the "Hello World!" String constant
    mw.visitLdcInsn("this is add method print!");
    // invokes the 'println' method (defined in the PrintStream class)
    mw.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V");
    mw.visitInsn(RETURN);
    // this code uses a maximum of two stack elements and two local
    // variables
    mw.visitMaxs(0, 0);
    mw.visitEnd();

    //Type.getDescriptor(AdviceFlowOuterHolder.class)
    FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC + ACC_FINAL, "age", Type.INT_TYPE.toString(), null,
            1);
    fv.visitEnd();

    FieldVisitor fv2 = cw.visitField(ACC_PUBLIC + ACC_STATIC + ACC_FINAL, "name2",
            Type.getDescriptor(String.class), null, "name2");
    fv2.visitEnd();

    ModifyClassVisiter cv2 = new ModifyClassVisiter(Opcodes.ASM5);
    cv2.addRemoveField("name");
    cr.accept(cv2, Opcodes.ASM5);

    FieldVisitor fv3 = cw.visitField(ACC_PUBLIC + ACC_STATIC + ACC_FINAL, "name",
            Type.getDescriptor(String.class), null, "name");
    fv3.visitEnd();

    byte[] code = cw.toByteArray();
    File file = new File("Config.class");
    System.out.println(file.getAbsolutePath());
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(code);
    fos.close();

}

From source file:com.tencent.tinker.build.auxiliaryclass.AuxiliaryClassInjectAdapter.java

License:Open Source License

public AuxiliaryClassInjectAdapter(String auxiliaryClassName, ClassWriter cw) {
    super(Opcodes.ASM5, cw);
    this.auxiliaryClassDesc = fastClassNameToDesc(auxiliaryClassName);
}

From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java

License:MIT License

/**
 * Generate a new method "boolean name()", which returns a constant value.
 *
 * @param clazz Class to add method to/* www  .  j a v a  2s  .  com*/
 * @param name Name of method
 * @param retval Return value of method
 */
public static void generateBooleanMethodConst(ClassNode clazz, String name, boolean retval) {
    MethodNode method = new MethodNode(Opcodes.ASM5, Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, name, "()Z",
            null, null);
    InsnList code = method.instructions;

    code.add(ASMHelper.pushIntConstant(retval ? 1 : 0));
    code.add(new InsnNode(Opcodes.IRETURN));

    clazz.methods.add(method);
}