Search in sources :

Example 1 with MethodSource

use of soot.MethodSource in project soot by Sable.

the class DexMethod method createMethodSource.

protected MethodSource createMethodSource(final Method method) {
    return new MethodSource() {

        @Override
        public Body getBody(SootMethod m, String phaseName) {
            Body b = Jimple.v().newBody(m);
            try {
                // add the body of this code item
                DexBody dexBody = new DexBody(dexFile, method, declaringClass.getType());
                dexBody.jimplify(b, m);
            } catch (InvalidDalvikBytecodeException e) {
                String msg = "Warning: Invalid bytecode in method " + m + ": " + e;
                logger.debug("" + msg);
                Util.emptyBody(b);
                Util.addExceptionAfterUnit(b, "java.lang.RuntimeException", b.getUnits().getLast(), "Soot has detected that this method contains invalid Dalvik bytecode which would have throw an exception at runtime. [" + msg + "]");
                TypeAssigner.v().transform(b);
            }
            m.setActiveBody(b);
            return m.getActiveBody();
        }
    };
}
Also used : MethodSource(soot.MethodSource) SootMethod(soot.SootMethod) Body(soot.Body)

Aggregations

Body (soot.Body)1 MethodSource (soot.MethodSource)1 SootMethod (soot.SootMethod)1