Fwd: [Soot-list] Newbie question: Getting a handle on Jimple via Java
Eric Bodden
eric.bodden at mail.mcgill.ca
Thu Feb 21 09:49:38 EST 2008
Ah, I see. Yes you can do something like this:
public class MyMain {
public static void main(String[] args) {
PackManager.v().getPack("wjtp").add(
new Transform("wjtp.myTransform",new SceneTransformer(){
protected void internalTransform(String arg1,
Map arg2) {
G.v().out.println(Scene.v().getSootClass("foo.TestClass"));
}
});
soot.Main.main(args);
}
}
This first hooks a SceneTransformer into the "whole Jimple
transformation pack" (wjtp) of Soot, see page 100 here:
http://www.sable.mcgill.ca/soot/tutorial/pldi03/tutorial.pdf
Within the transformer you then have access to all the classes
directly from the Scene. Their methods contain Jimple bodies.
Eric
On 21/02/2008, Willem Bester <wbester at cs.sun.ac.za> wrote:
> Hi Eric,
>
> Thanks for the reply. Unfortunately, this is not what I have in mind. I
> don't intend to use Soot as a stand-alone tool. I need to get a handle on
> the Jimple representation from within a Java program. So, is there some way
> I can call Soot (from a Java program) and have it return a reference to the
> Jimple representation of a .class file?
>
> Thanks again.
>
> Willem
>
> On Thu, Feb 21, 2008 at 4:27 PM, Eric Bodden <eric.bodden at mail.mcgill.ca>
> wrote:
> > Hi, Willem.
> >
> > you mean you just want to produce .jimple files from .class files?
> > That's super easy!
> >
> > Just do something like this:
> >
> > java -cp sootclasses.jar soot.Main -f J MyClass
> >
> > This will read MyClass.class from the current directory and produce
> > MyClass.jimple in the directory "sootOutput". All the command line
> > options are documented here:
> >
> > http://www.sable.mcgill.ca/soot/tutorial/usage/index.html
> >
> > Eric
> >
>
> --
> Willem Bester
> Stellenbosch, South Africa
--
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
More information about the Soot-list
mailing list