[Soot-list] Main entry points

Eric Bodden eric.bodden at mail.mcgill.ca
Wed Apr 25 00:09:33 EDT 2007


Hi.

getMainClass() returns *the* unique main-class for your application.
This class is either stated explicitly on the command line
(-main-class YourMainClass) or it is inferred. In the latter case,
Soot just takes the first application class with a main method it can
find.

I think in your case this method will help:

soot.EntryPoints.mainsOfApplicationClasses()

(call "EntryPoints.v().mainsOfApplicationClasses()")

This returns a list of SootMethod's (all main-methods). For each
method you can then retrieve the declaring class using
m.getDeclaringClass().

Eric

On 24/04/07, Mario Mendez <mario at cs.unm.edu> wrote:
> Thank you again for the quick responses to previous emails. The
> Hierarchy class has saved quite a lot of time of my life!
>
> Another question: is there any method to retrieve all the application
> classes that contain a 'main' method? I mean, my analysis will have 2
> modes: 'library', in which all public methods can be considered as entry
> points, and 'main', in which only the mains of the application classes
> can be considered as entry points.
>
> I found Scene.getMainClass, but it returns a SootClass (instead of a
> List) and since there is no Javadoc about it, it's not clear to me which
> criteria does the method use to choose that main class. For example, if
> we run
>
> soot -f n -output-dir ./ilciao_lib/ -app examples.Qsort
> jolden.voronoi.Voronoi
>
> , then the main class returned by Scene.getMainClass is examples.Qsort
>
> If we invert the order of the parameters
>
> soot -f n -output-dir ./ilciao_lib/ -app jolden.voronoi.Voronoi
> examples.Qsort
>
> , then the main class returned by Scene.getMainClass is
> jolden.voronoi.Voronoi
>
> Is there an API method to get both classes (AND ANY OTHER APPLICATION
> CLASS CONTAINING A MAIN) or should I just iterate over the public
> methods looking for those whose definition match with the one of main?
>
>
> Thanks!
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>


-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


More information about the Soot-list mailing list