fix on assigning the global location of the local variable lattice to static fields
authoryeom <yeom>
Thu, 28 Jul 2011 23:19:45 +0000 (23:19 +0000)
committeryeom <yeom>
Thu, 28 Jul 2011 23:19:45 +0000 (23:19 +0000)
Robust/src/Analysis/SSJava/FlowDownCheck.java

index 4d949f4df66d143882821569150f4e78c134482b..2d5a6a20f2ce27b4f3a7188ac8e9ec23d708d7a6 100644 (file)
@@ -844,8 +844,18 @@ public class FlowDownCheck {
           checkLocationFromExpressionNode(md, nametable, min.getExpression(),
               new CompositeLocation(), constraint, false);
     } else {
-      String thisLocId = ssjava.getMethodLattice(md).getThisLoc();
-      baseLocation = new CompositeLocation(new Location(md, thisLocId));
+
+      if (min.getMethod().isStatic()) {
+        String globalLocId = ssjava.getMethodLattice(md).getGlobalLoc();
+        if (globalLocId == null) {
+          throw new Error("Method lattice does not define global variable location at "
+              + generateErrorMessage(md.getClassDesc(), min));
+        }
+        baseLocation = new CompositeLocation(new Location(md, globalLocId));
+      } else {
+        String thisLocId = ssjava.getMethodLattice(md).getThisLoc();
+        baseLocation = new CompositeLocation(new Location(md, thisLocId));
+      }
     }
 
     checkCalleeConstraints(md, nametable, min, baseLocation, constraint);
@@ -1163,22 +1173,17 @@ public class FlowDownCheck {
         Location fieldLoc = (Location) fd.getType().getExtension();
         loc.addLocation(fieldLoc);
       } else if (d == null) {
-
-        // check if the var is a static field of the class
-        FieldDescriptor fd = nn.getField();
+        // access static field
         ClassDescriptor cd = nn.getClassDesc();
 
-        if (fd != null && cd != null) {
-
-          if (fd.isStatic() && fd.isFinal()) {
-            loc.addLocation(Location.createTopLocation(md));
-            return loc;
-          } else {
-            MethodLattice<String> localLattice = ssjava.getMethodLattice(md);
-            Location fieldLoc = new Location(md, localLattice.getThisLoc());
-            loc.addLocation(fieldLoc);
-          }
+        MethodLattice<String> localLattice = ssjava.getMethodLattice(md);
+        String globalLocId = localLattice.getGlobalLoc();
+        if (globalLocId == null) {
+          throw new Error("Method lattice does not define global variable location at "
+              + generateErrorMessage(md.getClassDesc(), nn));
         }
+        loc.addLocation(new Location(md, globalLocId));
+        return loc;
 
       }
     }