[Soot-list] getting jimple bodies from soot methods

Suhabe Bugrara sbugrara at MIT.EDU
Fri Jun 10 06:01:05 EDT 2005


Thanks for the reply. I tried calling the retrieveActiveBody method, but I
get the following NullPointerException. Apparently, the MethodSource
field of the SootMethod object is not set.

Suhabe

---------------------------------------------------------------------
Exception in thread "main" java.lang.NullPointerException
        at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:80)
        at soot.SootMethod.retrieveActiveBody(SootMethod.java:304)
        at SootTest.main(SootTest.java:20)




On Thu, 9 Jun 2005, Jennifer Lhotak wrote:

> Hi,
>
> You could use sm.retrieveActiveBody() which will create the body if
> necessary and will return the active body.
>
> Jennifer
>
> On Thu, 9 Jun 2005, Suhabe Bugrara wrote:
>
> > 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)
> >
> > _______________________________________________
> > 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