changes.
[IRC.git] / Robust / src / Analysis / SSJava / LocationInference.java
index 0716bc33dbf3b9ff5bd83633bcbe7098c415bf2a..cd5a58d38ff71bb4b8c464221a5b06566f83b6d5 100644 (file)
@@ -320,11 +320,15 @@ public class LocationInference {
         rtr +=
             "\n@RETURNLOC(\"" + generateLocationAnnoatation(methodLocInfo.getReturnLoc()) + "\")";
       }
-      rtr += "\n@THISLOC(\"this\")\n@GLOBALLOC(\"GLOBALLOC\")";
 
-      if (lattice.containsKey("PCLOC")) {
-        rtr += "\n@PCLOC(\"PCLOC\")";
+      rtr += "\n@THISLOC(\"this\")";
+      rtr += "\n@GLOBALLOC(\"GLOBALLOC\")";
+
+      CompositeLocation pcLoc = methodLocInfo.getPCLoc();
+      if (pcLoc != null) {
+        rtr += "\n@PCLOC(\"" + generateLocationAnnoatation(pcLoc) + "\")";
       }
+
     }
 
     return rtr;
@@ -355,10 +359,12 @@ public class LocationInference {
       }
 
       for (Iterator iter = cd.getFields(); iter.hasNext();) {
-        Descriptor fieldDesc = (Descriptor) iter.next();
-        String locIdentifier = locInfo.getFieldInferLocation(fieldDesc).getLocIdentifier();
-        if (!getLattice(cd).containsKey(locIdentifier)) {
-          getLattice(cd).put(locIdentifier);
+        FieldDescriptor fieldDesc = (FieldDescriptor) iter.next();
+        if (!(fieldDesc.isStatic() && fieldDesc.isFinal())) {
+          String locIdentifier = locInfo.getFieldInferLocation(fieldDesc).getLocIdentifier();
+          if (!getLattice(cd).getElementSet().contains(locIdentifier)) {
+            getLattice(cd).put(locIdentifier);
+          }
         }
       }
 
@@ -374,26 +380,28 @@ public class LocationInference {
         FieldDescriptor fd = (FieldDescriptor) iter.next();
 
         String locAnnotationStr;
-        if (inferLocMap.containsKey(fd)) {
-          CompositeLocation inferLoc = inferLocMap.get(fd);
+        CompositeLocation inferLoc = inferLocMap.get(fd);
+
+        if (inferLoc != null) {
+          // infer loc is null if the corresponding field is static and final
           locAnnotationStr = "@LOC(\"" + generateLocationAnnoatation(inferLoc) + "\")";
-        } else {
-          // if the field is not accssed by SS part, just assigns dummy
-          // location
-          locAnnotationStr = "@LOC(\"LOC\")";
+          int fdLineNum = fd.getLineNum();
+          String orgFieldDeclarationStr = sourceVec.get(fdLineNum);
+          String fieldDeclaration = fd.toString();
+          fieldDeclaration = fieldDeclaration.substring(0, fieldDeclaration.length() - 1);
+          String annoatedStr = locAnnotationStr + " " + orgFieldDeclarationStr;
+          sourceVec.set(fdLineNum, annoatedStr);
         }
-        int fdLineNum = fd.getLineNum();
-        String orgFieldDeclarationStr = sourceVec.get(fdLineNum);
-        String fieldDeclaration = fd.toString();
-        fieldDeclaration = fieldDeclaration.substring(0, fieldDeclaration.length() - 1);
-
-        String annoatedStr = locAnnotationStr + " " + orgFieldDeclarationStr;
-        sourceVec.set(fdLineNum, annoatedStr);
 
       }
 
       while (!toAnalyzeMethodIsEmpty()) {
         MethodDescriptor md = toAnalyzeMethodNext();
+
+        if (!ssjava.needTobeAnnotated(md)) {
+          continue;
+        }
+
         SSJavaLattice<String> methodLattice = md2lattice.get(md);
         if (methodLattice != null) {
 
@@ -405,10 +413,17 @@ public class LocationInference {
               methodLocInfo.getMapDescToInferLocation();
           Set<Descriptor> localVarDescSet = methodInferLocMap.keySet();
 
+          Set<String> localLocElementSet = methodLattice.getElementSet();
+
           for (Iterator iterator = localVarDescSet.iterator(); iterator.hasNext();) {
             Descriptor localVarDesc = (Descriptor) iterator.next();
             CompositeLocation inferLoc = methodInferLocMap.get(localVarDesc);
 
+            String localLocIdentifier = inferLoc.get(0).getLocIdentifier();
+            if (!localLocElementSet.contains(localLocIdentifier)) {
+              methodLattice.put(localLocIdentifier);
+            }
+
             String locAnnotationStr = "@LOC(\"" + generateLocationAnnoatation(inferLoc) + "\")";
 
             if (!isParameter(md, localVarDesc)) {
@@ -430,9 +445,6 @@ public class LocationInference {
                   getParamLocation(methodDefStr,
                       generateVarDeclaration((VarDescriptor) localVarDesc));
 
-              System.out.println("#methodDefStr=" + methodDefStr + " localVar="
-                  + generateVarDeclaration((VarDescriptor) localVarDesc) + "   idx=" + idx);
-
               assert (idx != -1);
 
               String annoatedStr =
@@ -443,6 +455,14 @@ public class LocationInference {
 
           }
 
+          // check if the lattice has to have the location type for the this
+          // reference...
+
+          // boolean needToAddthisRef = hasThisReference(md);
+          if (localLocElementSet.contains("this")) {
+            methodLattice.put("this");
+          }
+
           String methodLatticeDefStr = generateLatticeDefinition(md);
           String annoatedStr = methodLatticeDefStr + newline + sourceVec.get(methodDefLine);
           sourceVec.set(methodDefLine, annoatedStr);
@@ -455,6 +475,20 @@ public class LocationInference {
     codeGen();
   }
 
+  private boolean hasThisReference(MethodDescriptor md) {
+
+    FlowGraph fg = getFlowGraph(md);
+    Set<FlowNode> nodeSet = fg.getNodeSet();
+    for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
+      FlowNode flowNode = (FlowNode) iterator.next();
+      if (flowNode.getDescTuple().get(0).equals(md.getThis())) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
   private int getParamLocation(String methodStr, String paramStr) {
 
     String pattern = paramStr + ",";
@@ -484,7 +518,6 @@ public class LocationInference {
   }
 
   private String generateLocationAnnoatation(CompositeLocation loc) {
-
     String rtr = "";
     // method location
     Location methodLoc = loc.get(0);
@@ -574,7 +607,7 @@ public class LocationInference {
     // dependency in the call graph
     methodDescriptorsToVisitStack.clear();
 
-    descriptorListToAnalyze.removeFirst();
+    // descriptorListToAnalyze.removeFirst();
 
     Set<MethodDescriptor> methodDescriptorToVistSet = new HashSet<MethodDescriptor>();
     methodDescriptorToVistSet.addAll(descriptorListToAnalyze);
@@ -629,13 +662,15 @@ public class LocationInference {
 
     // do fixed-point analysis
 
+    ssjava.init();
     LinkedList<MethodDescriptor> descriptorListToAnalyze = ssjava.getSortedDescriptors();
 
-    Collections.sort(descriptorListToAnalyze, new Comparator<MethodDescriptor>() {
-      public int compare(MethodDescriptor o1, MethodDescriptor o2) {
-        return o1.getSymbol().compareToIgnoreCase(o2.getSymbol());
-      }
-    });
+    // Collections.sort(descriptorListToAnalyze, new
+    // Comparator<MethodDescriptor>() {
+    // public int compare(MethodDescriptor o1, MethodDescriptor o2) {
+    // return o1.getSymbol().compareToIgnoreCase(o2.getSymbol());
+    // }
+    // });
 
     // current descriptors to visit in fixed-point interprocedural analysis,
     // prioritized by
@@ -694,6 +729,13 @@ public class LocationInference {
       }
 
     }
+
+    descriptorListToAnalyze = ssjava.getSortedDescriptors();
+    for (Iterator iterator = descriptorListToAnalyze.iterator(); iterator.hasNext();) {
+      MethodDescriptor md = (MethodDescriptor) iterator.next();
+      calculateExtraLocations(md);
+    }
+
   }
 
   private void setMethodLocInfo(MethodDescriptor md, MethodLocationInfo methodInfo) {
@@ -745,10 +787,8 @@ public class LocationInference {
 
     if (!md1.getReturnType().isVoid()) {
       // add return value location
-      CompositeLocation rtrLoc1 =
-          new CompositeLocation(new Location(md1, locInfo1.getReturnLocName()));
-      CompositeLocation rtrLoc2 =
-          new CompositeLocation(new Location(md2, locInfo2.getReturnLocName()));
+      CompositeLocation rtrLoc1 = getMethodLocationInfo(md1).getReturnLoc();
+      CompositeLocation rtrLoc2 = getMethodLocationInfo(md2).getReturnLoc();
       list1.add(rtrLoc1);
       list2.add(rtrLoc2);
     }
@@ -852,46 +892,10 @@ public class LocationInference {
             // value flow between local var - local var or local var - field
             addRelationToLattice(md, methodLattice, methodInfo, srcNode, dstNode);
           }
-
-          // else if (srcNodeTuple.size() == 1 || dstNodeTuple.size() == 1) {
-          // // for the method lattice, we need to look at the first element of
-          // // NTuple<Descriptor>
-          // // in this case, take a look at connected nodes at the local level
-          // addRelationToLattice(md, methodLattice, methodInfo, srcNode,
-          // dstNode);
-          // } else {
-          // if
-          // (!srcNode.getDescTuple().get(0).equals(dstNode.getDescTuple().get(0)))
-          // {
-          // // in this case, take a look at connected nodes at the local level
-          // addRelationToLattice(md, methodLattice, methodInfo, srcNode,
-          // dstNode);
-          // } else {
-          // Descriptor srcDesc = srcNode.getDescTuple().get(0);
-          // Descriptor dstDesc = dstNode.getDescTuple().get(0);
-          // recursivelyAddCompositeRelation(md, fg, methodInfo, srcNode,
-          // dstNode, srcDesc,
-          // dstDesc);
-          // // recursiveAddRelationToLattice(1, md, srcNode, dstNode);
-          // }
-          // }
-
         }
       }
     }
 
-    for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
-      FlowNode flowNode = (FlowNode) iterator.next();
-      if (flowNode.isDeclaratonNode()) {
-        CompositeLocation inferLoc = methodInfo.getInferLocation(flowNode.getDescTuple().get(0));
-        String locIdentifier = inferLoc.get(0).getLocIdentifier();
-        if (!methodLattice.containsKey(locIdentifier)) {
-          methodLattice.put(locIdentifier);
-        }
-
-      }
-    }
-
     // create mapping from param idx to inferred composite location
 
     int offset;
@@ -909,106 +913,146 @@ public class LocationInference {
       methodInfo.addMapParamIdxToInferLoc(idx + offset, inferParamLoc);
     }
 
-    Map<Integer, CompositeLocation> mapParamToLoc = methodInfo.getMapParamIdxToInferLoc();
-    Set<Integer> keySet = mapParamToLoc.keySet();
-
-    if (!ssjava.getMethodContainingSSJavaLoop().equals(md)) {
-      // calculate the initial program counter location
-      // PC location is higher than location types of all parameters
-      String pcLocSymbol = "PCLOC";
-      for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
-        Integer paramIdx = (Integer) iterator.next();
-        CompositeLocation inferLoc = mapParamToLoc.get(paramIdx);
-        String paramLocLocalSymbol = inferLoc.get(0).getLocIdentifier();
-        if (!methodLattice.isGreaterThan(pcLocSymbol, paramLocLocalSymbol)) {
-          addRelationHigherToLower(methodLattice, methodInfo, pcLocSymbol, paramLocLocalSymbol);
-
-          Set<String> higherLocSet = getHigherLocSymbolThan(methodLattice, paramLocLocalSymbol);
-          higherLocSet.remove(pcLocSymbol);
-          for (Iterator iterator2 = higherLocSet.iterator(); iterator2.hasNext();) {
-            String loc = (String) iterator2.next();
-            addRelationHigherToLower(methodLattice, methodInfo, pcLocSymbol, loc);
-          }
+  }
+
+  private void calculateExtraLocations(MethodDescriptor md) {
+    // calcualte pcloc, returnloc,...
+
+    SSJavaLattice<String> methodLattice = getMethodLattice(md);
+    MethodLocationInfo methodInfo = getMethodLocationInfo(md);
+    FlowGraph fg = getFlowGraph(md);
+    Set<FlowNode> nodeSet = fg.getNodeSet();
+
+    for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
+      FlowNode flowNode = (FlowNode) iterator.next();
+      if (flowNode.isDeclaratonNode()) {
+        CompositeLocation inferLoc = methodInfo.getInferLocation(flowNode.getDescTuple().get(0));
+        String locIdentifier = inferLoc.get(0).getLocIdentifier();
+        if (!methodLattice.containsKey(locIdentifier)) {
+          methodLattice.put(locIdentifier);
         }
+
       }
     }
 
-    // calculate a return location
-    // the return location type is lower than all parameters and location types
-    // of return values
-    if (!md.getReturnType().isVoid()) {
+    Map<Integer, CompositeLocation> mapParamToLoc = methodInfo.getMapParamIdxToInferLoc();
+    Set<Integer> paramIdxSet = mapParamToLoc.keySet();
 
-      // first, generate the set of return value location types that starts with
-      // 'this' reference
+    try {
+      if (!ssjava.getMethodContainingSSJavaLoop().equals(md)) {
+        // calculate the initial program counter location
+        // PC location is higher than location types of all parameters
+        String pcLocSymbol = "PCLOC";
 
-      Set<CompositeLocation> inferFieldReturnLocSet = new HashSet<CompositeLocation>();
+        Set<CompositeLocation> paramInFlowSet = new HashSet<CompositeLocation>();
 
-      Set<FlowNode> paramFlowNode = getParamNodeFlowingToReturnValue(md);
-      Set<CompositeLocation> inferParamLocSet = new HashSet<CompositeLocation>();
-      if (paramFlowNode != null) {
-        for (Iterator iterator = paramFlowNode.iterator(); iterator.hasNext();) {
-          FlowNode fn = (FlowNode) iterator.next();
-          CompositeLocation inferLoc =
-              generateInferredCompositeLocation(methodInfo, getFlowGraph(md).getLocationTuple(fn));
-          inferParamLocSet.add(inferLoc);
-        }
-      }
+        for (Iterator iterator = paramIdxSet.iterator(); iterator.hasNext();) {
+          Integer paramIdx = (Integer) iterator.next();
 
-      Set<FlowNode> returnNodeSet = fg.getReturnNodeSet();
-      skip: for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
-        FlowNode returnNode = (FlowNode) iterator.next();
-        CompositeLocation inferReturnLoc =
-            generateInferredCompositeLocation(methodInfo, fg.getLocationTuple(returnNode));
-        System.out.println("@inferReturnLoc=" + inferReturnLoc);
-        if (inferReturnLoc.get(0).getLocIdentifier().equals("this")) {
-          // if the location type of the return value matches "this" reference
-          // then, check whether this return value is equal to/lower than all of
-          // parameters that possibly flow into the return values
-          for (Iterator iterator2 = inferParamLocSet.iterator(); iterator2.hasNext();) {
-            CompositeLocation paramInferLoc = (CompositeLocation) iterator2.next();
-
-            if ((!paramInferLoc.equals(inferReturnLoc))
-                && !isGreaterThan(methodLattice, paramInferLoc, inferReturnLoc)) {
-              continue skip;
-            }
+          FlowNode paramFlowNode = fg.getParamFlowNode(paramIdx);
+
+          if (fg.getIncomingFlowNodeSet(paramFlowNode).size() > 0) {
+            // parameter has in-value flows
+            CompositeLocation inferLoc = mapParamToLoc.get(paramIdx);
+            paramInFlowSet.add(inferLoc);
           }
-          inferFieldReturnLocSet.add(inferReturnLoc);
+        }
 
+        if (paramInFlowSet.size() > 0) {
+          CompositeLocation lowestLoc = getLowest(methodLattice, paramInFlowSet);
+          assert (lowestLoc != null);
+          methodInfo.setPCLoc(lowestLoc);
         }
+
       }
 
-      if (inferFieldReturnLocSet.size() > 0) {
+      // calculate a return location
+      // the return location type is lower than all parameters and location
+      // types
+      // of return values
+      if (!md.getReturnType().isVoid()) {
+        // first, generate the set of return value location types that starts
+        // with
+        // 'this' reference
 
-        CompositeLocation returnLoc = getLowest(methodLattice, inferFieldReturnLocSet);
-        methodInfo.setReturnLoc(returnLoc);
+        Set<CompositeLocation> inferFieldReturnLocSet = new HashSet<CompositeLocation>();
 
-      } else {
-        String returnLocSymbol = "RETURNLOC";
-        CompositeLocation returnLocInferLoc =
-            new CompositeLocation(new Location(md, returnLocSymbol));
-        methodInfo.setReturnLoc(returnLocInferLoc);
-
-        for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
-          Integer paramIdx = (Integer) iterator.next();
-          CompositeLocation inferLoc = mapParamToLoc.get(paramIdx);
-          String paramLocLocalSymbol = inferLoc.get(0).getLocIdentifier();
-          if (!methodLattice.isGreaterThan(paramLocLocalSymbol, returnLocSymbol)) {
-            addRelationHigherToLower(methodLattice, methodInfo, paramLocLocalSymbol,
-                returnLocSymbol);
+        Set<FlowNode> paramFlowNode = getParamNodeFlowingToReturnValue(md);
+        Set<CompositeLocation> inferParamLocSet = new HashSet<CompositeLocation>();
+        if (paramFlowNode != null) {
+          for (Iterator iterator = paramFlowNode.iterator(); iterator.hasNext();) {
+            FlowNode fn = (FlowNode) iterator.next();
+            CompositeLocation inferLoc =
+                generateInferredCompositeLocation(methodInfo, getFlowGraph(md).getLocationTuple(fn));
+            inferParamLocSet.add(inferLoc);
           }
         }
 
-        for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
+        Set<FlowNode> returnNodeSet = fg.getReturnNodeSet();
+
+        skip: for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
           FlowNode returnNode = (FlowNode) iterator.next();
-          CompositeLocation inferLoc =
+          CompositeLocation inferReturnLoc =
               generateInferredCompositeLocation(methodInfo, fg.getLocationTuple(returnNode));
-          if (!isGreaterThan(methodLattice, inferLoc, returnLocInferLoc)) {
-            addRelation(methodLattice, methodInfo, inferLoc, returnLocInferLoc);
+          if (inferReturnLoc.get(0).getLocIdentifier().equals("this")) {
+            // if the location type of the return value matches "this" reference
+            // then, check whether this return value is equal to/lower than all
+            // of
+            // parameters that possibly flow into the return values
+            for (Iterator iterator2 = inferParamLocSet.iterator(); iterator2.hasNext();) {
+              CompositeLocation paramInferLoc = (CompositeLocation) iterator2.next();
+
+              if ((!paramInferLoc.equals(inferReturnLoc))
+                  && !isGreaterThan(methodLattice, paramInferLoc, inferReturnLoc)) {
+                continue skip;
+              }
+            }
+            inferFieldReturnLocSet.add(inferReturnLoc);
+
           }
         }
 
-      }
+        if (inferFieldReturnLocSet.size() > 0) {
+
+          CompositeLocation returnLoc = getLowest(methodLattice, inferFieldReturnLocSet);
+          if (returnLoc == null) {
+            // in this case, assign <'this',bottom> to the RETURNLOC
+            returnLoc = new CompositeLocation(new Location(md, md.getThis().getSymbol()));
+            returnLoc.addLocation(new Location(md.getClassDesc(), getLattice(md.getClassDesc())
+                .getBottomItem()));
+          }
+          methodInfo.setReturnLoc(returnLoc);
 
+        } else {
+          String returnLocSymbol = "RETURNLOC";
+          CompositeLocation returnLocInferLoc =
+              new CompositeLocation(new Location(md, returnLocSymbol));
+          methodInfo.setReturnLoc(returnLocInferLoc);
+
+          for (Iterator iterator = paramIdxSet.iterator(); iterator.hasNext();) {
+            Integer paramIdx = (Integer) iterator.next();
+            CompositeLocation inferLoc = mapParamToLoc.get(paramIdx);
+            String paramLocLocalSymbol = inferLoc.get(0).getLocIdentifier();
+            if (!methodLattice.isGreaterThan(paramLocLocalSymbol, returnLocSymbol)) {
+              addRelationHigherToLower(methodLattice, methodInfo, paramLocLocalSymbol,
+                  returnLocSymbol);
+            }
+          }
+
+          for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
+            FlowNode returnNode = (FlowNode) iterator.next();
+            CompositeLocation inferLoc =
+                generateInferredCompositeLocation(methodInfo, fg.getLocationTuple(returnNode));
+            if (!isGreaterThan(methodLattice, inferLoc, returnLocInferLoc)) {
+              addRelation(methodLattice, methodInfo, inferLoc, returnLocInferLoc);
+            }
+          }
+
+        }
+
+      }
+    } catch (CyclicFlowException e) {
+      e.printStackTrace();
     }
 
   }
@@ -1037,13 +1081,57 @@ public class LocationInference {
 
     for (Iterator iterator = set.iterator(); iterator.hasNext();) {
       CompositeLocation loc = (CompositeLocation) iterator.next();
-      if (isGreaterThan(methodLattice, lowest, loc)) {
+
+      if ((!loc.equals(lowest)) && (!isComparable(methodLattice, lowest, loc))) {
+        // if there is a case where composite locations are incomparable, just
+        // return null
+        return null;
+      }
+
+      if ((!loc.equals(lowest)) && isGreaterThan(methodLattice, lowest, loc)) {
         lowest = loc;
       }
     }
     return lowest;
   }
 
+  private boolean isComparable(SSJavaLattice<String> methodLattice, CompositeLocation comp1,
+      CompositeLocation comp2) {
+
+    int size = comp1.getSize() >= comp2.getSize() ? comp2.getSize() : comp1.getSize();
+
+    for (int idx = 0; idx < size; idx++) {
+      Location loc1 = comp1.get(idx);
+      Location loc2 = comp2.get(idx);
+
+      Descriptor desc1 = loc1.getDescriptor();
+      Descriptor desc2 = loc2.getDescriptor();
+
+      if (!desc1.equals(desc2)) {
+        throw new Error("Fail to compare " + comp1 + " and " + comp2);
+      }
+
+      String symbol1 = loc1.getLocIdentifier();
+      String symbol2 = loc2.getLocIdentifier();
+
+      SSJavaLattice<String> lattice;
+      if (idx == 0) {
+        lattice = methodLattice;
+      } else {
+        lattice = getLattice(desc1);
+      }
+
+      if (symbol1.equals(symbol2)) {
+        continue;
+      } else if (!lattice.isComparable(symbol1, symbol2)) {
+        return false;
+      }
+
+    }
+
+    return true;
+  }
+
   private boolean isGreaterThan(SSJavaLattice<String> methodLattice, CompositeLocation comp1,
       CompositeLocation comp2) {
 
@@ -1069,6 +1157,7 @@ public class LocationInference {
       } else {
         lattice = getLattice(desc1);
       }
+
       if (symbol1.equals(symbol2)) {
         continue;
       } else if (lattice.isGreaterThan(symbol1, symbol2)) {
@@ -1152,6 +1241,7 @@ public class LocationInference {
       for (int k = 0; k < numParam; k++) {
         if (i != k) {
           CompositeLocation param2 = calleeLocInfo.getParamCompositeLocation(k);
+
           if (isGreaterThan(getLattice(possibleMdCallee), param1, param2)) {
             NodeTupleSet argDescTupleSet1 = getNodeTupleSetByArgIdx(min, i);
             NodeTupleSet argDescTupleSet2 = getNodeTupleSetByArgIdx(min, k);
@@ -1219,8 +1309,6 @@ public class LocationInference {
       Location inferLocElement;
       if (curDesc == null) {
         // in this case, we have a newly generated location.
-        // System.out.println("!!! generated location=" +
-        // cur.getLocIdentifier());
         inferLocElement = new Location(enclosingDesc, cur.getLocIdentifier());
       } else {
         String fieldLocSymbol =
@@ -1496,7 +1584,7 @@ public class LocationInference {
         if (inferLocation.getTuple().startsWith(curPrefix)) {
           // the same infer location is already existed. no need to do
           // anything
-          System.out.println("NO ATTEMPT TO HAVE A COMPOSITE LOCATION curPrefix=" + curPrefix);
+          System.out.println("NO ATTEMPT TO MAKE A COMPOSITE LOCATION curPrefix=" + curPrefix);
           return true;
         } else {
           // assign a new composite location
@@ -2211,8 +2299,6 @@ public class LocationInference {
   private void analyzeFlowMethodInvokeNode(MethodDescriptor md, SymbolTable nametable,
       MethodInvokeNode min, NodeTupleSet nodeSet, NodeTupleSet implicitFlowTupleSet) {
 
-    System.out.println("analyzeFlowMethodInvokeNode=" + min.printNode(0));
-
     if (nodeSet == null) {
       nodeSet = new NodeTupleSet();
     }
@@ -2228,8 +2314,7 @@ public class LocationInference {
     }
 
     if (!ssjava.isSSJavaUtil(calleeMethodDesc.getClassDesc())
-        && !ssjava.isTrustMethod(calleeMethodDesc) && !calleeMethodDesc.getModifiers().isNative()
-        && !isSystemout) {
+        && !ssjava.isTrustMethod(calleeMethodDesc) && !isSystemout) {
 
       FlowGraph calleeFlowGraph = getFlowGraph(calleeMethodDesc);
       Set<FlowNode> calleeReturnSet = calleeFlowGraph.getReturnNodeSet();
@@ -2242,7 +2327,6 @@ public class LocationInference {
 
         if (!min.getMethod().isStatic()) {
           addArgIdxMap(min, 0, baseNodeSet);
-          // System.out.println("arg idx=0  argTupleSet=" + baseNodeSet);
 
           for (Iterator iterator = calleeReturnSet.iterator(); iterator.hasNext();) {
             FlowNode returnNode = (FlowNode) iterator.next();
@@ -2285,13 +2369,12 @@ public class LocationInference {
           ExpressionNode en = min.getArg(i);
           int idx = i + offset;
           NodeTupleSet argTupleSet = new NodeTupleSet();
-          analyzeFlowExpressionNode(calleeMethodDesc, nametable, en, argTupleSet, false);
+          analyzeFlowExpressionNode(md, nametable, en, argTupleSet, true);
           // if argument is liternal node, argTuple is set to NULL.
           addArgIdxMap(min, idx, argTupleSet);
-          // System.out.println("arg idx=" + (idx) + "  argTupleSet=" +
-          // argTupleSet);
           FlowNode paramNode = calleeFlowGraph.getParamFlowNode(idx);
-          if (hasInFlowTo(calleeFlowGraph, paramNode, calleeReturnSet)) {
+          if (hasInFlowTo(calleeFlowGraph, paramNode, calleeReturnSet)
+              || calleeMethodDesc.getModifiers().isNative()) {
             addParamNodeFlowingToReturnValue(calleeMethodDesc, paramNode);
             nodeSet.addTupleSet(argTupleSet);
           }
@@ -2352,7 +2435,6 @@ public class LocationInference {
         analyzeFlowExpressionNode(callermd, nametable, en, argTupleSet, false);
         // if argument is liternal node, argTuple is set to NULL.
         addArgIdxMap(min, i + offset, argTupleSet);
-        System.out.println("arg idx=" + (i + offset) + "  argTupleSet=" + argTupleSet);
         nodeSet.addTupleSet(argTupleSet);
       }
 
@@ -2368,7 +2450,8 @@ public class LocationInference {
       ArrayAccessNode aan, NodeTupleSet nodeSet, boolean isLHS) {
 
     NodeTupleSet expNodeTupleSet = new NodeTupleSet();
-    analyzeFlowExpressionNode(md, nametable, aan.getExpression(), expNodeTupleSet, isLHS);
+    NTuple<Descriptor> base =
+        analyzeFlowExpressionNode(md, nametable, aan.getExpression(), expNodeTupleSet, isLHS);
 
     NodeTupleSet idxNodeTupleSet = new NodeTupleSet();
     analyzeFlowExpressionNode(md, nametable, aan.getIndex(), idxNodeTupleSet, isLHS);
@@ -2530,7 +2613,6 @@ public class LocationInference {
 
       }
     }
-
     getFlowGraph(md).createNewFlowNode(base);
 
     return base;