From: yeom Date: Thu, 28 Jul 2011 23:19:45 +0000 (+0000) Subject: fix on assigning the global location of the local variable lattice to static fields X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=935d3b537fcb3158b6d6ccf7edd500c6e0d50d21 fix on assigning the global location of the local variable lattice to static fields --- diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 4d949f4d..2d5a6a20 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -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 localLattice = ssjava.getMethodLattice(md); - Location fieldLoc = new Location(md, localLattice.getThisLoc()); - loc.addLocation(fieldLoc); - } + MethodLattice 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; } }