use of soot.SootClass in project soot by Sable.
the class SootASMClassWriterTest method testGetCommonSuperClassTransitive.
@Test
public void testGetCommonSuperClassTransitive() {
SootClass sc11 = mockClass("AA");
SootClass sc21 = mockClass("BB");
when(sc11.getSuperclass()).thenReturn(commonSuperClass);
when(sc21.getSuperclass()).thenReturn(commonSuperClass);
when(sc11.getSuperclassUnsafe()).thenReturn(commonSuperClass);
when(sc21.getSuperclassUnsafe()).thenReturn(commonSuperClass);
when(sc1.getSuperclass()).thenReturn(sc11);
when(sc2.getSuperclass()).thenReturn(sc21);
when(sc1.getSuperclassUnsafe()).thenReturn(sc11);
when(sc2.getSuperclassUnsafe()).thenReturn(sc21);
assertEquals("C", cw.getCommonSuperClass("A", "B"));
}
use of soot.SootClass in project soot by Sable.
the class SootASMClassWriterTest method testGetCommonSuperClassPhantomClass.
@Test
public void testGetCommonSuperClassPhantomClass() {
SootClass sc11 = mockClass("AA");
when(sc11.isPhantomClass()).thenReturn(true);
when(sc11.hasSuperclass()).thenReturn(false);
when(sc11.getSuperclass()).thenReturn(null);
when(sc11.getSuperclassUnsafe()).thenReturn(null);
when(sc1.getSuperclass()).thenReturn(sc11);
when(sc2.getSuperclass()).thenReturn(commonSuperClass);
when(sc1.getSuperclassUnsafe()).thenReturn(sc11);
when(sc2.getSuperclassUnsafe()).thenReturn(commonSuperClass);
assertEquals("java/lang/Object", cw.getCommonSuperClass("A", "B"));
}
use of soot.SootClass in project soot by Sable.
the class CallGraphExample method main.
public static void main(String[] args) {
List<String> argsList = new ArrayList<String>(Arrays.asList(args));
argsList.addAll(Arrays.asList(new String[] { "-w", "-main-class", // main-class
"testers.CallGraphs", // argument classes
"testers.CallGraphs", //
"testers.A" }));
PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new SceneTransformer() {
@Override
protected void internalTransform(String phaseName, Map options) {
CHATransformer.v().transform();
SootClass a = Scene.v().getSootClass("testers.A");
SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");
CallGraph cg = Scene.v().getCallGraph();
Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(src));
while (targets.hasNext()) {
SootMethod tgt = (SootMethod) targets.next();
System.out.println(src + " may call " + tgt);
}
}
}));
args = argsList.toArray(new String[0]);
soot.Main.main(args);
}
use of soot.SootClass in project soot by Sable.
the class Foonalasys method loadClass.
/**
* Loads the named class into the Soot scene,
* marks it as an application class, and generates bodies
* for all of its concrete methods.
* @param name the fully qualified name of the class to be loaded.
*/
public static void loadClass(String name) {
SootClass c = Scene.v().loadClassAndSupport(name);
c.setApplicationClass();
Iterator mi = c.getMethods().iterator();
while (mi.hasNext()) {
SootMethod sm = (SootMethod) mi.next();
if (sm.isConcrete()) {
sm.retrieveActiveBody();
}
}
}
use of soot.SootClass in project soot by Sable.
the class DexMethod method getThrownExceptions.
protected List<SootClass> getThrownExceptions(final Method method) {
// the following snippet retrieves all exceptions that this method
// throws by analyzing its annotations
List<SootClass> thrownExceptions = new ArrayList<SootClass>();
for (Annotation a : method.getAnnotations()) {
Type atype = DexType.toSoot(a.getType());
String atypes = atype.toString();
if (!(atypes.equals("dalvik.annotation.Throws")))
continue;
for (AnnotationElement ae : a.getElements()) {
EncodedValue ev = ae.getValue();
if (ev instanceof ArrayEncodedValue) {
for (EncodedValue evSub : ((ArrayEncodedValue) ev).getValue()) {
if (evSub instanceof TypeEncodedValue) {
TypeEncodedValue valueType = (TypeEncodedValue) evSub;
String exceptionName = valueType.getValue();
String dottedName = Util.dottedClassName(exceptionName);
thrownExceptions.add(SootResolver.v().makeClassRef(dottedName));
}
}
}
}
}
return thrownExceptions;
}
Aggregations