[Soot-list] Creating call graph for classes without main method throws "Exception in thread "main" java.lang.RuntimeException: There is no main class set!"

Saswat Anand saswat78 at gmail.com
Mon Sep 24 18:09:47 EDT 2012


I think that the "main class" is a class that has a main method (i.e.,
with signature void main(String[]). The test.CallGraphs does not have
a main method.

Save your hair :)

Saswat

On Mon, Sep 24, 2012 at 2:24 PM, Pauline Anthonysamy
<anthonys at comp.lancs.ac.uk> wrote:
> Hello Everyone,
>
> I am pulling my hair out - trying to figure out why am I getting this
> exception ("Exception in thread "main" java.lang.RuntimeException: There is
> no main class set!") even when I have set the main class to be
> "test.CallGraphs".
> I am using eclipse (not sure if this matters, probably not). My build path
> has sootclasses.jar,  jce.jar and jre system library.
>
> I have searched through the mail archives but no luck :-/
> Can someone please have a look at my code below and advise if I am making a
> mistake any where??
>
>
> package test;
>
> public class CallGraphExample {
> public static void main(String[] args) {
> // create a list from args
> List<String> argsList = new ArrayList<String>(Arrays.asList(args));
> // add on the following arguments
> argsList.addAll(Arrays.asList(new String[]{"-w", "test.CallGraphs"}));
> // 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) {
> CHATransformer.v().transform();
> SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");
> ArrayList<SootMethod> entryPoints = new ArrayList<SootMethod>();
> entryPoints.add(src);
> Scene.v().setEntryPoints(entryPoints);
> 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);
> }
> }
>
>
> package test;
>
> public class CallGraphs {
> public static void doStuff() {
> StringBuilder b = new StringBuilder("Blah");
> b.append(" Blah");
> new A().foo();
> }
>
> }
>
> package test;
>
> public class A {
> public void foo() {
> bar();
> }
> public void bar() {
> }
>
> }
>
>
> Any pointers will be highly appreciated!!
>
> Many Thanks,
> -Pauline
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>


More information about the Soot-list mailing list