[Soot-list] Soot-list Digest, Vol 89, Issue 23
Pauline Anthonysamy
anthonys at comp.lancs.ac.uk
Tue Sep 25 09:51:28 EDT 2012
Many thanks to Cheng and Quentin!!
I bypassed the exception. My mistake was passing the class name within
Options.v().parse().
Below is a working example for future noobs!
public class CallGraphExample {
public static void main(String[] args) {
// PackManager manages the packs containing the various phases
and their options
PackManager.v().getPack("wjtp")
.add(new Transform("wjtp.myTransform", new SceneTransformer() {
@Override
protected void internalTransform(String phaseName, Map
options) {
System.out.println("\n\n -----> 5 \n\n");
CHATransformer.v().transform();
SootMethod src =
Scene.v().getMainClass().getMethodByName("doStuff");
System.out.println("\n\n -----> 6 \n\n");
CallGraph cg = Scene.v().getCallGraph();
System.out.println("\n\n -----> 7 \n\n");
Iterator<MethodOrMethodContext> targets = new
Targets(cg.edgesOutOf(src));
while (targets.hasNext()) {
System.out.println("\n\n -----> 8 \n\n");
SootMethod tgt = (SootMethod)targets.next();
System.out.println("\n\n -----> 9 \n\n");
System.out.println(src + " may call " + tgt);
}
}
}));
System.out.println("\n\n -----> 1 \n\n");
Options.v().parse(new String[] {"-w"});
SootClass a = Scene.v().forceResolve("test.CallGraphs",
SootClass.BODIES);
a.setApplicationClass();
Scene.v().loadNecessaryClasses();
SootMethod m = a.getMethodByName("doStuff");
System.out.println("\n\n -----> 2 \n\n");
ArrayList<SootMethod> entryPoints = new ArrayList<SootMethod>();
entryPoints.add(m);
System.out.println("\n\n -----> 3 \n\n");
System.out.println("STUFF: " + entryPoints.get(0));
Scene.v().setEntryPoints(entryPoints);
System.out.println("\n\n -----> 4 \n\n");
PackManager.v().runPacks(); //soot.Main.main(args);
}
}
On 25/09/12 12:31, soot-list-request at sable.mcgill.ca wrote:
> Send Soot-list mailing list submissions to
> soot-list at sable.mcgill.ca
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> or, via email, send a message with subject or body 'help' to
> soot-list-request at sable.mcgill.ca
>
> You can reach the person managing the list at
> soot-list-owner at sable.mcgill.ca
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Soot-list digest..."
>
>
> Today's Topics:
>
> 1. Re: Exception in thread "main" java.lang.RuntimeException:
> There is no main class set! (Quentin Sabah)
> 2. Re: Exception in thread "main" java.lang.RuntimeException:,
> There is no main class set! (Pauline Anthonysamy)
> 3. Re: Exception in thread "main" java.lang.RuntimeException:,
> There is no main class set! (Cheng Zhang)
> 4. Re: Exception in thread "main" java.lang.RuntimeException:
> There is no main class set! (Marc-Andr? Laverdi?re-Papineau)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 25 Sep 2012 11:00:32 +0200
> From: Quentin Sabah <quentin.sabah at inria.fr>
> Subject: Re: [Soot-list] Exception in thread "main"
> java.lang.RuntimeException: There is no main class set!
> To: soot-list at sable.mcgill.ca
> Message-ID: <506172B0.3020108 at inria.fr>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> To be more specific, soot will look for the main class / entry-point
> *before* running your scene transformer. So it is too late to set the
> scene entry-point during the transformation, as in your code.
>
More information about the Soot-list
mailing list