Package org.ow2.easybeans.asm

Examples of org.ow2.easybeans.asm.ClassWriter.toByteArray()


                null);
        mv.visitEnd();

        cw.visitEnd();

        return cw.toByteArray();
    }
}
View Full Code Here


            mv.visitInsn(ARETURN);
            // max stack and max locals automatically computed
            mv.visitMaxs(0, 0);
            mv.visitEnd();

            return cw.toByteArray();
        }

        /*
         * Compile this expression. This method must append to the given code
         * writer the byte code that evaluates and pushes on the stack the value
View Full Code Here

        // loads the original class and adapts it
        ClassReader cr = new ClassReader("CommentAttribute");
        ClassWriter cw = new ClassWriter(0);
        ClassVisitor cv = new AddCommentClassAdapter(cw);
        cr.accept(cv, new Attribute[] { new CommentAttribute("") }, 0);
        byte[] b = cw.toByteArray();

        // stores the adapted class on disk
        FileOutputStream fos = new FileOutputStream("CommentAttribute.class.new");
        try {
            fos.write(b);
View Full Code Here

        mv.visitInsn(Opcodes.RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
        ((MethodNode) this.current).accept(cw);
        cw.visitEnd();
        byte[] b = cw.toByteArray();
        try {
            TestClassLoader loader = new TestClassLoader();
            Class<?> c = loader.defineClass("C", b);
            c.newInstance();
        } catch (Throwable t) {
View Full Code Here

        mv.visitInvokeDynamicInsn("bar", "()V", h, Type.getType("()V"), h);
        mv.visitInsn(RETURN);
        mv.visitEnd();

        cw.visitEnd();
        return cw.toByteArray();
    }
}
View Full Code Here

                                exceptions));
            }
        },
                new Attribute[] { new Comment(), new CodeComment() },
                ClassReader.EXPAND_FRAMES);
        cr = new ClassReader(cw.toByteArray());

        String nd = n + "Dump";
        if (n.indexOf('.') != -1) {
            nd = "asm." + nd;
        }
View Full Code Here

        handler.startDocument();
        cr.accept(new SAXClassAdapter(handler, false), 0);
        handler.endDocument();
       
        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(
View Full Code Here

                {
                    return null; // skip these attributes
                }
            } }, 0);

        assertEquals(new ClassReader(cw2.toByteArray()),
                new ClassReader(bos.toByteArray()));
    }
}
View Full Code Here

                                desc,
                                signature,
                                exceptions));
            }
        }, ClassReader.EXPAND_FRAMES);
        byte[] b = cw.toByteArray();
        try {
            LOADER.defineClass(n, b);
        } catch (ClassFormatError cfe) {
            fail(cfe.getMessage());
        } catch (Throwable ignored) {
View Full Code Here

                return null;
            }
        });
        ClassWriter cw = new ClassWriter(0);
        cn.accept(cw);
        assertEquals(cr, new ClassReader(cw.toByteArray()));
    }
}
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.