[Soot-list] NullPointerException when call retrieveActiveBody()

tina heyetina at 163.com
Tue Jun 19 05:10:20 EDT 2012


Hi,

  I wrote a demo to do control flow analysis according to survivor's guide(
5.7 control flow graphs) .

  

 The code is:


 SootClass c=Scene.v().loadClassAndSupport("Try");//Try is the target class
name 

  Scene.v().loadNecessaryClasses();

  c.setApplicationClass();

SootMethod src=a.getMethodByName("main");//main is the target method

  Body body=src. retrieveActiveBody();

  UnitGraph g=new BriefUnitGraph(body);

  Iterator it=g.iterator();

while(it.hasNext()) 

{

     Unit u=(Unit)it.next();

 }

This code is written in main method in main.class of Soot source code.

 

When run the code, it will throw NullpointerException:


Exception in thread "main" java.lang.NullPointerException

    at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:89)

    at soot.SootMethod.retrieveActiveBody(SootMethod.java:322)

    at soot.Main.main(Main.java:166)

 

Through debugging, I found SootMethod.ms is null, but I don't know how to
set MethodSource, and how to fix this problem, could you help me?

 

regards

 

Tina

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120619/82aaa59c/attachment-0001.html 


More information about the Soot-list mailing list