Package org.objectweb.asm

Examples of org.objectweb.asm.ClassWriter.visitMethod()


    mw.visitInsn(RETURN);
    mw.visitMaxs(0, 0);
    mw.visitEnd();

    // 定义类的merge方法
    mw = cw.visitMethod(ACC_PUBLIC, "merge", "(L" + Context.NAME
        + ";Ljava/io/Writer;)V", null, null);
    mw.visitVarInsn(ALOAD, CONTEXT);
    mw.visitMethodInsn(INVOKEVIRTUAL, Context.NAME, "getTemplate", "()L"
        + Template.NAME + ";");
    mw.visitVarInsn(ASTORE, TEMPLATE);
View Full Code Here


    MethodVisitor mw;
    String name = "test";
    cw.visit(V1_5, ACC_PUBLIC, name, null, "java/lang/Object",
        new String[] { IParser.NAME });

    mw = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mw.visitVarInsn(ALOAD, THIS);
    mw.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    mw.visitInsn(RETURN);
    mw.visitMaxs(0, 0);
    mw.visitEnd();
View Full Code Here

    mw.visitInsn(RETURN);
    mw.visitMaxs(0, 0);
    mw.visitEnd();

    // 定义类的merge方法
    mw = cw.visitMethod(ACC_PUBLIC, "merge", "(L" + Context.NAME
        + ";Ljava/io/Writer;)V", null, null);
    mw.visitVarInsn(ALOAD, CONTEXT);
    mw.visitMethodInsn(INVOKEVIRTUAL, Context.NAME, "getTemplate", "()L"
        + Template.NAME + ";");
    mw.visitVarInsn(ASTORE, TEMPLATE);
View Full Code Here

    MethodVisitor mw;
    name = "template";
    cw.visit(V1_5, ACC_PUBLIC, name, null, "java/lang/Object", INTERFACES);

    // 定义类的构造方法
    mw = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mw.visitVarInsn(ALOAD, THIS);
    mw.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    mw.visitInsn(RETURN);
    mw.visitMaxs(0, 0);
    mw.visitEnd();
View Full Code Here

    mw.visitInsn(RETURN);
    mw.visitMaxs(0, 0);
    mw.visitEnd();

    // 定义类的merge方法
    mw = cw.visitMethod(ACC_PUBLIC, "merge", "(L" + Context.NAME
        + ";Ljava/io/Writer;)V", null, null);
    mw.visitVarInsn(ALOAD, CONTEXT);
    mw.visitMethodInsn(INVOKEVIRTUAL, Context.NAME, "getTemplate", "()L" + NAME
        + ";");
    mw.visitVarInsn(ASTORE, TEMPLATE);
View Full Code Here

    MethodVisitor mw;
    name = "template";
    cw.visit(V1_5, ACC_PUBLIC, name, null, "java/lang/Object", INTERFACES);

    // 定义类的构造方法
    mw = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mw.visitVarInsn(ALOAD, THIS);
    mw.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    mw.visitInsn(RETURN);
    mw.visitMaxs(0, 0);
    mw.visitEnd();
View Full Code Here

    mw.visitInsn(RETURN);
    mw.visitMaxs(0, 0);
    mw.visitEnd();

    // 定义类的merge方法
    mw = cw.visitMethod(ACC_PUBLIC, "merge", "(L" + Context.NAME
        + ";Ljava/io/Writer;)V", null, null);
    mw.visitVarInsn(ALOAD, CONTEXT);
    mw.visitMethodInsn(INVOKEVIRTUAL, Context.NAME, "getTemplate", "()L" + NAME
        + ";");
    mw.visitVarInsn(ASTORE, TEMPLATE);
View Full Code Here

    "org/objectweb/speedo/mapper/lib/Object2StringSerializer", //superName
    new String[0], //interfaces
    str // sourcefile
    );
    //implement an empty public constructor
    CodeVisitor c = cw.visitMethod(Constants.ACC_PUBLIC, "<init>", "()V", null, null);
    c.visitVarInsn(Constants.ALOAD, 0);
    c.visitMethodInsn(
      Constants.INVOKESPECIAL,
      "org/objectweb/speedo/mapper/lib/Object2StringSerializer",
      "<init>",
View Full Code Here

      "()V");
    c.visitInsn(Constants.RETURN);
    c.visitMaxs(0, 0);

    //implement the getSerializedObject method
    c = cw.visitMethod(Constants.ACC_PUBLIC, "getSerializedObject", "()Ljava/lang/String;", null, null);
    c.visitTypeInsn(Constants.NEW, "java/lang/StringBuffer");
    c.visitInsn(Constants.DUP);
    c.visitMethodInsn(Constants.INVOKESPECIAL, "java/lang/StringBuffer", "<init>", "()V");
    final int SPLIT_SIZE = 5000;
    int nbSplit = value.length() / SPLIT_SIZE;
View Full Code Here

    }

    private void loadMagic() {
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        cw.visit(Opcodes.V1_4, Opcodes.ACC_PUBLIC, "sun/reflect/GroovyMagic", null, "sun/reflect/MagicAccessorImpl", null);
        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "sun/reflect/MagicAccessorImpl", "<init>", "()V");
        mv.visitInsn(RETURN);
        mv.visitMaxs(0,0);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.