changes.
[IRC.git] / Robust / src / Analysis / SSJava / MethodAnnotationCheck.java
index df5d779d92ca616b04531b4f5658eadefd899a83..9ed0123f3bf71c9e0e6358c146fb30ab3b321fb9 100644 (file)
@@ -64,7 +64,7 @@ public class MethodAnnotationCheck {
       ClassDescriptor cd = (ClassDescriptor) obj;
       toanalyze.remove(cd);
 
-      if (!cd.isInterface()) {
+      if (!ssjava.isSSJavaUtil(cd) && !cd.isInterface()) {
         for (Iterator method_it = cd.getMethods(); method_it.hasNext();) {
           MethodDescriptor md = (MethodDescriptor) method_it.next();
           checkTrustworthyMethodAnnotation(md);
@@ -76,7 +76,9 @@ public class MethodAnnotationCheck {
 
     for (Iterator iterator = annotatedMDSet.iterator(); iterator.hasNext();) {
       MethodDescriptor md = (MethodDescriptor) iterator.next();
-      ssjava.addAnnotationRequire(md);
+      if (!ssjava.isTrustMethod(md)) {
+        ssjava.addAnnotationRequire(md);
+      }
     }
 
     Set<Pair> visited = new HashSet<Pair>();
@@ -95,7 +97,7 @@ public class MethodAnnotationCheck {
           if (!visited.contains(p)) {
             visited.add(p);
 
-            if (!ssjava.isTrustMethod(calleeMD)) {
+            if (!ssjava.isTrustMethod(callerMD) && !ssjava.isTrustMethod(calleeMD)) {
               // if method is annotated as "TRUST", do not need to check for
               // linear type & flow-down rule
               tovisit.add(calleeMD);
@@ -106,7 +108,7 @@ public class MethodAnnotationCheck {
               for (Iterator iterator2 = possibleCalleeSet.iterator(); iterator2.hasNext();) {
                 MethodDescriptor possibleCallee = (MethodDescriptor) iterator2.next();
 
-                if (!possibleCallee.isAbstract()) {
+                if (!possibleCallee.isAbstract() && !possibleCallee.getModifiers().isNative()) {
                   ssjava.addAnnotationRequire(possibleCallee);
                   tovisit.add(possibleCallee);
                 }
@@ -203,20 +205,10 @@ public class MethodAnnotationCheck {
 
   private void checkBlockNode(MethodDescriptor md, SymbolTable nametable, BlockNode bn, boolean flag) {
     bn.getVarTable().setParent(nametable);
-    String label = bn.getLabel();
-    boolean isSSJavaLoop = flag;
-    if (label != null && label.equals(ssjava.SSJAVA)) {
-      if (isSSJavaLoop) {
-        throw new Error("Only outermost loop can be the self-stabilizing loop.");
-      } else {
-        annotatedMDSet.add(md);
-        isSSJavaLoop = true;
-      }
-    }
 
     for (int i = 0; i < bn.size(); i++) {
       BlockStatementNode bsn = bn.get(i);
-      checkBlockStatementNode(md, bn.getVarTable(), bsn, isSSJavaLoop);
+      checkBlockStatementNode(md, bn.getVarTable(), bsn, flag);
     }
 
   }
@@ -285,9 +277,22 @@ public class MethodAnnotationCheck {
   }
 
   private void checkLoopNode(MethodDescriptor md, SymbolTable nametable, LoopNode ln, boolean flag) {
+
+    String label = ln.getLabel();
+    boolean isSSJavaLoop = flag;
+    if (label != null && label.equals(ssjava.SSJAVA)) {
+      if (isSSJavaLoop) {
+        throw new Error("Only outermost loop can be the self-stabilizing loop.");
+      } else {
+        ssjava.setMethodContainingSSJavaLoop(md);
+        annotatedMDSet.add(md);
+        isSSJavaLoop = true;
+      }
+    }
+
     if (ln.getType() == LoopNode.WHILELOOP || ln.getType() == LoopNode.DOWHILELOOP) {
-      checkExpressionNode(md, nametable, ln.getCondition(), flag);
-      checkBlockNode(md, nametable, ln.getBody(), flag);
+      checkExpressionNode(md, nametable, ln.getCondition(), isSSJavaLoop);
+      checkBlockNode(md, nametable, ln.getBody(), isSSJavaLoop);
     } else {
       // For loop case
       /* Link in the initializer naming environment */
@@ -295,12 +300,12 @@ public class MethodAnnotationCheck {
       bn.getVarTable().setParent(nametable);
       for (int i = 0; i < bn.size(); i++) {
         BlockStatementNode bsn = bn.get(i);
-        checkBlockStatementNode(md, bn.getVarTable(), bsn, flag);
+        checkBlockStatementNode(md, bn.getVarTable(), bsn, isSSJavaLoop);
       }
       // check the condition
-      checkExpressionNode(md, bn.getVarTable(), ln.getCondition(), flag);
-      checkBlockNode(md, bn.getVarTable(), ln.getBody(), flag);
-      checkBlockNode(md, bn.getVarTable(), ln.getUpdate(), flag);
+      checkExpressionNode(md, bn.getVarTable(), ln.getCondition(), isSSJavaLoop);
+      checkBlockNode(md, bn.getVarTable(), ln.getBody(), isSSJavaLoop);
+      checkBlockNode(md, bn.getVarTable(), ln.getUpdate(), isSSJavaLoop);
     }
   }