[Soot-list] getting jimple bodies from soot methods

Suhabe Bugrara sbugrara at MIT.EDU
Thu Jun 9 21:54:11 EDT 2005


Hi,

I'm trying to access the JimpleBody of a SootMethod in the code snippet
below, but I get the following runtime exception when I call
"getActiveBody" on the SootMethod object. I can't figure out what else I
need to do to get JimpleBody's set in the SootMethods.

Suhabe

---------------------------------------------------------------------
public static void main (String[] args) {

 soot.Main.main(new String[] {
                		"HelloWorld",
                		"-cp",
				"c:\\layers\\src;c:\\java\\jdk1.5.0_03\\jre\\lib\\rt.jar",
                		"-f", "jimple",
 });


 SootClass sc = Scene.v().getSootClass("HelloWorld");
 SootMethod sm = sc.getMethodByName("say");

 //RuntimeException thrown at the following line
 JimpleBody b = (JimpleBody) sm.getActiveBody();
}

----------------------------------------------------------------------
Exception in thread "main" java.lang.RuntimeException: no active body
present for method <HelloWorld: void say()>
        at soot.SootMethod.getActiveBody(SootMethod.java:279)
        at SootTest.main(SootTest.java:21)



More information about the Soot-list mailing list