[Soot-list] Help!!How to get into the inner class and analysis it

hxj hxj163 at gmail.com
Sat Mar 10 16:28:46 EST 2012


Besides, I tried to use entryPoints to analyse a class without main 
method using eclipse. I searched one approach in soot-list: 
http://www.sable.mcgill.ca/pipermail/soot-list/2011-July/003807.html
which suggests us to use

/Scene.v().forceResolve("testers.CallGraph", SootClass.SIGNATURE);/

before accessing the sootclass. I did the same thing then I got the 
exception: The method forceResolve(String, int) is undefined for the 
type Scene. Then I found the Scene.java in eclipse-plugins does not 
contain this method forceResolve().

I am not sure whether it is a bug of soot-eclipse-plugin. So I hope you 
could give some more advices about how to using the entryPoints in Eclipse.

Best regards,
Xujing


On 10/03/2012 21:17, hxj wrote:
> Hi Developers:
>
> I have a file CallGraphsTest.java and I want to analyse the method 
> a(); so I created CallGraphEx.java to analyse the CallGraphsTest.java:
>
> public class CallGraphsTest
> {
>
>     public static void main(String[] args){
>         new CallGraphsTest().a();
>     }
>
>     public void a(){
>
>         final C cc = new C();
>
>         class  D extends C{
>         @Override
>               public void foo(){
>
>             }
>             public void ta(){cc.bar();}
>
>         }
>
>         C b  =new D();
>         doStuff(b);
>     }
>
>     public static void doStuff(C a) {
>
>     }
>
>     class C
>     {
>         public void foo() {
>             bar();
>         }
>
>         public void bar() {
>         }
>     }
>
>
>
>
> public class CallGraphEx
> {
>     public static void main(String[] args) {
>        List<String> argsList = new 
> ArrayList<String>(Arrays.asList(args));
>        argsList.addAll(Arrays.asList(new String[]{
>                "-w",
>                "-main-class",
>                "testers.CallGraphsTest",//main-class
>                "testers.CallGraphsTest",//argument classes
>        }));
>
>        PackManager.v().getPack("wjtp").add(new 
> Transform("wjtp.myTrans", new SceneTransformer() {
>
>         @Override
>         protected void internalTransform(String phaseName, Map options) {
>                CHATransformer.v().transform();
>
>                    SootMethod scr = 
> Scene.v().getMainClass().getMethodByName("a");
>
>                    CallGraph cg = Scene.v().getCallGraph();
>
>                    Iterator<MethodOrMethodContext> targets = new 
> Targets(cg.edgesOutOf(scr));
>                    while (targets.hasNext()) {
>                        SootMethod tgt = (SootMethod)targets.next();
>                        System.out.println(scr+ " may call " + tgt);
>                    }
>        }}));
>
>            args = argsList.toArray(new String[0]);
>            soot.Main.main(args);
>     }
> }
>
>
> After running this CallGraphEx.java, I got the following results:
>
> <testers.CallGraphsTest: void a()> may call <java.lang.Object: void 
> <clinit>()>
> <testers.CallGraphsTest: void a()> may call 
> <testers.CallGraphsTest$1D: void 
> <init>(testers.CallGraphsTest,testers.CallGraphsTest$C)>
> <testers.CallGraphsTest: void a()> may call <testers.CallGraphsTest$C: 
> void <init>(testers.CallGraphsTest)>
> <testers.CallGraphsTest: void a()> may call <java.lang.Object: void 
> <clinit>()>
> <testers.CallGraphsTest: void a()> may call <java.lang.Object: void 
> <clinit>()>
> <testers.CallGraphsTest: void a()> may call <testers.CallGraphsTest: 
> void doStuff(testers.CallGraphsTest$C)>
>
>
> So we can find that in order to analyse a(),  we still need to analyse 
> the inner class C and another inner class D inside the method a().
> My problem is: how could we get the inner class C and D (not just get 
> their names) so that we could analyse these inner classes using 
> intraprocedural or interprocedural analysis?
>
> Thanks very much!
> Best regards,
> Eve
>
>
>
>

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


More information about the Soot-list mailing list