Package org.ow2.asm

Examples of org.ow2.asm.MethodVisitor


        } catch (Exception e) {
        }
    }

    public void testIllegalMethodInsnVisitBeforeStart() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        try {
            mv.visitInsn(NOP);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here


        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }

    private void returnInsns(final ClassWriter cw) {
        MethodVisitor mv;
        mv = cw.visitMethod(ACC_STATIC, "ireturnInsn", "()I", null, null);
        mv.visitCode();
        mv.visitInsn(ICONST_0);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
        mv = cw.visitMethod(ACC_PRIVATE, "lreturnInsn", "()J", null, null);
        mv.visitCode();
        mv.visitInsn(LCONST_0);
        mv.visitInsn(LRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
        mv = cw.visitMethod(0, "freturnInsn", "()F", null, null);
        mv.visitCode();
        mv.visitInsn(FCONST_0);
        mv.visitInsn(FRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
        mv = cw.visitMethod(0, "dreturnInsn", "()D", null, null);
        mv.visitCode();
        mv.visitInsn(DCONST_0);
        mv.visitInsn(DRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void testIllegalFrameType() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitFrame(123, 0, null, 0, null);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void testIllegalFrameLocalCount() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitFrame(F_SAME, 1, new Object[] { INTEGER }, 0, null);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void testIllegalFrameStackCount() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitFrame(F_SAME, 0, null, 1, new Object[] { INTEGER });
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void testIllegalFrameLocalArray() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitFrame(F_APPEND, 1, new Object[0], 0, null);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void testIllegalFrameStackArray() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitFrame(F_SAME1, 0, null, 1, new Object[0]);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void testIllegalFrameValue() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitFrame(F_FULL, 1, new Object[] { "LC;" }, 0, null);
            fail();
        } catch (Exception e) {
        }
        try {
            mv.visitFrame(F_FULL, 1, new Object[] { new Integer(0) }, 0, null);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }

    private void fieldInsns(final ClassWriter cw) {
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC,
                "fieldInsns",
                "()V",
                null,
                null);
        mv.visitFieldInsn(GETSTATIC, "pkg/Insns", "s", "S");
        mv.visitFieldInsn(PUTSTATIC, "pkg/Insns", "s", "S");
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, "pkg/Insns", "i", "I");
        mv.visitFieldInsn(PUTFIELD, "pkg/Insns", "i", "I");
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, "pkg/Insns", "l", "J");
        mv.visitFieldInsn(PUTFIELD, "pkg/Insns", "l", "J");
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void testIllegalMethodInsn() {
        MethodVisitor mv = new CheckMethodAdapter(new EmptyVisitor());
        mv.visitCode();
        try {
            mv.visitInsn(-1);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

TOP

Related Classes of org.ow2.asm.MethodVisitor

Copyright © 2018 www.massapicom. 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.