Package javassist.bytecode.analysis

Examples of javassist.bytecode.analysis.Analyzer


        return frames[pos - offset]; // Adjust pos
    }

    private void initFrames(CtClass clazz, MethodInfo minfo) throws BadBytecode {
        if (frames == null) {
            frames = ((new Analyzer())).analyze(clazz, minfo);
            offset = 0; // start tracking changes
        }
    }
View Full Code Here


        return frames[pos - offset]; // Adjust pos
    }

    private void initFrames(CtClass clazz, MethodInfo minfo) throws BadBytecode {
        if (frames == null) {
            frames = ((new Analyzer())).analyze(clazz, minfo);
            offset = 0; // start tracking changes
        }
    }
View Full Code Here

        return frames[pos - offset]; // Adjust pos
    }

    private void initFrames(CtClass clazz, MethodInfo minfo) throws BadBytecode {
        if (frames == null) {
            frames = ((new Analyzer())).analyze(clazz, minfo);
            offset = 0; // start tracking changes
        }
    }
View Full Code Here

    }

    private static void analyzeMethod(CtClass clazz, CtMethod method) {
        String methodName = clazz.getName() + "." + method.getName() + method.getSignature();
        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

/*  99 */     return this.frames[(pos - this.offset)];
/*     */   }
/*     */
/*     */   private void initFrames(CtClass clazz, MethodInfo minfo) throws BadBytecode {
/* 103 */     if (this.frames == null) {
/* 104 */       this.frames = new Analyzer().analyze(clazz, minfo);
/* 105 */       this.offset = 0;
/*     */     }
/*     */   }
View Full Code Here

    public  void testReusedLocalMerge() throws Exception {
        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

            pos = iter.next();
            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

            pos = iter.next();
            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

        code.addIndex(pos - current);
    }

    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

        verifyReturn(method, "java.lang.String");
    }

    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

TOP

Related Classes of javassist.bytecode.analysis.Analyzer

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.