Package org.mvel2.asm.tree

Examples of org.mvel2.asm.tree.ClassNode


        map.put("Boo", "B1");
        map.put("Coo", "C1");
        map.put("Doo", "D1");
        Remapper remapper = new SimpleRemapper(map);
       
        ClassNode cn = new ClassNode();
        dump(new RemappingClassAdapter(cn, remapper));
       
        assertEquals("D1", cn.name);
        assertEquals("B1", cn.superName);
        assertEquals(Arrays.asList(new String[] {"I", "I", "C1", "J", "B1"}), cn.interfaces);
View Full Code Here


    }

    @Override
    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        ClassNode cn = new ClassNode();
        cr.accept(cn, 0);
        List<MethodNode> methods = cn.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = methods.get(i);
            Analyzer<?> a = new Analyzer<BasicValue>(new SimpleVerifier());
View Full Code Here

    }

    @Override
    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        ClassNode cn = new ClassNode();
        cr.accept(cn, 0);
        List<MethodNode> methods = cn.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = methods.get(i);
            Analyzer<?> a = new Analyzer<BasicValue>(new BasicVerifier());
View Full Code Here

    }

    @Override
    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        ClassNode cn = new ClassNode();
        cr.accept(cn, 0);
        List<MethodNode> methods = cn.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = methods.get(i);
            Analyzer<?> a = new Analyzer<SourceValue>(new SourceInterpreter());
View Full Code Here

*/
public class Analysis implements Opcodes {

    public static void main(final String[] args) throws Exception {
        ClassReader cr = new ClassReader("Analysis");
        ClassNode cn = new ClassNode();
        cr.accept(cn, ClassReader.SKIP_DEBUG);

        List<MethodNode> methods = cn.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = methods.get(i);
View Full Code Here

     * @param cv the {@link ClassVisitor} to which this visitor delegates calls.
     *        May be <tt>null</tt>.
     */
    public JasminifierClassAdapter(final PrintWriter pw, final ClassVisitor cv)
    {
        super(new ClassNode() {
            @Override
            public void visitEnd() {
                if (cv != null) {
                    accept(cv);
                }
View Full Code Here

        labelNames = new HashMap<Label, String>();
    }

    @Override
    public void visitEnd() {
        ClassNode cn = (ClassNode) cv;
        pw.print(".bytecode ");
        pw.print(cn.version & 0xFFFF);
        pw.print('.');
        pw.println(cn.version >>> 16);
        println(".source ", cn.sourceFile);
View Full Code Here

        final ClassReader cr,
        final ClassLoader loader,
        final boolean dump,
        final PrintWriter pw)
    {
        ClassNode cn = new ClassNode();
        cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

        Type syperType = cn.superName == null
                ? null
                : Type.getObjectType(cn.superName);
View Full Code Here

        });

        runTest("deserialize", "tree package", new RunTest() {
            @Override
            public void test(byte[] bytes, int[] errors) {
                new ClassReader(bytes).accept(new ClassNode(), 0);
            }
        });
       
        System.out.println();

        // deserialize and reserialize tests

        runTestAll("deserialize and reserialize", "", new RunTest() {
            @Override
            public void test(byte[] bytes, int[] errors) {
                ClassReader cr = new ClassReader(bytes);
                ClassWriter cw = new ClassWriter(0);
                cr.accept(cw, 0);
                cw.toByteArray();
            }
        });

        runTestAll("deserialize and reserialize",
                "copyPool",
                new RunTest() {
                    @Override
                    public void test(byte[] bytes, int[] errors) {
                        ClassReader cr = new ClassReader(bytes);
                        ClassWriter cw = new ClassWriter(cr, 0);
                        cr.accept(cw, 0);
                        cw.toByteArray();
                    }
                });

        runTest("deserialize and reserialize",
                "tree package",
                new RunTest() {
                    @Override
                    public void test(byte[] bytes, int[] errors) {
                        ClassWriter cw = new ClassWriter(0);
                        ClassNode cn = new ClassNode();
                        new ClassReader(bytes).accept(cn, 0);
                        cn.accept(cw);
                        cw.toByteArray();
                    }
                });

        compute = false;
        computeFrames = false;
       
        runTest("deserialize and reserialize", "BCEL", nullBCELAdapt);

        runTest("deserialize and reserialize",
                "Aspectj BCEL",
                nullAspectjBCELAdapt);
       
        runTest("deserialize and reserialize",
                "Javassist",
                nullJavassistAdapt);

        runTest("deserialize and reserialize",
                "SERP",
                nullSERPAdapt);

        System.out.println();

        // deserialize and reserialize tests with computeMaxs

        runTest("deserialize and reserialize",
                "computeMaxs",
                new RunTest() {
                    @Override
                    public void test(byte[] bytes, int[] errors) {
                        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
                        new ClassReader(bytes).accept(cw, 0);
                        cw.toByteArray();
                    }
                });

        compute = true;
        computeFrames = false;

        runTest("deserialize and reserialize",
                "BCEL and computeMaxs",
                nullBCELAdapt);

        runTest("deserialize and reserialize",
                "Aspectj BCEL and computeMaxs",
                nullAspectjBCELAdapt);
       
        // misc. tests

        runTest("deserialize and reserialize",
                "LocalVariablesSorter",
                new RunTest() {
                    @Override
                    public void test(byte[] bytes, int[] errors) {
                        ClassWriter cw = new ClassWriter(0);
                        new ClassReader(bytes).accept(new ClassAdapter(cw) {

                            @Override
                            public MethodVisitor visitMethod(
                                final int access,
                                final String name,
                                final String desc,
                                final String signature,
                                final String[] exceptions)
                            {
                                return new LocalVariablesSorter(access,
                                        desc,
                                        cv.visitMethod(access,
                                                name,
                                                desc,
                                                signature,
                                                exceptions));
                            }
                        }, ClassReader.EXPAND_FRAMES);
                        cw.toByteArray();
                    }
                });

        // This test repeatedly tests the same classes as SimpleVerifier
        // actually calls Class.forName() on the class which fills the PermGen
        runTestSome("analyze", "SimpleVerifier", new RunTest() {
            @Override
            public void test(byte[] bytes, int[] errors) {
                ClassReader cr = new ClassReader(bytes);
                ClassNode cn = new ClassNode();
                cr.accept(cn, ClassReader.SKIP_DEBUG);
                 List<MethodNode> methods = cn.methods;
                for (int k = 0; k < methods.size(); ++k) {
                    MethodNode method = methods.get(k);
                    Analyzer<?> a = new Analyzer<BasicValue>(new SimpleVerifier());
View Full Code Here

            long time = -System.currentTimeMillis();
            while (files.hasNext()) {
                byte data[] = files.next();
                ClassReader reader = new ClassReader(data);
                ClassNode clazz = new ClassNode();
                reader.accept(clazz, 0);
                result.add(clazz);
            }
            time += System.currentTimeMillis();

            memDown(runtime);
            System.out.println("Time: ".concat(timeFormat(time)));
            System.out.println("Final memory load: ".concat(memFormat(getUsedMem(runtime))));
            System.out.println("ASM memory load: ".concat(memFormat(getUsedMem(runtime)
                    - startmem)));
            for (int j = 0; j < limit; j++) {
                ClassNode clazz = result.get(j);
                 List<MethodNode> l = clazz.methods;
                for (int k = 0, lim = l.size(); k < lim; k++) {
                    MethodNode m = l.get(k);
                    InsnList insn = m.instructions;
                    if (insn != null) {
View Full Code Here

TOP

Related Classes of org.mvel2.asm.tree.ClassNode

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.