Java 类org.objectweb.asm.attrs.Comment 实例源码

项目:asm-legacy-svn-clone    文件:CheckClassAdapterUnitTest.java   
public void testIllegalFieldMemberVisitAfterEnd() {
    FieldVisitor fv = new CheckFieldAdapter(null);
    fv.visitEnd();
    try {
        fv.visitAttribute(new Comment());
        fail();
    } catch (Exception e) {
    }
}
项目:asm-legacy-svn-clone    文件:CheckClassAdapterUnitTest.java   
public void testIllegalMethodMemberVisitAfterEnd() {
    MethodVisitor mv = new CheckMethodAdapter(null);
    mv.visitEnd();
    try {
        mv.visitAttribute(new Comment());
        fail();
    } catch (Exception e) {
    }
}
项目:asm-legacy-svn-clone    文件:TraceClassAdapterTest.java   
@Override
public void test() throws Exception {
    ClassReader cr = new ClassReader(is);
    ClassWriter cw = new ClassWriter(0);
    ClassVisitor cv = new TraceClassVisitor(cw, new PrintWriter(
            new CharArrayWriter()));
    cr.accept(cv, new Attribute[] { new Comment(), new CodeComment() }, 0);
    assertEquals(cr, new ClassReader(cw.toByteArray()));
}
项目:ow2-asm    文件:CheckClassAdapterUnitTest.java   
public void testIllegalFieldMemberVisitAfterEnd() {
    FieldVisitor fv = new CheckFieldAdapter(null);
    fv.visitEnd();
    try {
        fv.visitAttribute(new Comment());
        fail();
    } catch (Exception e) {
    }
}
项目:ow2-asm    文件:CheckClassAdapterUnitTest.java   
public void testIllegalMethodMemberVisitAfterEnd() {
    MethodVisitor mv = new CheckMethodAdapter(null);
    mv.visitEnd();
    try {
        mv.visitAttribute(new Comment());
        fail();
    } catch (Exception e) {
    }
}
项目:ow2-asm    文件:TraceClassAdapterTest.java   
@Override
public void test() throws Exception {
    ClassReader cr = new ClassReader(is);
    ClassWriter cw = new ClassWriter(0);
    ClassVisitor cv = new TraceClassVisitor(cw, new PrintWriter(
            new CharArrayWriter()));
    cr.accept(cv, new Attribute[] { new Comment(), new CodeComment() }, 0);
    assertEquals(cr, new ClassReader(cw.toByteArray()));
}
项目:objectweb-asm-4.0    文件:CheckClassAdapterUnitTest.java   
public void testIllegalFieldMemberVisitAfterEnd() {
    FieldVisitor fv = new CheckFieldAdapter(null);
    fv.visitEnd();
    try {
        fv.visitAttribute(new Comment());
        fail();
    } catch (Exception e) {
    }
}
项目:objectweb-asm-4.0    文件:CheckClassAdapterUnitTest.java   
public void testIllegalMethodMemberVisitAfterEnd() {
    MethodVisitor mv = new CheckMethodAdapter(null);
    mv.visitEnd();
    try {
        mv.visitAttribute(new Comment());
        fail();
    } catch (Exception e) {
    }
}
项目:objectweb-asm-4.0    文件:TraceClassAdapterTest.java   
@Override
public void test() throws Exception {
    ClassReader cr = new ClassReader(is);
    ClassWriter cw = new ClassWriter(0);
    ClassVisitor cv = new TraceClassVisitor(cw,
            new PrintWriter(new CharArrayWriter()));
    cr.accept(cv, new Attribute[] { new Comment(), new CodeComment() }, 0);
    assertEquals(cr, new ClassReader(cw.toByteArray()));
}
项目:asm-legacy-svn-clone    文件:Attribute.java   
public byte[] dump() {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    FieldVisitor fv;
    MethodVisitor mv;

    cw.visit(V1_3, ACC_PUBLIC + ACC_SYNTHETIC, "pkg/Attribute", null,
            "java/lang/Object", null);

    cw.visitAttribute(new Comment());

    fv = cw.visitField(ACC_PUBLIC, "f", "I", null, null);
    fv.visitAttribute(new Comment());
    fv.visitEnd();

    mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitAttribute(new Comment());
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V",
            false);

    /*
     * the following instructions are designed so that this method will be
     * resized by the method resizing test, in order to cover the code that
     * recomputes the code attribute labels in the resizeInstructions method
     * (see MethodWriter).
     */
    Label l0 = new Label();
    mv.visitInsn(ICONST_0);
    mv.visitJumpInsn(IFEQ, l0);
    // many NOPs will be introduced here by the method resizing test
    mv.visitJumpInsn(GOTO, l0);
    mv.visitLabel(l0);

    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitAttribute(new CodeComment());
    mv.visitEnd();

    cw.visitEnd();
    return cw.toByteArray();
}
项目:ow2-asm    文件:Attribute.java   
public byte[] dump() {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    FieldVisitor fv;
    MethodVisitor mv;

    cw.visit(V1_3, ACC_PUBLIC + ACC_SYNTHETIC, "pkg/Attribute", null,
            "java/lang/Object", null);

    cw.visitAttribute(new Comment());

    fv = cw.visitField(ACC_PUBLIC, "f", "I", null, null);
    fv.visitAttribute(new Comment());
    fv.visitEnd();

    mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitAttribute(new Comment());
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");

    /*
     * the following instructions are designed so that this method will be
     * resized by the method resizing test, in order to cover the code that
     * recomputes the code attribute labels in the resizeInstructions method
     * (see MethodWriter).
     */
    Label l0 = new Label();
    mv.visitInsn(ICONST_0);
    mv.visitJumpInsn(IFEQ, l0);
    // many NOPs will be introduced here by the method resizing test
    mv.visitJumpInsn(GOTO, l0);
    mv.visitLabel(l0);

    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitAttribute(new CodeComment());
    mv.visitEnd();

    cw.visitEnd();
    return cw.toByteArray();
}
项目:objectweb-asm-4.0    文件:Attribute.java   
public byte[] dump() {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    FieldVisitor fv;
    MethodVisitor mv;

    cw.visit(V1_3,
            ACC_PUBLIC + ACC_SYNTHETIC,
            "pkg/Attribute",
            null,
            "java/lang/Object",
            null);

    cw.visitAttribute(new Comment());

    fv = cw.visitField(ACC_PUBLIC, "f", "I", null, null);
    fv.visitAttribute(new Comment());
    fv.visitEnd();

    mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitAttribute(new Comment());
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");

    /*
     * the following instructions are designed so that this method will be
     * resized by the method resizing test, in order to cover the code that
     * recomputes the code attribute labels in the resizeInstructions method
     * (see MethodWriter).
     */
    Label l0 = new Label();
    mv.visitInsn(ICONST_0);
    mv.visitJumpInsn(IFEQ, l0);
    // many NOPs will be introduced here by the method resizing test
    mv.visitJumpInsn(GOTO, l0);
    mv.visitLabel(l0);

    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitAttribute(new CodeComment());
    mv.visitEnd();

    cw.visitEnd();
    return cw.toByteArray();
}