prevent infinite recursion for cycle of callers
authorjjenista <jjenista>
Mon, 1 Sep 2008 21:11:43 +0000 (21:11 +0000)
committerjjenista <jjenista>
Mon, 1 Sep 2008 21:11:43 +0000 (21:11 +0000)
Robust/src/Analysis/CallGraph/CallGraph.java

index 1c24b244d966a2d78796aa766449bb1839ef9327..6039499347773c36aaa32feca72c5f5ce7823489 100644 (file)
@@ -114,15 +114,26 @@ public class CallGraph {
 
     HashSet ns=new HashSet();
     ns.add(d);
+    return getMoreMethodCalls( ns, d );
+  }
+
+  private Set getMoreMethodCalls( HashSet found, Descriptor d ) {
+    HashSet ns=new HashSet();
+    ns.add(d);
+    found.add(d);
     Set s=(Set)mapCaller2CalleeSet.get(d);
     if (s!=null)
       for(Iterator it=s.iterator(); it.hasNext();) {
        MethodDescriptor md=(MethodDescriptor)it.next();
-       ns.addAll(getMethodCalls(md));
+       if( !found.contains(md) ) {
+         found.contains(md);
+         ns.addAll(getMoreMethodCalls(found, md));
+       }
       }
-    return ns;
+    return ns;    
   }
 
+
   private void buildGraph() {
     Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
     while(it.hasNext()) {