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

Pauline Anthonysamy anthonys at comp.lancs.ac.uk
Mon Sep 24 17:24:32 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120924/45c05fc3/attachment.html 


More information about the Soot-list mailing list