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

hxj hxj163 at gmail.com
Sun Mar 11 06:48:39 EDT 2012


Hi,

Thanks for your reply. Yes, that is my problem. But I want to analyze 
the class C which is inside the CallGraphsTest.  I tried to use 
Scene.v().getSootClass("C") and 
Scene.v().getSootClass("tester.CallGraphsTest.C"). But they did not work.

Then I found maybe Hierarchy is useful. So I added in my code:

SootClass sClass = Scene.v().getSootClass("testers.CallGraphsTest");
List<SootClass> abc = 
Scene.v().getActiveHierarchy().getSubclassesOf(sClass);
System.out.println(abc.toString());

But I found the list is empty. Now I have no idea.

So could you tell me what is the problem of my code?

Best regards,
Eve

On 11/03/2012 02:36, Cheng Zhang wrote:
> 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 
> <mailto: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   //inner class
>             {
>                 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 <mailto: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/f5224af5/attachment-0001.html 


More information about the Soot-list mailing list