Package javassist.bytecode.analysis

Examples of javassist.bytecode.analysis.Analyzer.analyze()


        System.out.println("START: " + methodName);
        Analyzer analyzer = new Analyzer();

        long time = System.currentTimeMillis();
        try {
            analyzer.analyze(clazz, method.getMethodInfo2());
            System.out.println("SUCCESS: " + methodName + " - " + (System.currentTimeMillis() - time));
        } catch (Exception e) {
            System.out.println("FAIL: " + methodName + " - " + (e.getMessage() == null ? e.getClass().getName() : e.getMessage()));
        }
    }
View Full Code Here


        CtMethod method = ClassPool.getDefault().getMethod(
                getClass().getName() + "$Dummy", "reusedLocalMerge");

        MethodInfo info = method.getMethodInfo2();
        Analyzer analyzer = new Analyzer();
        Frame[] frames = analyzer.analyze(method.getDeclaringClass(), info);
        assertNotNull(frames);
        int pos = findOpcode(info, Opcode.RETURN);
        Frame frame = frames[pos];
        assertEquals("java.lang.Object", frame.getLocal(2).getCtClass().getName());
    }
View Full Code Here

            if (iter.byteAt(pos) == Opcode.ARETURN)
                break;
        }

        Analyzer analyzer = new Analyzer();
        Frame[] frames = analyzer.analyze(method.getDeclaringClass(), info);
        assertNotNull(frames);
        Frame frame = frames[pos];
        assertEquals(expected, frame.peek().getCtClass().getName());
    }
View Full Code Here

            if (iter.byteAt(pos) == Opcode.AALOAD)
                break;
        }

        Analyzer analyzer = new Analyzer();
        Frame[] frames = analyzer.analyze(clazz, info);
        assertNotNull(frames);
        Frame frame = frames[pos];
        assertNotNull(frame);

        Type type = frame.getStack(frame.getTopIndex() - 1);
View Full Code Here

    }

    public void testDeadCode() throws Exception {
        CtMethod method = generateDeadCode(ClassPool.getDefault());
        Analyzer analyzer = new Analyzer();
        Frame[] frames = analyzer.analyze(method.getDeclaringClass(), method.getMethodInfo2());
        assertNotNull(frames);
        assertNull(frames[4]);
        assertNotNull(frames[5]);
        verifyReturn(method, "java.lang.String");
    }
View Full Code Here

    public void testInvalidCode() throws Exception {
        CtMethod method = generateInvalidCode(ClassPool.getDefault());
        Analyzer analyzer = new Analyzer();
        try {
            analyzer.analyze(method.getDeclaringClass(), method.getMethodInfo2());
        } catch (BadBytecode e) {
            return;
        }

        fail("Invalid code should have triggered a BadBytecode exception");
View Full Code Here

    public void testCodeFalloff() throws Exception {
        CtMethod method = generateCodeFalloff(ClassPool.getDefault());
        Analyzer analyzer = new Analyzer();
        try {
            analyzer.analyze(method.getDeclaringClass(), method.getMethodInfo2());
        } catch (BadBytecode e) {
            return;
        }

        fail("Code falloff should have triggered a BadBytecode exception");
View Full Code Here

    }

    public void testJsrMerge() throws Exception {
        CtMethod method = generateJsrMerge(ClassPool.getDefault());
        Analyzer analyzer = new Analyzer();
        analyzer.analyze(method.getDeclaringClass(), method.getMethodInfo2());
        verifyReturn(method, "java.lang.String");
    }

    public void testJsrMerge2() throws Exception {
        CtMethod method = generateJsrMerge2(ClassPool.getDefault());
View Full Code Here

    }

    public void testJsrMerge2() throws Exception {
        CtMethod method = generateJsrMerge2(ClassPool.getDefault());
        Analyzer analyzer = new Analyzer();
        analyzer.analyze(method.getDeclaringClass(), method.getMethodInfo2());
        verifyReturn(method, "java.lang.String");
    }

    private CtMethod generateDeadCode(ClassPool pool) throws Exception {
        CtClass clazz = pool.makeClass(getClass().getName() + "$Generated0");
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.