[Soot-list] try catch in methods issue

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Mon Mar 29 05:22:23 EDT 2010


Hi Dinesh.

Using loadClassAndSupport is not recommended. Could you try not using
loadClassAndSupport but instead using a transformer instead?

public static void main(String[] args) {
  PackManager.v().getPack("jtp").add(
    new Transform("jtp.myTransform", new BodyTransformer() {
      protected void internalTransform(Body body, String phase, Map options) {
        //do something with body here
      }
    }));
  soot.Main.main(args);
}

This should avoid any such problems.
See also here: http://www.bodden.de/2008/09/22/soot-intra/

Eric

--
Dr. Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt



On 29 March 2010 10:56, dinesh chhatani <dinustudy at gmail.com> wrote:
> thanks for answering Eric,
>
> See this is the part of code,
>
>
> SootClass sClass = Scene.v().loadClassAndSupport(args[0]);
>
> sClass.setApplicationClass();
>
> Iterator methodIt = sClass.getMethods().iterator();
>
> while (methodIt.hasNext()) {
>
> SootMethod m = (SootMethod)methodIt.next();
>
> Body b = m.retrieveActiveBody();............this line throws Null pointer
> exception for the  method of given class in arg[] (if that contains
> try/catch block)
>
> On Mon, Mar 29, 2010 at 1:41 PM, Eric Bodden
> <bodden at st.informatik.tu-darmstadt.de> wrote:
>>
>> Hi Dinesh.
>>
>> > I want to create UnitGraphs for all my methods in the class
>> > Now if my method is having try/catch block then when the body of that
>> > method
>> > is retrieved by m.retrieveactivebody at this point it throws null
>> > pointer
>> > exception.
>>
>> Normally whether or not a method has a try-catch block should have no
>> impact on whether you can retrieve a body or not. I suspect that you
>> are using Soot incorrectly but that is hard to say without seeing your
>> code.
>>
>> > also what are limitations of soot as far as version is control(Is it
>> > working
>> > for all jdk's) and upcoming versions in future
>>
>> This really depends what you want to use Soot for. Most functionality
>> should work fine with any JDK.
>>
>> Eric
>
>
>
> --
> Regards,
> Dinesh Chhatani
>


More information about the Soot-list mailing list