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

Cheng Zhang cheng.zhang.stap at gmail.com
Sat Mar 10 21:36:10 EST 2012


Hi,

Sorry, I am not quite clear what your problem is.
But if it is how to get the SootClass instances for the inner classes,
I would suggest trying the method: Scene.v().getSootClass(<class name>)

Hope this helps,
Cheng

On Sun, Mar 11, 2012 at 5:17 AM, hxj <hxj163 at gmail.com> 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
>
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120311/a0aa2d94/attachment.html 


More information about the Soot-list mailing list