Examples of ClassReader


Examples of org.ow2.asm.ClassReader

        mv.visitVarInsn(ISTORE, 30);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 31);
        mv.visitEnd();
        cw.visitEnd();
        ClassReader cr = new ClassReader(cw.toByteArray());
        CheckClassAdapter.verify(cr, true, new PrintWriter(System.err));
    }
View Full Code Here

Examples of org.ow2.asm.ClassReader

        } catch (Exception e) {
        }
    }
   
    public void testIllegalDebugLabelUse() throws IOException {
        ClassReader cr = new ClassReader("java.lang.Object");
        ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
        ClassVisitor cv = new ClassAdapter(cw) {
            @Override
            public MethodVisitor visitMethod(
                int access,
                String name,
                String desc,
                String signature,
                String[] exceptions)
            {
                final MethodVisitor next = cv.visitMethod(access,
                        name,
                        desc,
                        signature,
                        exceptions);
                if (next == null) {
                    return next;
                }
                return new MethodAdapter(new CheckMethodAdapter(next)) {
                    private Label entryLabel = null;

                    @Override
                    public void visitLabel(Label label) {
                        if (entryLabel == null) {
                            entryLabel = label;
                        }
                        mv.visitLabel(label);
                    }

                    @Override
                    public void visitMaxs(int maxStack, int maxLocals) {
                        Label unwindhandler = new Label();
                        mv.visitLabel(unwindhandler);
                        mv.visitInsn(Opcodes.ATHROW); // rethrow
                        mv.visitTryCatchBlock(entryLabel,
                                unwindhandler,
                                unwindhandler,
                                null);
                        mv.visitMaxs(maxStack, maxLocals);
                    }
                };
            }
        };
        try {
            cr.accept(cv, ClassReader.EXPAND_FRAMES);
            fail();
        } catch (Exception e) {
        }
    }
View Full Code Here

Examples of org.ow2.asm.ClassReader

            System.err.println("Prints the ASM code to generate the given class.");
            System.err.println("Usage: GASMifierClassVisitor [-debug] "
                    + "<fully qualified class name or class file name>");
            System.exit(-1);
        }
        ClassReader cr;
        if (args[i].endsWith(".class")) {
            cr = new ClassReader(new FileInputStream(args[i]));
        } else {
            cr = new ClassReader(args[i]);
        }
        cr.accept(new GASMifierClassVisitor(new PrintWriter(System.out)),
                getDefaultAttributes(),
                ClassReader.EXPAND_FRAMES | flags);
    }
View Full Code Here

Examples of org.ow2.asm.ClassReader

        return new AnalyzerAdapterTest().getSuite();
    }

    @Override
    public void test() throws Exception {
        ClassReader cr = new ClassReader(is);
        if (cr.readInt(4) != Opcodes.V1_6) {
            try {
                ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
                cr.accept(cw, 0);
                cr = new ClassReader(cw.toByteArray());
            } catch (Exception e) {
                skipTest();
                return;
            }
        }
        ClassWriter cw = new ClassWriter(0);
        ClassVisitor cv = new ClassAdapter(cw) {

            private String owner;

            @Override
            public void visit(
                final int version,
                final int access,
                final String name,
                final String signature,
                final String superName,
                final String[] interfaces)
            {
                owner = name;
                cv.visit(version,
                        access,
                        name,
                        signature,
                        superName,
                        interfaces);
            }

            @Override
            public MethodVisitor visitMethod(
                final int access,
                final String name,
                final String desc,
                final String signature,
                final String[] exceptions)
            {
                MethodVisitor mv = cv.visitMethod(access,
                        name,
                        desc,
                        signature,
                        exceptions);
                return new AnalyzerAdapter(owner, access, name, desc, mv);
            }
        };
        cr.accept(cv, ClassReader.EXPAND_FRAMES);
    }
View Full Code Here

Examples of org.ow2.asm.ClassReader

        return new JSRInlinerAdapterTest().getSuite();
    }

    @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

Examples of org.ow2.asm.ClassReader

        return new SimpleVerifierTest().getSuite();
    }

    @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());
            a.analyze(cn.name, method);
View Full Code Here

Examples of org.ow2.asm.ClassReader

        public Class<?> loadClass(final String name) throws ClassNotFoundException
        {
            if (name.startsWith(prefix)) {
                try {
                    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
                    ClassReader cr = new ClassReader(getClass().getResourceAsStream("/"
                            + name.replace('.', '/') + ".class"));
                    cr.accept(new AdviceClassAdapter(cw),
                            ClassReader.EXPAND_FRAMES);
                    byte[] bytecode = cw.toByteArray();
                    return super.defineClass(name, bytecode, 0, bytecode.length);
                } catch (IOException ex) {
                    throw new ClassNotFoundException("Load error: "
View Full Code Here

Examples of org.ow2.asm.ClassReader

        return new BasicVerifierTest().getSuite();
    }

    @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());
            a.analyze(cn.name, method);
View Full Code Here

Examples of org.ow2.asm.ClassReader

    }

    @Override
    public void test() throws Exception {
        ClassWriter cw = new ClassWriter(0);
        ClassReader cr = new ClassReader(is);
        Map<String, String> map = new HashMap<String, String>() {
            @Override
            public String get(Object key) {
                return "Foo";
            }
        };
        cr.accept(new RemappingClassAdapter(cw, new SimpleRemapper(map)), ClassReader.EXPAND_FRAMES);
    }
View Full Code Here

Examples of org.ow2.asm.ClassReader

    protected void assertMaxs(final int maxStack, final int maxLocals) {
        mv.visitMaxs(maxStack, maxLocals);
        mv.visitEnd();
        cw.visitEnd();
        byte[] b = cw.toByteArray();
        ClassReader cr = new ClassReader(b);
        cr.accept(new EmptyVisitor() {
            @Override
            public MethodVisitor visitMethod(
                final int access,
                final String name,
                final String desc,
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.