Change in conflict tracker!
[jpf-core.git] / src / main / gov / nasa / jpf / listener / ConflictTracker.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package gov.nasa.jpf.listener;
19
20 import gov.nasa.jpf.Config;
21 import gov.nasa.jpf.JPF;
22 import gov.nasa.jpf.ListenerAdapter;
23 import gov.nasa.jpf.search.Search;
24 import gov.nasa.jpf.jvm.bytecode.*;
25 import gov.nasa.jpf.vm.*;
26 import gov.nasa.jpf.vm.bytecode.LocalVariableInstruction;
27 import gov.nasa.jpf.vm.bytecode.ReadInstruction;
28 import gov.nasa.jpf.vm.bytecode.StoreInstruction;
29 import gov.nasa.jpf.vm.bytecode.WriteInstruction;
30
31 import java.io.PrintWriter;
32
33 import java.util.*;
34
35 /**
36  * Listener using data flow analysis to find conflicts between smartApps.
37  **/
38
39 public class ConflictTracker extends ListenerAdapter {
40   private final PrintWriter out;
41   private final HashSet<String> conflictSet = new HashSet<String>(); // Variables we want to track
42   private final HashSet<String> appSet = new HashSet<String>(); // Apps we want to find their conflicts
43   private final HashSet<String> manualSet = new HashSet<String>(); // Writer classes with manual inputs to detect direct-direct(No Conflict) interactions
44   private final HashMap<Integer, Node> nodes = new HashMap<Integer, Node>(); // Nodes of a graph
45   private ArrayList<NameValuePair> tempSetSet = new ArrayList<NameValuePair>();
46   private long timeout;
47   private long startTime;
48   private Node parentNode = new Node(-2);
49   private String operation;
50   private String detail;
51   private String errorMessage;
52   private int depth;
53   private int id;
54   private boolean conflictFound = false;
55   private boolean manual = false;
56
57   private final String SET_LOCATION_METHOD = "setLocationMode";
58   private final String LOCATION_VAR = "locationMode";
59   
60   public ConflictTracker(Config config, JPF jpf) {
61     out = new PrintWriter(System.out, true);
62
63     String[] conflictVars = config.getStringArray("variables");
64     // We are not tracking anything if it is null
65     if (conflictVars != null) {
66       for (String var : conflictVars) {
67         conflictSet.add(var);
68       }
69     }
70     String[] apps = config.getStringArray("apps");
71     // We are not tracking anything if it is null
72     if (apps != null) {
73       for (String var : apps) {
74         appSet.add(var);
75       }
76     }
77     String[] manualClasses = config.getStringArray("manualClasses");
78     // We are not tracking anything if it is null
79     if (manualClasses != null) {
80       for (String var : manualClasses) {
81         manualSet.add(var);
82       }
83     }
84
85     // Timeout input from config is in minutes, so we need to convert into millis
86     timeout = config.getInt("timeout", 0) * 60 * 1000;
87     startTime = System.currentTimeMillis();
88   }
89
90   boolean propagateTheChange(Node currentNode) {
91         HashSet<Node> changed = new HashSet<Node>(currentNode.getSuccessors());
92         HashMap<Node, HashSet<Node>> parentQueueMap = new HashMap<Node, HashSet<Node>>();
93         HashSet<Node> parents = new HashSet<Node>();
94         parents.add(currentNode);
95
96         for (Node node : currentNode.getSuccessors()) {
97                 parentQueueMap.put(node, parents);
98         }
99
100         while(!changed.isEmpty()) {
101                 // Get the first element of the changed set and remove it
102                 Node nodeToProcess = changed.iterator().next();
103                 changed.remove(nodeToProcess);
104
105                 // Update the changed parents
106                 parents = parentQueueMap.get(nodeToProcess);
107                 boolean isChanged = false;
108
109                 for (Node node : parents) {
110                         // Update the edge
111                         isChanged |= updateTheOutSet(node, nodeToProcess);
112                 }
113
114                 // Check for a conflict if the outSet of nodeToProcess is changed
115                 if (isChanged) {
116                         for (Node node : nodeToProcess.getSuccessors()) {
117                                 HashMap<Transition, ArrayList<NameValuePair>> setSets = nodeToProcess.getOutgoingEdges().get(node).getSetSetMap();
118                                 for (Map.Entry mapElement : setSets.entrySet()) {
119                                         Transition transition = (Transition)mapElement.getKey();
120                                         if (checkForConflict(nodeToProcess, node, transition))
121                                                 return true;
122                                 }
123                         }
124                 }
125
126                 // Update the parents list for the successors of the current node
127                 parents = new HashSet<Node>();
128                 parents.add(nodeToProcess);
129
130                 // Checking if the out set has changed or not(Add its successors to the change list!)
131                 if (isChanged) {
132                         for (Node i : nodeToProcess.getSuccessors()) {
133                                 if (!changed.contains(i))
134                                         changed.add(i);
135
136                                 // Update the list of updated parents for the current node
137                                 if (parentQueueMap.containsKey(i))
138                                         parentQueueMap.get(i).add(nodeToProcess);
139                                 else
140                                         parentQueueMap.put(i, parents);
141                         }
142                 }
143       }
144
145       return false;
146   }
147
148   String createErrorMessage(NameValuePair pair, HashMap<String, String> valueMap, HashMap<String, Integer> writerMap) {
149         String message = "Conflict found between the two apps. App"+pair.getAppNum()+
150                          " has written the value: "+pair.getValue()+
151                          " to the variable: "+pair.getVarName()+" while App"
152                          +writerMap.get(pair.getVarName())+" is overwriting the value: "
153                          +valueMap.get(pair.getVarName())+" to the same variable!";
154         System.out.println(message);    
155         return message;
156   }
157
158   boolean checkForConflict(Node parentNode, Node currentNode, Transition currentTransition) {
159         ArrayList<NameValuePair> setSet = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap().get(currentTransition);
160         HashMap<String, String> valueMap = new HashMap<String, String>(); // HashMap from varName to value
161         HashMap<String, Integer> writerMap = new HashMap<String, Integer>(); //  HashMap from varName to appNum
162
163         // Update the valueMap and writerMap + check for conflict between the elements of setSet
164         for (int i = 0;i < setSet.size();i++) {
165             NameValuePair nameValuePair = setSet.get(i);
166             String varName = nameValuePair.getVarName();
167             String value = nameValuePair.getValue();
168             Integer appNum = nameValuePair.getAppNum();
169
170             if (valueMap.containsKey(varName)) {
171                 // Check if we have a same writer
172                 if (!writerMap.get(varName).equals(appNum)) {
173                         // Check if we have a conflict or not
174                         if (!valueMap.get(varName).equals(value)) {
175                                 errorMessage = createErrorMessage(nameValuePair, valueMap, writerMap);
176                                 return true;
177                         } else { // We have two writers writing the same value
178                                 writerMap.put(varName, 3); // 3 represents both apps
179                         }
180                 } else {
181                         // Check if we have more than one value with the same writer
182                         if (!valueMap.get(varName).equals(value)) {
183                                 // We have one writer writing more than one value in a same event
184                                 valueMap.put(varName, "twoValue");
185                         }
186                 }
187              } else {
188                 valueMap.put(varName, value);
189                 writerMap.put(varName, appNum);
190              }
191         }
192
193         // Check for conflict between outSet and this transition setSet
194         for (NameValuePair i : currentNode.getOutSet()) {
195              if (valueMap.containsKey(i.getVarName())) {
196                  String value = valueMap.get(i.getVarName());
197                  Integer writer = writerMap.get(i.getVarName());
198                      if ((value != null)&&(writer != null)) {
199                          if (!value.equals(i.getValue())&&!writer.equals(i.getAppNum())) { 
200                              // We have different values and different writers
201                              errorMessage = createErrorMessage(i, valueMap, writerMap);
202                              return true;
203                          }
204                      }
205              }
206        }
207
208        return false;
209   }
210
211   boolean updateTheOutSet(Node parentNode, Node currentNode) {
212         HashMap<Transition, ArrayList<NameValuePair>> setSets = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap();
213         HashSet<String> updatedVarNames = new HashSet<String>();
214         Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
215         HashMap<String, Integer> lastWriter = currentEdge.getLastWriter();
216         HashMap<String, String> lastValue = currentEdge.getLastValue();
217         HashMap<String, Integer> outSetVarMap = new HashMap<String, Integer>();
218         boolean isChanged = false;
219
220         for (Map.Entry mapElement : setSets.entrySet()) {
221             ArrayList<NameValuePair> setSet = (ArrayList<NameValuePair>)mapElement.getValue();
222   
223             for (int i = 0;i < setSet.size();i++) {
224                         updatedVarNames.add(setSet.get(i).getVarName());
225             }
226         }
227
228
229         for (NameValuePair i : parentNode.getOutSet()) {
230                 outSetVarMap.put(i.getVarName(), i.getAppNum());
231                 if (!updatedVarNames.contains(i.getVarName()))
232                         isChanged |= currentNode.getOutSet().add(i);
233         }
234
235
236         for (Map.Entry mapElement : setSets.entrySet()) {
237             ArrayList<NameValuePair> setSet = (ArrayList<NameValuePair>)mapElement.getValue();
238   
239             for (int i = 0;i < setSet.size();i++) {
240                         String varName = setSet.get(i).getVarName();
241                         Integer writer = lastWriter.get(varName);
242                         String value = lastValue.get(varName);
243
244                         if (setSet.get(i).getAppNum().equals(writer) 
245                             && setSet.get(i).getValue().equals(value)) {
246                                 if (outSetVarMap.containsKey(varName)) {
247                                         Integer hashCode = outSetVarMap.get(varName).hashCode() * 31 +
248                                                            varName.hashCode();
249                                         currentNode.getOutSet().remove(hashCode);
250                                 }
251                                 isChanged |= currentNode.getOutSet().add(setSet.get(i));
252                         }
253             }
254         }
255
256         return isChanged;
257   }
258
259   void updateTheEdge(Node currentNode, Transition transition) {
260         if (parentNode.getOutgoingEdges().containsKey(currentNode)) {
261                 Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
262                 if (currentEdge.getSetSetMap().containsKey(transition)) { // Update the transition
263                         if (manual)
264                                 currentEdge.getSetSetMap().put(transition, tempSetSet);
265                         else
266                                 currentEdge.getSetSetMap().get(transition).addAll(tempSetSet);
267                 } else { // Add a new transition
268                         currentEdge.getSetSetMap().put(transition, tempSetSet);
269                 }
270         } else {
271                 parentNode.getOutgoingEdges().put(currentNode, new Edge(parentNode, currentNode));
272                 Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
273                 currentEdge.getSetSetMap().put(transition, tempSetSet);
274         }
275
276         // Update the last writer and last value for this edge for each varName
277         Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
278         ArrayList<NameValuePair> setSet = currentEdge.getSetSetMap().get(transition);
279         for (int i = 0;i < setSet.size();i++) {
280                 NameValuePair nameValuePair = setSet.get(i);
281                 currentEdge.getLastWriter().put(nameValuePair.getVarName(), nameValuePair.getAppNum());
282                 currentEdge.getLastValue().put(nameValuePair.getVarName(), nameValuePair.getValue());
283         }
284   }
285
286   
287
288   static class Node {
289         Integer id;
290         HashSet<Node> predecessors = new HashSet<Node>();
291         HashSet<Node> successors = new HashSet<Node>();
292         HashSet<NameValuePair> outSet = new HashSet<NameValuePair>();
293         HashMap<Node, Edge> outgoingEdges = new HashMap<Node, Edge>();
294
295         Node(Integer id) {
296           this.id = id;
297         }
298
299         Integer getId() {
300                 return id;
301         }
302
303         HashSet<Node> getPredecessors() {
304                 return predecessors;
305         }
306
307         HashSet<Node> getSuccessors() {
308                 return successors;
309         }
310
311         HashSet<NameValuePair> getOutSet() {
312                 return outSet;
313         }
314
315         HashMap<Node, Edge> getOutgoingEdges() {
316                 return outgoingEdges;
317         }
318   }
319
320   static class Edge {
321         Node source, destination;
322         HashMap<String, Integer> lastWriter = new HashMap<String, Integer>();
323         HashMap<String, String> lastValue = new HashMap<String, String>();
324         HashMap<Transition, ArrayList<NameValuePair>> setSetMap = new HashMap<Transition, ArrayList<NameValuePair>>();
325
326         Edge(Node source, Node destination) {
327                 this.source = source;
328                 this.destination = destination;
329         }
330
331         Node getSource() {
332                 return source;
333         }
334
335         Node getDestination() {
336                 return destination;
337         }
338
339         HashMap<Transition, ArrayList<NameValuePair>> getSetSetMap() {
340                 return setSetMap;
341         }
342
343         HashMap<String, Integer> getLastWriter() {
344                 return lastWriter;
345         }
346
347         HashMap<String, String> getLastValue() {
348                 return lastValue;
349         }
350   }
351
352   static class NameValuePair {
353         Integer appNum;
354         String value;
355         String varName;
356         boolean isManual;
357
358         NameValuePair(Integer appNum, String value, String varName, boolean isManual) {
359                 this.appNum = appNum;
360                 this.value = value;
361                 this.varName = varName;
362                 this.isManual = isManual;
363         }
364
365         void setAppNum(Integer appNum) {
366                 this.appNum = appNum;
367         }
368
369         void setValue(String value) {
370                 this.value = value;
371         }
372
373         void setVarName(String varName) {
374                 this.varName = varName;
375         }
376
377         void setIsManual(String varName) {
378                 this.isManual = isManual;
379         }
380
381         Integer getAppNum() {
382                 return appNum;
383         }
384
385         String getValue() {
386                 return value;
387         }
388
389         String getVarName() {
390                 return varName;
391         }
392
393         boolean getIsManual() {
394                 return isManual;
395         }
396
397         @Override
398         public boolean equals(Object o) {
399       if (o instanceof NameValuePair) {
400         NameValuePair other = (NameValuePair) o;
401         if (varName.equals(other.getVarName()))
402           return appNum.equals(other.getAppNum());
403       }
404       return false;
405         }
406
407         @Override
408         public int hashCode() {
409                 return appNum.hashCode() * 31 + varName.hashCode();
410         }
411   }
412
413   @Override
414   public void stateRestored(Search search) {
415     id = search.getStateId();
416     depth = search.getDepth();
417     operation = "restored";
418     detail = null;
419
420     out.println("The state is restored to state with id: "+id+", depth: "+depth);
421   
422     // Update the parent node
423     if (nodes.containsKey(id)) {
424           parentNode = nodes.get(id);
425     } else {
426           parentNode = new Node(id);
427     }
428   }
429
430   @Override
431   public void searchStarted(Search search) {
432     out.println("----------------------------------- search started");
433   }
434  
435
436   @Override
437   public void stateAdvanced(Search search) {
438     String theEnd = null;
439     Transition transition = search.getTransition();
440     id = search.getStateId();
441     depth = search.getDepth();
442     operation = "forward";
443
444     // Add the node to the list of nodes
445     if (nodes.get(id) == null)
446         nodes.put(id, new Node(id));
447
448     Node currentNode = nodes.get(id);
449
450     // Update the edge based on the current transition
451     updateTheEdge(currentNode, transition);
452
453     // Reset the temporary variables and flags
454     tempSetSet = new ArrayList<NameValuePair>();
455     manual = false;
456
457     // Check for the conflict in this transition
458     conflictFound = checkForConflict(parentNode, currentNode, transition);
459
460     if (search.isNewState()) {
461       detail = "new";
462     } else {
463       detail = "visited";
464     }
465
466     if (search.isEndState()) {
467       out.println("This is the last state!");
468       theEnd = "end";
469     }
470
471     out.println("The state is forwarded to state with id: "+id+", depth: "+depth+" which is "+detail+" state: "+"% "+theEnd);
472     
473     // Updating the predecessors for this node
474     // Check if parent node is already in successors of the current node or not
475     if (!(currentNode.getPredecessors().contains(parentNode)))
476         currentNode.getPredecessors().add(parentNode);
477
478     // Update the successors for this node
479     // Check if current node is already in successors of the parent node or not
480     if (!(parentNode.getSuccessors().contains(currentNode)))
481         parentNode.getSuccessors().add(currentNode);
482
483     // Update the outset of the current node and check if it is changed or not to propagate the change
484     boolean isChanged = updateTheOutSet(parentNode, currentNode);
485     
486     // Check if the outSet of this state has changed, update all of its successors' sets if any
487     if (isChanged) {
488         for (Node node : currentNode.getSuccessors()) {
489                 HashMap<Transition, ArrayList<NameValuePair>> setSets = currentNode.getOutgoingEdges().get(node).getSetSetMap();
490                 for (Map.Entry mapElement : setSets.entrySet()) {
491                         Transition currentTransition = (Transition)mapElement.getKey();
492                         conflictFound = conflictFound || checkForConflict(currentNode, node, currentTransition);
493                 }
494         }
495         conflictFound = conflictFound || propagateTheChange(currentNode);
496     }
497     // Update the parent node
498     if (nodes.containsKey(id)) {
499           parentNode = nodes.get(id);
500     } else {
501           parentNode = new Node(id);
502     }
503   }
504
505   @Override
506   public void stateBacktracked(Search search) {
507     id = search.getStateId();
508     depth = search.getDepth();
509     operation = "backtrack";
510     detail = null;
511
512     out.println("The state is backtracked to state with id: "+id+", depth: "+depth);
513
514     // Update the parent node
515     if (nodes.containsKey(id)) {
516           parentNode = nodes.get(id);
517     } else {
518           parentNode = new Node(id);
519     }
520   }
521
522   @Override
523   public void searchFinished(Search search) {
524     out.println("----------------------------------- search finished");
525   }
526
527   private String getValue(ThreadInfo ti, Instruction inst, byte type) {
528     StackFrame frame;
529     int lo, hi;
530
531     frame = ti.getTopFrame();
532
533     if ((inst instanceof JVMLocalVariableInstruction) ||
534         (inst instanceof JVMFieldInstruction))
535     {
536       if (frame.getTopPos() < 0)
537         return(null);
538
539       lo = frame.peek();
540       hi = frame.getTopPos() >= 1 ? frame.peek(1) : 0;
541
542       return(decodeValue(type, lo, hi));
543     }
544
545     if (inst instanceof JVMArrayElementInstruction)
546       return(getArrayValue(ti, type));
547
548     return(null);
549   }
550
551   private final static String decodeValue(byte type, int lo, int hi) {
552     switch (type) {
553       case Types.T_ARRAY:   return(null);
554       case Types.T_VOID:    return(null);
555
556       case Types.T_BOOLEAN: return(String.valueOf(Types.intToBoolean(lo)));
557       case Types.T_BYTE:    return(String.valueOf(lo));
558       case Types.T_CHAR:    return(String.valueOf((char) lo));
559       case Types.T_DOUBLE:  return(String.valueOf(Types.intsToDouble(lo, hi)));
560       case Types.T_FLOAT:   return(String.valueOf(Types.intToFloat(lo)));
561       case Types.T_INT:     return(String.valueOf(lo));
562       case Types.T_LONG:    return(String.valueOf(Types.intsToLong(lo, hi)));
563       case Types.T_SHORT:   return(String.valueOf(lo));
564
565       case Types.T_REFERENCE:
566         ElementInfo ei = VM.getVM().getHeap().get(lo);
567         if (ei == null)
568           return(null);
569
570         ClassInfo ci = ei.getClassInfo();
571         if (ci == null)
572           return(null);
573
574         if (ci.getName().equals("java.lang.String"))
575           return('"' + ei.asString() + '"');
576
577         return(ei.toString());
578
579       default:
580         System.err.println("Unknown type: " + type);
581         return(null);
582      }
583   }
584
585   private String getArrayValue(ThreadInfo ti, byte type) {
586     StackFrame frame;
587     int lo, hi;
588
589     frame = ti.getTopFrame();
590     lo    = frame.peek();
591     hi    = frame.getTopPos() >= 1 ? frame.peek(1) : 0;
592
593     return(decodeValue(type, lo, hi));
594   }
595
596   private byte getType(ThreadInfo ti, Instruction inst) {
597     StackFrame frame;
598     FieldInfo fi;
599     String type;
600
601     frame = ti.getTopFrame();
602     if ((frame.getTopPos() >= 0) && (frame.isOperandRef())) {
603       return (Types.T_REFERENCE);
604     }
605
606     type = null;
607
608     if (inst instanceof JVMLocalVariableInstruction) {
609       type = ((JVMLocalVariableInstruction) inst).getLocalVariableType();
610     } else if (inst instanceof JVMFieldInstruction){
611       fi = ((JVMFieldInstruction) inst).getFieldInfo();
612       type = fi.getType();
613     }
614
615     if (inst instanceof JVMArrayElementInstruction) {
616       return (getTypeFromInstruction(inst));
617     }
618
619     if (type == null) {
620       return (Types.T_VOID);
621     }
622
623     return (decodeType(type));
624   }
625
626   private final static byte getTypeFromInstruction(Instruction inst) {
627     if (inst instanceof JVMArrayElementInstruction)
628       return(getTypeFromInstruction((JVMArrayElementInstruction) inst));
629
630     return(Types.T_VOID);
631   }
632
633   private final static byte decodeType(String type) {
634     if (type.charAt(0) == '?'){
635       return(Types.T_REFERENCE);
636     } else {
637       return Types.getBuiltinType(type);
638     }
639   }
640
641   // Find the variable writer
642   // It should be one of the apps listed in the .jpf file
643   private String getWriter(List<StackFrame> sfList, HashSet<String> writerSet) {
644     // Start looking from the top of the stack backward
645     for(int i=sfList.size()-1; i>=0; i--) {
646       MethodInfo mi = sfList.get(i).getMethodInfo();
647       if(!mi.isJPFInternal()) {
648         String method = mi.getStackTraceName();
649         // Check against the writers in the writerSet
650         for(String writer : writerSet) {
651           if (method.contains(writer)) {
652             return writer;
653           }
654         }
655       }
656     }
657
658     return null;
659   }
660
661   private void writeWriterAndValue(String writer, String value, String var) {
662     // Update the temporary Set set.
663     NameValuePair temp = new NameValuePair(1, value, var, manual);
664     if (writer.equals("App2"))
665         temp = new NameValuePair(2, value, var, manual);
666     
667     tempSetSet.add(temp);
668   }
669
670   @Override
671   public void instructionExecuted(VM vm, ThreadInfo ti, Instruction nextInsn, Instruction executedInsn) {
672     if (timeout > 0) {
673       if (System.currentTimeMillis() - startTime > timeout) {
674         StringBuilder sbTimeOut = new StringBuilder();
675         sbTimeOut.append("Execution timeout: " + (timeout / (60 * 1000)) + " minutes have passed!");
676         Instruction nextIns = ti.createAndThrowException("java.lang.RuntimeException", sbTimeOut.toString());
677         ti.setNextPC(nextIns);
678       }
679     }
680
681     if (conflictFound) {
682       StringBuilder sb = new StringBuilder();
683       sb.append(errorMessage);
684       Instruction nextIns = ti.createAndThrowException("java.lang.RuntimeException", sb.toString());
685       ti.setNextPC(nextIns);
686     } else {
687       if (conflictSet.contains(LOCATION_VAR)) {
688         MethodInfo mi = executedInsn.getMethodInfo();
689         // Find the last load before return and get the value here
690         if (mi.getName().equals(SET_LOCATION_METHOD) &&
691                 executedInsn instanceof ALOAD && nextInsn instanceof ARETURN) {
692           byte type  = getType(ti, executedInsn);
693           String value = getValue(ti, executedInsn, type);
694
695           // Extract the writer app name
696           ClassInfo ci = mi.getClassInfo();
697           String writer = ci.getName();
698
699           // Update the temporary Set set.
700           writeWriterAndValue(writer, value, LOCATION_VAR);
701         }
702       } else {
703         if (executedInsn instanceof WriteInstruction) {
704           String varId = ((WriteInstruction) executedInsn).getFieldInfo().getFullName();
705
706           for (String var : conflictSet) {
707             if (varId.contains(var)) {
708               // Get variable info
709               byte type = getType(ti, executedInsn);
710               String value = getValue(ti, executedInsn, type);
711               String writer = getWriter(ti.getStack(), appSet);
712               // Just return if the writer is not one of the listed apps in the .jpf file
713               if (writer == null)
714                 return;
715
716               if (getWriter(ti.getStack(), manualSet) != null)
717                 manual = true;
718
719               // Update the temporary Set set.
720               writeWriterAndValue(writer, value, var);
721             }
722           }
723         }
724       }
725     }
726   }
727 }