Package org.ow2.asm

Examples of org.ow2.asm.ClassReader.accept()


        SAXTransformerFactory saxtf = (SAXTransformerFactory) TransformerFactory.newInstance();
        TransformerHandler handler = saxtf.newTransformerHandler();
        handler.setResult(new SAXResult(new ASMContentHandler(cw)));
        handler.startDocument();
        cr.accept(new SAXClassAdapter(handler, false), 0);
        handler.endDocument();
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bos.write(cw.toByteArray());
View Full Code Here


       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bos.write(cw.toByteArray());

        ClassWriter cw2 = new ClassWriter(0);
        cr.accept(cw2, new Attribute[] { new Attribute("Comment") {
            @Override
            protected Attribute read(
                final ClassReader cr,
                final int off,
                final int len,
View Full Code Here

    @Override
    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        ClassWriter cw = new ClassWriter(0);
        cr.accept(new ClassAdapter(cw) {
            @Override
            public MethodVisitor visitMethod(
                final int access,
                final String name,
                final String desc,
View Full Code Here

    @Override
    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        ClassWriter cw1 = new ClassWriter(0);
        ClassWriter cw2 = new ClassWriter(0);
        cr.accept(new ReferenceClassAdapter(cw1), ClassReader.EXPAND_FRAMES);
        cr.accept(new AdviceClassAdapter(cw2), ClassReader.EXPAND_FRAMES);
        assertEquals(new ClassReader(cw1.toByteArray()),
                new ClassReader(cw2.toByteArray()));
    }
View Full Code Here

    @Override
    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        ClassNode cn = new ClassNode();
        cr.accept(cn, 0);
        // clone instructions for testing clone methods
        for (int i = 0; i < cn.methods.size(); ++i) {
            MethodNode mn = cn.methods.get(i);
            Iterator<AbstractInsnNode> it = mn.instructions.iterator();
            Map<LabelNode, LabelNode> m = new HashMap<LabelNode, LabelNode>() {
View Full Code Here

    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        ClassWriter cw1 = new ClassWriter(0);
        ClassWriter cw2 = new ClassWriter(0);
        cr.accept(new ReferenceClassAdapter(cw1), ClassReader.EXPAND_FRAMES);
        cr.accept(new AdviceClassAdapter(cw2), ClassReader.EXPAND_FRAMES);
        assertEquals(new ClassReader(cw1.toByteArray()),
                new ClassReader(cw2.toByteArray()));
    }

    static class ReferenceClassAdapter extends ClassAdapter {
View Full Code Here

    @Override
    public void generate(final String dir) throws IOException {
        byte[] b = dump();
        ClassWriter cw = new ClassWriter(0);
        ClassReader cr = new ClassReader(b);
        cr.accept(new RenameAdapter(cw), ClassReader.EXPAND_FRAMES);

        generate(dir, "pkg/FrameTable.class", b);
        generate(dir, "pkg/FrameMap.class", cw.toByteArray());
    }
View Full Code Here

    }

    static byte[] transformClass(final byte[] clazz) {
        ClassReader cr = new ClassReader(clazz);
        ClassWriter cw = new ClassWriter(0);
        cr.accept(new ClassAdapter(cw) {

            @Override
            public MethodVisitor visitMethod(
                final int access,
                final String name,
View Full Code Here

            StringWriter sw1 = new StringWriter();
            StringWriter sw2 = new StringWriter();
            sw2.write(ve.toString() + "\n");
            ClassVisitor cv1 = new TraceClassVisitor(new PrintWriter(sw1));
            ClassVisitor cv2 = new TraceClassVisitor(new PrintWriter(sw2));
            cr.accept(cv1, 0);
            new ClassReader(b).accept(cv2, 0);
            String s1 = sw1.toString();
            String s2 = sw2.toString();
            assertEquals("different data", s1, s2);
        }
View Full Code Here

                    }
                };
            }
        };
        try {
            cr.accept(cv, ClassReader.EXPAND_FRAMES);
            fail();
        } catch (Exception e) {
        }
    }
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.