add ssjava debug option to have interim results if we want and small changes
authoryeom <yeom>
Wed, 29 Jun 2011 18:11:45 +0000 (18:11 +0000)
committeryeom <yeom>
Wed, 29 Jun 2011 18:11:45 +0000 (18:11 +0000)
Robust/src/Analysis/SSJava/FlowDownCheck.java
Robust/src/Analysis/SSJava/MethodAnnotationCheck.java
Robust/src/Analysis/SSJava/SSJavaAnalysis.java
Robust/src/Analysis/SSJava/SingleReferenceCheck.java
Robust/src/IR/State.java
Robust/src/Main/Main.java

index db16bef941f85e9ca0f32d79638951516fbbff5f..71537e2a7d830f605ba9b215f473eccf6f5946d0 100644 (file)
@@ -114,7 +114,7 @@ public class FlowDownCheck {
         checkDeclarationInClass(cd);
         for (Iterator method_it = cd.getMethods(); method_it.hasNext();) {
           MethodDescriptor md = (MethodDescriptor) method_it.next();
-          if (ssjava.needAnnotation(md)) {
+          if (ssjava.needTobeAnnotated(md)) {
             checkDeclarationInMethodBody(cd, md);
           }
         }
@@ -133,7 +133,7 @@ public class FlowDownCheck {
       checkClass(cd);
       for (Iterator method_it = cd.getMethods(); method_it.hasNext();) {
         MethodDescriptor md = (MethodDescriptor) method_it.next();
-        if (ssjava.needAnnotation(md)) {
+        if (ssjava.needTobeAnnotated(md)) {
           checkMethodBody(cd, md);
         }
       }
@@ -176,7 +176,7 @@ public class FlowDownCheck {
     BlockNode bn = state.getMethodBody(md);
 
     // parsing returnloc annotation
-    if (ssjava.needAnnotation(md)) {
+    if (ssjava.needTobeAnnotated(md)) {
 
       Vector<AnnotationDescriptor> methodAnnotations = md.getModifiers().getAnnotations();
       if (methodAnnotations != null) {
index fa62806273c6224ec5e22dffe8ab297df25a8219..587bc28dd1a22d8ab16bee235ef3579b0fc1a1b5 100644 (file)
@@ -71,7 +71,7 @@ public class MethodAnnotationCheck {
 
     for (Iterator iterator = annotatedMDSet.iterator(); iterator.hasNext();) {
       MethodDescriptor md = (MethodDescriptor) iterator.next();
-      ssjava.putNeedAnnotation(md);
+      ssjava.addAnnotationRequire(md);
     }
 
     Set<Pair> visited = new HashSet<Pair>();
@@ -89,7 +89,7 @@ public class MethodAnnotationCheck {
           if (!visited.contains(p)) {
             visited.add(p);
             tovisit.add(calleeMD);
-            ssjava.putNeedAnnotation(calleeMD);
+            ssjava.addAnnotationRequire(calleeMD);
           }
         }
       }
@@ -102,7 +102,7 @@ public class MethodAnnotationCheck {
     // be annotated.
 
     Set<MethodDescriptor> tovisit = new HashSet<MethodDescriptor>();
-    tovisit.addAll(ssjava.getMd2hasAnnotation().keySet());
+    tovisit.addAll(ssjava.getAnnotationRequireSet());
 
     while (!tovisit.isEmpty()) {
       MethodDescriptor md = tovisit.iterator().next();
@@ -119,7 +119,7 @@ public class MethodAnnotationCheck {
             MethodDescriptor matchmd = (MethodDescriptor) methodit.next();
             if (md.matches(matchmd)) {
               if (matchmd.getClassDesc().equals(subCD)) {
-                ssjava.putNeedAnnotation(matchmd);
+                ssjava.addAnnotationRequire(matchmd);
               }
             }
           }
index ca98c6bed48b363b9451f96800498d8bbb479abe..c9e0e900ecfd5c95ccca490ab8e37c8cf1b2bd08 100644 (file)
@@ -1,5 +1,6 @@
 package Analysis.SSJava;
 
+import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Set;
@@ -33,7 +34,7 @@ public class SSJavaAnalysis {
   MethodAnnotationCheck methodAnnotationChecker;
 
   // if a method has annotations, the mapping has true
-  Hashtable<MethodDescriptor, Boolean> md2needAnnotation;
+  Set<MethodDescriptor> annotationRequireSet;
 
   // class -> field lattice
   Hashtable<ClassDescriptor, SSJavaLattice<String>> cd2lattice;
@@ -53,18 +54,29 @@ public class SSJavaAnalysis {
     this.cd2lattice = new Hashtable<ClassDescriptor, SSJavaLattice<String>>();
     this.cd2methodDefault = new Hashtable<ClassDescriptor, MethodLattice<String>>();
     this.md2lattice = new Hashtable<MethodDescriptor, MethodLattice<String>>();
-    this.md2needAnnotation = new Hashtable<MethodDescriptor, Boolean>();
+    this.annotationRequireSet = new HashSet<MethodDescriptor>();
     this.skipLoopTerminate = new Hashtable<MethodDescriptor, Integer>();
   }
 
   public void doCheck() {
     doMethodAnnotationCheck();
+    if (state.SSJAVADEBUG) {
+      debugPrint();
+    }
     parseLocationAnnotation();
     doFlowDownCheck();
     doDefinitelyWrittenCheck();
     doSingleReferenceCheck();
   }
 
+  public void debugPrint() {
+    System.out.println("SSJAVA: SSJava is checking the following methods:");
+    for (Iterator<MethodDescriptor> iterator = annotationRequireSet.iterator(); iterator.hasNext();) {
+      MethodDescriptor md = iterator.next();
+      System.out.println("SSJAVA: " + md);
+    }
+  }
+
   private void doMethodAnnotationCheck() {
     methodAnnotationChecker = new MethodAnnotationCheck(this, state, tu);
     methodAnnotationChecker.methodAnnoatationCheck();
@@ -112,7 +124,7 @@ public class SSJavaAnalysis {
         MethodDescriptor md = (MethodDescriptor) method_it.next();
         // parsing location hierarchy declaration for the method
 
-        if (needAnnotation(md)) {
+        if (needTobeAnnotated(md)) {
           Vector<AnnotationDescriptor> methodAnnotations = md.getModifiers().getAnnotations();
           if (methodAnnotations != null) {
             for (int i = 0; i < methodAnnotations.size(); i++) {
@@ -249,22 +261,21 @@ public class SSJavaAnalysis {
     }
   }
 
-  public boolean needAnnotation(MethodDescriptor md) {
-    return md2needAnnotation.containsKey(md);
+  public boolean needTobeAnnotated(MethodDescriptor md) {
+    return annotationRequireSet.contains(md);
   }
 
-  public void putNeedAnnotation(MethodDescriptor md) {
-    md2needAnnotation.put(md, new Boolean(true));
+  public void addAnnotationRequire(MethodDescriptor md) {
+    annotationRequireSet.add(md);
   }
 
-  public Hashtable<MethodDescriptor, Boolean> getMd2hasAnnotation() {
-    return md2needAnnotation;
+  public Set<MethodDescriptor> getAnnotationRequireSet() {
+    return annotationRequireSet;
   }
 
   public void doLoopTerminationCheck(LoopOptimize lo) {
     LoopTerminate lt = new LoopTerminate();
-    Set<MethodDescriptor> mdSet = md2needAnnotation.keySet();
-    for (Iterator iterator = mdSet.iterator(); iterator.hasNext();) {
+    for (Iterator iterator = annotationRequireSet.iterator(); iterator.hasNext();) {
       MethodDescriptor md = (MethodDescriptor) iterator.next();
       if (!skipLoopTerminate.containsKey(md)) {
         FlatMethod fm = state.getMethodFlat(md);
index 5ef3452c7ca419f7163b65d27def66b7c0926c68..baae40db57b3e40e96963a983340096cf5c2adea 100644 (file)
@@ -33,7 +33,7 @@ public class SingleReferenceCheck {
       ClassDescriptor cd = (ClassDescriptor) it.next();
       for (Iterator method_it = cd.getMethods(); method_it.hasNext();) {
         MethodDescriptor md = (MethodDescriptor) method_it.next();
-        if (ssjava.needAnnotation(md)) {
+        if (ssjava.needTobeAnnotated(md)) {
           checkMethodBody(cd, md);
         }
       }
index bb692cd49c342a43b698d743ae4dd40f856c7892..c4016aa9056f7e0089dd65a4d9120497a5bbf0e9 100644 (file)
@@ -140,6 +140,7 @@ public class State {
 
   //SSJava
   public boolean SSJAVA=false;
+  public boolean SSJAVADEBUG=false;
 
 
   public boolean OPTIONAL=false;
index e8ae399d71ca8d237e10205b0f77d56e34a2b57e..d7d3c7ecdd87bedd75c00d22012088aa6ba1e0a9 100644 (file)
@@ -360,7 +360,9 @@ public class Main {
         state.NOSTALLTR = true;
       } else if (option.equals("-ssjava")) {
         state.SSJAVA = true;
-      } else if (option.equals("-printlinenum")) {
+      } else if (option.equals("-ssjavadebug")) {
+        state.SSJAVADEBUG = true;
+      }else if (option.equals("-printlinenum")) {
         state.LINENUM=true;
       } else if (option.equals("-help")) {
         System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");