+
+ @Override
+ public void instructionExecuted(VM vm, ThreadInfo ti, Instruction nextInsn, Instruction executedInsn) {
+ // CASE #1: Detecting variable write-after-write conflict
+ if (executedInsn instanceof WriteInstruction) {
+ // Check for write-after-write conflict
+ String varId = ((WriteInstruction) executedInsn).getFieldInfo().getFullName();
+ for(String var : conflictSet) {
+ if (varId.contains(var)) {
+ String writer = getWriter(ti.getStack());
+ // Just return if the writer is not one of the listed apps in the .jpf file
+ if (writer == null)
+ return;
+
+ // Stores event number that executes WriteInstruction
+ if (!writeEventNumberSet.contains(currentChoice)) {
+ writeEventNumberSet.add(currentChoice);
+ }
+ }
+ }
+ }
+ }
+
+ // Find the variable writer
+ // It should be one of the apps listed in the .jpf file
+ private String getWriter(List<StackFrame> sfList) {
+ // Start looking from the top of the stack backward
+ for(int i=sfList.size()-1; i>=0; i--) {
+ MethodInfo mi = sfList.get(i).getMethodInfo();
+ if(!mi.isJPFInternal()) {
+ String method = mi.getStackTraceName();
+ // Check against the apps in the appSet
+ for(String app : appSet) {
+ // There is only one writer at a time but we need to always
+ // check all the potential writers in the list
+ if (method.contains(app)) {
+ return app;
+ }
+ }
+ }
+ }
+
+ return null;
+ }