Fixed replaying to work with the new logging facilities

Jonathan Bell [2012-08-10 02:56:01]
Fixed replaying to work with the new logging facilities
Filename
testcase-generation-tester/.classpath
testcase-generation-tester/.settings/org.eclipse.jdt.core.prefs
testcase-generation-tester/src/edu/columbia/cs/psl/invivo/example/ReaderUser.java
testcase-generation/.classpath
testcase-generation/.settings/org.eclipse.jdt.core.prefs
testcase-generation/src/edu/columbia/cs/psl/invivo/record/Instrumenter.java
testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/CloningAdviceAdapter.java
testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingClassVisitor.java
testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingMethodVisitor.java
testcase-generation/src/edu/columbia/cs/psl/invivo/record/xstream/StaticReflectionProvider.java
testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayClassVisitor.java
testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayMethodVisitor.java
diff --git a/testcase-generation-tester/.classpath b/testcase-generation-tester/.classpath
index 313c1ce..8b2a61d 100644
--- a/testcase-generation-tester/.classpath
+++ b/testcase-generation-tester/.classpath
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="lib/asm-all-4.0.jar" sourcepath="lib/asm-src.zip"/>
 	<classpathentry kind="lib" path="lib/cloning-1.7.9.jar"/>
 	<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
diff --git a/testcase-generation-tester/.settings/org.eclipse.jdt.core.prefs b/testcase-generation-tester/.settings/org.eclipse.jdt.core.prefs
index 8000cd6..f236995 100644
--- a/testcase-generation-tester/.settings/org.eclipse.jdt.core.prefs
+++ b/testcase-generation-tester/.settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,12 @@
+#Thu Aug 09 21:40:37 EDT 2012
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.compliance=1.7
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/testcase-generation-tester/src/edu/columbia/cs/psl/invivo/example/ReaderUser.java b/testcase-generation-tester/src/edu/columbia/cs/psl/invivo/example/ReaderUser.java
index 5e4ffdb..41fb143 100644
--- a/testcase-generation-tester/src/edu/columbia/cs/psl/invivo/example/ReaderUser.java
+++ b/testcase-generation-tester/src/edu/columbia/cs/psl/invivo/example/ReaderUser.java
@@ -35,7 +35,7 @@ public class ReaderUser extends InputStreamReader {
 			int d = 0;
 			int[] x = new int[4];
 			File f=  new File("in-vivo.log");
-			f.exists();
+//			f.exists();
 			f.getAbsoluteFile();
 			BufferedReader r = new BufferedReader(new FileReader("in-vivo.log"));
 			char[] buf = new char[5000];
diff --git a/testcase-generation/.classpath b/testcase-generation/.classpath
index 0a28405..21dea0f 100644
--- a/testcase-generation/.classpath
+++ b/testcase-generation/.classpath
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="lib/asm-all-4.0.jar" sourcepath="lib/asm-src.zip"/>
 	<classpathentry kind="lib" path="lib/cloning-1.7.9.jar"/>
 	<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
diff --git a/testcase-generation/.settings/org.eclipse.jdt.core.prefs b/testcase-generation/.settings/org.eclipse.jdt.core.prefs
index 8000cd6..123798b 100644
--- a/testcase-generation/.settings/org.eclipse.jdt.core.prefs
+++ b/testcase-generation/.settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,12 @@
+#Thu Aug 09 21:42:23 EDT 2012
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.compliance=1.7
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/Instrumenter.java b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/Instrumenter.java
index d827bfa..f317a3e 100644
--- a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/Instrumenter.java
+++ b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/Instrumenter.java
@@ -95,7 +95,7 @@ public class Instrumenter {
 			byte[] out = cw.toByteArray();
 			try{
 			 ClassReader cr2 = new ClassReader(out);
-			 cr2.accept(new CheckClassAdapter(new ClassWriter(0)), 0);
+			 cr2.accept(new CheckClassAdapter(new ClassWriter(0)), ClassReader.EXPAND_FRAMES);
 			}
 			catch(Exception ex)
 			{
diff --git a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/CloningAdviceAdapter.java b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/CloningAdviceAdapter.java
index a07d50d..b255389 100644
--- a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/CloningAdviceAdapter.java
+++ b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/CloningAdviceAdapter.java
@@ -190,7 +190,7 @@ public class CloningAdviceAdapter extends GeneratorAdapter implements Opcodes {
 		// In this case, it's necessary to grow it
 		// Create the new array and initialize its size

-		int newArray = lvsorter.newLocal(Type.getType(logFieldTypeDesc));
+		int newArray = newLocal(Type.getType(logFieldTypeDesc));
 		visitFieldInsn(getOpcode, logFieldOwner, logFieldName, logFieldTypeDesc);
 		arrayLength();
 		visitInsn(Opcodes.I2D);
@@ -219,7 +219,7 @@ public class CloningAdviceAdapter extends GeneratorAdapter implements Opcodes {
 		loadLocal(newArray);
 		visitFieldInsn(putOpcode, logFieldOwner, logFieldName, logFieldTypeDesc);

-		int newArray2 = lvsorter.newLocal(Type.getType("[Ljava/lang/String;"));
+		int newArray2 = newLocal(Type.getType("[Ljava/lang/String;"));
 		visitFieldInsn(getOpcode, logFieldOwner, logFieldName+"_owners", "[Ljava/lang/String;");
 		arrayLength();
 		visitInsn(Opcodes.I2D);
@@ -343,16 +343,16 @@ public class CloningAdviceAdapter extends GeneratorAdapter implements Opcodes {
 			super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(WallaceExportRunner.class), "_export", "()V");
 		// super.visitVarInsn(ALOAD, monitorIndx);
 		// super.monitorEnter();
-		super.visitFieldInsn(getOpcode, logFieldOwner, "logsize", Type.INT_TYPE.getDescriptor());
-		super.visitLdcInsn(Constants.VERY_MAX_LOG_SIZE);
-		super.visitJumpInsn(IF_ICMPLE, endLbl);
+//		super.visitFieldInsn(getOpcode, logFieldOwner, "logsize", Type.INT_TYPE.getDescriptor());
+//		super.visitLdcInsn(Constants.VERY_MAX_LOG_SIZE);
+//		super.visitJumpInsn(IF_ICMPLE, endLbl);

 		// println("GOing to wait for " + logFieldOwner);
 		// super.visitLabel(tryStart);

-		super.visitFieldInsn(Opcodes.GETSTATIC, Type.getInternalName(Log.class), "lock", "Ljava/lang/Object;");
-		super.visitLdcInsn(500L);
-		super.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "wait", "(J)V");
+//		super.visitFieldInsn(Opcodes.GETSTATIC, Type.getInternalName(Log.class), "lock", "Ljava/lang/Object;");
+//		super.visitLdcInsn(500L);
+//		super.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "wait", "(J)V");

 		// super.visitLabel(tryEnd);

diff --git a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingClassVisitor.java b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingClassVisitor.java
index 4f82504..bec7c4e 100644
--- a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingClassVisitor.java
+++ b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingClassVisitor.java
@@ -51,12 +51,14 @@ public class NonDeterministicLoggingClassVisitor extends ClassVisitor implements
 				)
 		{
 			MethodVisitor smv = cv.visitMethod(acc, name, desc, signature, exceptions);
-			AnalyzerAdapter analyzer = new AnalyzerAdapter(className, acc, name, desc, smv);
-			JSRInlinerAdapter mv = new JSRInlinerAdapter(analyzer, acc, name, desc, signature, exceptions);
-			LocalVariablesSorter sorter  = new LocalVariablesSorter(acc, desc, mv);
+			JSRInlinerAdapter mv = new JSRInlinerAdapter(smv, acc, name, desc, signature, exceptions);
+
+			AnalyzerAdapter analyzer = new AnalyzerAdapter(className, acc, name, desc, mv);
+//			LocalVariablesSorter sorter  = new LocalVariablesSorter(acc, desc, analyzer);
+
 			// CheckMethodAdapter cmv = new CheckMethodAdapter(mv);

-			NonDeterministicLoggingMethodVisitor cloningMV = new NonDeterministicLoggingMethodVisitor(Opcodes.ASM4, sorter, acc, name, desc, className, isFirstConstructor, analyzer, sorter);
+			NonDeterministicLoggingMethodVisitor cloningMV = new NonDeterministicLoggingMethodVisitor(Opcodes.ASM4, analyzer, acc, name, desc, className, isFirstConstructor, analyzer, null);
 			if (name.equals("<init>"))
 				isFirstConstructor = false;
 			cloningMV.setClassVisitor(this);
diff --git a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingMethodVisitor.java b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingMethodVisitor.java
index 94b4e4c..5a324f2 100644
--- a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingMethodVisitor.java
+++ b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/visitor/NonDeterministicLoggingMethodVisitor.java
@@ -27,7 +27,7 @@ public class NonDeterministicLoggingMethodVisitor extends CloningAdviceAdapter i
 	private String					desc;
 	private String					classDesc;
 	private int						pc;
-	private static HashSet<String>	nonDeterministicMethods	= new HashSet<String>();
+	public static HashSet<String>	nonDeterministicMethods	= new HashSet<String>();
 	private boolean					isStatic;
 	private boolean					constructor;
 	private boolean					superInitialized;
@@ -101,6 +101,7 @@ public class NonDeterministicLoggingMethodVisitor extends CloningAdviceAdapter i
 	@Override
 	public void visitMethodInsn(int opcode, String owner, String name, String desc) {
 		try {
+
 			MethodCall m = new MethodCall(this.name, this.desc, this.classDesc, pc, lineNumber, owner, name, desc, isStatic);
 			Type returnType = Type.getMethodType(desc).getReturnType();
 			if ((!constructor || isFirstConstructor || superInitialized) && !returnType.equals(Type.VOID_TYPE)
diff --git a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/xstream/StaticReflectionProvider.java b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/xstream/StaticReflectionProvider.java
index 7e6088a..3852bb0 100644
--- a/testcase-generation/src/edu/columbia/cs/psl/invivo/record/xstream/StaticReflectionProvider.java
+++ b/testcase-generation/src/edu/columbia/cs/psl/invivo/record/xstream/StaticReflectionProvider.java
@@ -62,6 +62,6 @@ public class StaticReflectionProvider extends Sun14ReflectionProvider {
 	@Override
 	protected boolean fieldModifiersSupported(Field field) {
 		int modifiers = field.getModifiers();
-		return !(Modifier.isTransient(modifiers));
+		return !(Modifier.isTransient(modifiers) || (Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers) ));
 	}
 }
diff --git a/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayClassVisitor.java b/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayClassVisitor.java
index c92d038..085e31d 100644
--- a/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayClassVisitor.java
+++ b/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayClassVisitor.java
@@ -9,9 +9,11 @@ import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
+import org.objectweb.asm.commons.AnalyzerAdapter;
 import org.objectweb.asm.commons.JSRInlinerAdapter;
 import org.objectweb.asm.tree.FieldNode;
 import org.objectweb.asm.tree.MethodInsnNode;
+import org.objectweb.asm.util.CheckMethodAdapter;

 import edu.columbia.cs.psl.invivo.record.Constants;
 import edu.columbia.cs.psl.invivo.record.MethodCall;
@@ -41,13 +43,15 @@ public class NonDeterministicReplayClassVisitor extends ClassVisitor implements
 	public MethodVisitor visitMethod(int acc, String name, String desc,
 			String signature, String[] exceptions) {
 		//TODO need an annotation to disable doing this to some apps
-		if(isAClass && !name.equals(Constants.INNER_COPY_METHOD_NAME) && !name.equals(Constants.OUTER_COPY_METHOD_NAME) && !name.equals(Constants.SET_FIELDS_METHOD_NAME))// && className.startsWith("edu"))
+		if(isAClass)// && className.startsWith("edu"))
 		{
-			MethodVisitor smv = cv.visitMethod(acc, name, desc, signature,
-					exceptions);
-			JSRInlinerAdapter  mv = new JSRInlinerAdapter(smv, acc, name, desc, signature, exceptions);
+
+			MethodVisitor smv = cv.visitMethod(acc, name, desc, signature, exceptions);
+			JSRInlinerAdapter mv = new JSRInlinerAdapter(smv, acc, name, desc, signature, exceptions);

-			NonDeterministicReplayMethodVisitor cloningMV = new NonDeterministicReplayMethodVisitor(Opcodes.ASM4, mv, acc, name, desc,className,isFirstConstructor);
+			AnalyzerAdapter analyzer = new AnalyzerAdapter(className, acc, name, desc, mv);
+			CheckMethodAdapter cm = new CheckMethodAdapter(analyzer);
+			NonDeterministicReplayMethodVisitor cloningMV = new NonDeterministicReplayMethodVisitor(Opcodes.ASM4, cm, acc, name, desc,className,isFirstConstructor, analyzer);
 			if(name.equals("<init>"))
 				isFirstConstructor = false;
 			cloningMV.setClassVisitor(this);
diff --git a/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayMethodVisitor.java b/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayMethodVisitor.java
index 11401fb..7d79d75 100644
--- a/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayMethodVisitor.java
+++ b/testcase-generation/src/edu/columbia/cs/psl/invivo/replay/NonDeterministicReplayMethodVisitor.java
@@ -15,6 +15,7 @@ import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
+import org.objectweb.asm.commons.AnalyzerAdapter;
 import org.objectweb.asm.tree.MethodInsnNode;

 import edu.columbia.cs.psl.invivo.record.CloningUtils;
@@ -24,6 +25,7 @@ import edu.columbia.cs.psl.invivo.record.Instrumenter;
 import edu.columbia.cs.psl.invivo.record.Log;
 import edu.columbia.cs.psl.invivo.record.MethodCall;
 import edu.columbia.cs.psl.invivo.record.visitor.CloningAdviceAdapter;
+import edu.columbia.cs.psl.invivo.record.visitor.NonDeterministicLoggingMethodVisitor;

 public class NonDeterministicReplayMethodVisitor extends CloningAdviceAdapter implements Constants {
 	private static Logger			logger					= Logger.getLogger(NonDeterministicReplayMethodVisitor.class);
@@ -31,23 +33,11 @@ public class NonDeterministicReplayMethodVisitor extends CloningAdviceAdapter im
 	private String					desc;
 	private String					classDesc;
 	private int						pc;
-	private static HashSet<String>	nonDeterministicMethods	= new HashSet<String>();
 	private boolean					isStatic;
 	private boolean					constructor;
 	private boolean					superInitialized;

-	static {
-		File f = new File("nondeterministic-methods.txt");
-		Scanner s;
-		try {
-			s = new Scanner(f);
-			while (s.hasNextLine())
-				nonDeterministicMethods.add(s.nextLine());
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		}
-	}
-
+
 	@Override
 	public void visitCode() {
 		super.visitCode();
@@ -56,16 +46,18 @@ public class NonDeterministicReplayMethodVisitor extends CloningAdviceAdapter im
 	}

 	private boolean	isFirstConstructor;
+	AnalyzerAdapter	analyzer;

 	protected NonDeterministicReplayMethodVisitor(int api, MethodVisitor mv, int access, String name, String desc, String classDesc,
-			boolean isFirstConstructor) {
-		super(api, mv, access, name, desc,classDesc, null);
+			boolean isFirstConstructor, AnalyzerAdapter analyzer) {
+		super(api, mv, access, name, desc, classDesc, null);
 		this.name = name;
 		this.desc = desc;
 		this.classDesc = classDesc;
 		this.isStatic = (access & Opcodes.ACC_STATIC) != 0;
 		this.constructor = "<init>".equals(name);
 		this.isFirstConstructor = isFirstConstructor;
+		this.analyzer = analyzer;
 	}

 	private NonDeterministicReplayClassVisitor	parent;
@@ -74,8 +66,6 @@ public class NonDeterministicReplayMethodVisitor extends CloningAdviceAdapter im
 		this.parent = coaClassVisitor;
 	}

-
-
 	@Override
 	public void visitEnd() {
 		super.visitEnd();
@@ -90,184 +80,193 @@ public class NonDeterministicReplayMethodVisitor extends CloningAdviceAdapter im
 		super.visitLineNumber(line, start);
 		lineNumber = line;
 	}
-	private void loadReplayIndex(String className, String fieldName)
-	{
-		/*
-		  GETSTATIC edu/columbia/cs/psl/invivo/record/ExportedLog.aLog_replayIndex : Ljava/util/HashMap;
-		    INVOKESTATIC java/lang/Thread.currentThread()Ljava/lang/Thread;
-		    INVOKEVIRTUAL java/lang/Thread.getName()Ljava/lang/String;
-		    INVOKEVIRTUAL java/util/HashMap.containsKey(Ljava/lang/Object;)Z
-		    IFNE L1
-		   L2
-		    LINENUMBER 45 L2
-		    GETSTATIC edu/columbia/cs/psl/invivo/record/ExportedLog.aLog_replayIndex : Ljava/util/HashMap;
-		    INVOKESTATIC java/lang/Thread.currentThread()Ljava/lang/Thread;
-		    INVOKEVIRTUAL java/lang/Thread.getName()Ljava/lang/String;
-		    ICONST_0
-		    INVOKESTATIC java/lang/Integer.valueOf(I)Ljava/lang/Integer;
-		    INVOKEVIRTUAL java/util/HashMap.put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
-		    POP
-		   L1
-		    LINENUMBER 46 L1
-		   FRAME SAME
-		    GETSTATIC edu/columbia/cs/psl/invivo/record/ExportedLog.aLog_replayIndex : Ljava/util/HashMap;
-		    INVOKESTATIC java/lang/Thread.currentThread()Ljava/lang/Thread;
-		    INVOKEVIRTUAL java/lang/Thread.getName()Ljava/lang/String;
-		    INVOKEVIRTUAL java/util/HashMap.get(Ljava/lang/Object;)Ljava/lang/Object;
-		    CHECKCAST java/lang/Integer
-		    INVOKEVIRTUAL java/lang/Integer.intValue()I
-		 */
-		super.visitFieldInsn(GETSTATIC, Type.getInternalName(ExportedLog.class), fieldName+"_replayIndex", "Ljava/util/HashMap;");
+
+	private void loadReplayIndex(String className, String fieldName) {
+		super.visitFieldInsn(GETSTATIC, className, fieldName + "_replayIndex", "Ljava/util/HashMap;");
 		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Thread.class), "currentThread", "()Ljava/lang/Thread;");
-		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Thread.class), "getName", "()Ljava/lang/String;");
+		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(Thread.class), "getName", "()Ljava/lang/String;");
 		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(HashMap.class), "containsKey", "(Ljava/lang/Object;)Z");
 		Label exists = new Label();
-		super.visitFieldInsn(GETSTATIC, Type.getInternalName(ExportedLog.class), fieldName+"_replayIndex", "Ljava/util/HashMap;");
+		super.visitJumpInsn(Opcodes.IFNE, exists);
+		super.visitFieldInsn(GETSTATIC, className, fieldName + "_replayIndex", "Ljava/util/HashMap;");
 		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Thread.class), "currentThread", "()Ljava/lang/Thread;");
-		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Thread.class), "getName", "()Ljava/lang/String;");
+		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(Thread.class), "getName", "()Ljava/lang/String;");
 		super.visitInsn(ICONST_0);
-		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Integer.class), "valueOf", "(I)java/lang/Integer;");
+		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Integer.class), "valueOf", "(I)Ljava/lang/Integer;");
 		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(HashMap.class), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
-
-		super.visitJumpInsn(Opcodes.IFNE, exists);
+		super.visitInsn(POP);
+		super.visitLabel(exists);
+		super.visitFieldInsn(GETSTATIC, className, fieldName + "_replayIndex", "Ljava/util/HashMap;");
+		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Thread.class), "currentThread", "()Ljava/lang/Thread;");
+		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(Thread.class), "getName", "()Ljava/lang/String;");
+		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(HashMap.class), "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
+		super.visitTypeInsn(CHECKCAST, "java/lang/Integer");
+		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(Integer.class), "intValue", "()I");
+//				super.visitInsn(ICONST_0);
+	}
+
+	private void incrementReplayIndex(String className, String fieldName) {
+		super.visitFieldInsn(GETSTATIC, className, fieldName + "_replayIndex", "Ljava/util/HashMap;");
+		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Thread.class), "currentThread", "()Ljava/lang/Thread;");
+		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(Thread.class), "getName", "()Ljava/lang/String;");
+		loadReplayIndex(className, fieldName);
+		super.visitInsn(ICONST_1);
+		super.visitInsn(IADD);
+		super.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Integer.class), "valueOf", "(I)Ljava/lang/Integer;");
+		super.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(HashMap.class), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
+		super.visitInsn(POP);
 	}
-	private HashMap<String, MethodInsnNode> captureMethodsToGenerate = new HashMap<String, MethodInsnNode>();
+
+	private HashMap<String, MethodInsnNode>	captureMethodsToGenerate	= new HashMap<String, MethodInsnNode>();
+
 	@Override
 	public void visitMethodInsn(int opcode, String owner, String name, String desc) {
+
 		try {
 			MethodCall m = new MethodCall(this.name, this.desc, this.classDesc, pc, lineNumber, owner, name, desc, isStatic);
 			Type returnType = Type.getMethodType(desc).getReturnType();
-			if ((!constructor || isFirstConstructor || superInitialized) && returnType.equals(Type.VOID_TYPE)
-					&& nonDeterministicMethods.contains(owner + "." + name + ":" + desc)) {
+
+			if (opcode == INVOKESPECIAL && name.equals("<init>") && NonDeterministicLoggingMethodVisitor.nonDeterministicMethods.contains(owner + "." + name + ":" + desc)) {
+				System.out.println(this.classDesc +"."+this.name);
+				System.out.println(Replayer.instrumentedClasses.get(classDesc).superName);
+				System.out.println(owner);
+				System.out.println(analyzer.stack);
+				if (!(owner.equals(Replayer.instrumentedClasses.get(classDesc).superName) && this.name.equals("<init>"))) {
+					Type[] args = Type.getArgumentTypes(desc);
+					for (int i = args.length - 1; i >= 0; i--) {
+						Type t = args[i];
+						if (t.getSize() == 2)
+							mv.visitInsn(POP2);
+						else
+							mv.visitInsn(POP);
+					}
+
+					if (analyzer.stack != null && analyzer.stack.size() > 0
+							&& analyzer.uninitializedTypes.containsKey(analyzer.stack.get(analyzer.stack.size() - 1))
+							&& analyzer.uninitializedTypes.get(analyzer.stack.get(analyzer.stack.size() - 1)).equals(owner)) {
+						mv.visitInsn(POP);
+						if (analyzer.stack.size() > 0 && analyzer.uninitializedTypes.containsKey(analyzer.stack.get(analyzer.stack.size() - 1))
+								&& analyzer.uninitializedTypes.get(analyzer.stack.get(analyzer.stack.size() - 1)).equals(owner))
+							mv.visitInsn(POP);
+
+						String replayClassName = MethodCall.getReplayClassName(Type.getType("L"+m.getMethodOwner()+";"));
+						mv.visitFieldInsn(GETSTATIC, replayClassName, m.getLogFieldName(), "[Ljava/lang/Object;");
+
+						Label fallThrough = new Label();
+						loadReplayIndex(replayClassName, m.getLogFieldName());
+						mv.visitInsn(DUP);
+
+						mv.visitFieldInsn(GETSTATIC, replayClassName, m.getLogFieldName() + "_fill", "I");
+						mv.visitJumpInsn(Opcodes.IF_ICMPNE, fallThrough);
+						mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(ReplayRunner.class), "loadNextLog", "()V");
+						mv.visitInsn(POP);
+						loadReplayIndex(replayClassName, m.getLogFieldName());
+
+						mv.visitLabel(fallThrough);
+						//				arrayLoad(Type.getType("L"+m.getMethodOwner()+";"));
+						mv.visitInsn(AALOAD);
+						mv.visitTypeInsn(CHECKCAST, m.getMethodOwner());
+						incrementReplayIndex(replayClassName, m.getLogFieldName());
+					}
+
+				} else {
+					super.visitMethodInsn(opcode, owner, name, desc);
+				}
+
+			} else if ((!constructor || isFirstConstructor || superInitialized) && returnType.equals(Type.VOID_TYPE) && !name.equals("<init>")
+					&& NonDeterministicLoggingMethodVisitor.nonDeterministicMethods.contains(owner + "." + name + ":" + desc)) {
 				Type[] args = Type.getArgumentTypes(desc);
-//				logger.warn(owner+"."+name+desc);
 				for (int i = args.length - 1; i >= 0; i--) {
 					Type t = args[i];
-					if(t.getSize() == 2)
+					if (t.getSize() == 2)
 						mv.visitInsn(POP2);
 					else
 						mv.visitInsn(POP);
 				}
-				if(opcode != INVOKESTATIC)
+				if (opcode != INVOKESTATIC)
 					mv.visitInsn(POP);

-				if(opcode == INVOKESPECIAL && name.equals("<init>") && !Replayer.instrumentedClasses.get(classDesc).superName.equals(owner)
-						)
-				{
-					mv.visitInsn(POP);
-					mv.visitInsn(ACONST_NULL);
-				}
-			}
-			else if ((!constructor || isFirstConstructor || superInitialized) && !returnType.equals(Type.VOID_TYPE)
-					&& nonDeterministicMethods.contains(owner + "." + name + ":" + desc)) {
-
+				//				else
+				//					super.visitMethodInsn(opcode, owner, name, desc);
+
+			} else if ((!constructor || isFirstConstructor || superInitialized) && !returnType.equals(Type.VOID_TYPE)
+					&& NonDeterministicLoggingMethodVisitor.nonDeterministicMethods.contains(owner + "." + name + ":" + desc)) {
+
 				Label startOfPlayBack = new Label();

-
 				super.visitFieldInsn(GETSTATIC, Type.getInternalName(Log.class), "logLock", Type.getDescriptor(Lock.class));
 				super.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Lock.class), "lock", "()V");
-
+
 				logger.debug("Adding field in MV to list " + m.getLogFieldName());
 				methodCallsToClear.add(m);
 				Type[] args = Type.getArgumentTypes(desc);
 				boolean hasArray = false;
-				for(Type t : args)
-					if(t.getSort() == Type.ARRAY)
+				for (Type t : args)
+					if (t.getSort() == Type.ARRAY)
 						hasArray = true;
-
-				if(hasArray) {
-
+
+				if (hasArray) {
+
 					Type[] targs = Type.getArgumentTypes(desc);
 					for (int i = targs.length - 1; i >= 0; i--) {
 						Type t = targs[i];
 						if (t.getSort() == Type.ARRAY) {
 							/*
-							 * stack (grows down):
-							 * dest (fill not incremented yet)
+							 * stack (grows down): dest (fill not incremented yet)
 							 */
 							String replayClassName = MethodCall.getReplayClassName(t);
-							mv.visitFieldInsn(GETSTATIC, replayClassName,
-									MethodCall.getLogFieldName(t),
-									MethodCall.getLogFieldType(t).getDescriptor());
-							mv.visitFieldInsn(GETSTATIC,replayClassName,
-									MethodCall.getLogFieldName(t)+"_replayIndex",
-									"I");
+							String replayFieldName = MethodCall.getLogFieldName(t);
+							mv.visitFieldInsn(GETSTATIC, replayClassName, MethodCall.getLogFieldName(t), MethodCall.getLogFieldType(t)
+									.getDescriptor());
+							//							mv.visitFieldInsn(GETSTATIC,replayClassName,
+							//									MethodCall.getLogFieldName(t)+"_replayIndex",
+							//									"I");
+							loadReplayIndex(replayClassName, replayFieldName);
 							mv.visitInsn(DUP);
-							mv.visitFieldInsn(GETSTATIC, replayClassName, MethodCall.getLogFieldName(t)+"_fill", "I");
+							mv.visitFieldInsn(GETSTATIC, replayClassName, MethodCall.getLogFieldName(t) + "_fill", "I");
 							Label fallThrough = new Label();
-
-
+
 							mv.visitJumpInsn(Opcodes.IF_ICMPNE, fallThrough);
 							mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(ReplayRunner.class), "loadNextLog", "()V");
 							pop();
-							mv.visitFieldInsn(GETSTATIC, replayClassName,
-									MethodCall.getLogFieldName(t) +"_replayIndex",
-									"I");
+							loadReplayIndex(replayClassName, replayFieldName);
 							visitLabel(fallThrough);
-
+
 							arrayLoad(t);

 							/*
-							 * stack (grows down):
-							 * dest
-							 * src
+							 * stack (grows down): dest src
 							 */
 							swap();
 							/*
-							 * stack (grows down):
-							 * src
-							 * dest
+							 * stack (grows down): src dest
 							 */
 							push(0);
 							/*
-							 * stack (grows down):
-							 * src
-							 * dest
-							 * 0
+							 * stack (grows down): src dest 0
 							 */
 							swap();
 							/*
-							 * stack (grows down):
-							 * src
-							 * 0
-							 * dest
+							 * stack (grows down): src 0 dest
 							 */
 							push(0);
 							/*
-							 * stack (grows down):
-							 * src
-							 * 0
-							 * dest
-							 * 0
+							 * stack (grows down): src 0 dest 0
 							 */

-							mv.visitFieldInsn(GETSTATIC, replayClassName,
-									MethodCall.getLogFieldName(t),
-									MethodCall.getLogFieldType(t).getDescriptor());
-							mv.visitFieldInsn(GETSTATIC, replayClassName,
-									MethodCall.getLogFieldName(t)+"_replayIndex",
-									"I");
-							mv.visitInsn(DUP);
-							mv.visitInsn(ICONST_1);
-							mv.visitInsn(IADD);
-							mv.visitFieldInsn(PUTSTATIC, replayClassName,
-									MethodCall.getLogFieldName(t) +"_replayIndex",
-									"I");
+							mv.visitFieldInsn(GETSTATIC, replayClassName, MethodCall.getLogFieldName(t), MethodCall.getLogFieldType(t)
+									.getDescriptor());
+							loadReplayIndex(replayClassName, replayFieldName);
 							arrayLoad(t);
 							mv.visitTypeInsn(Opcodes.CHECKCAST, t.getInternalName());
 							mv.visitInsn(ARRAYLENGTH);
+							incrementReplayIndex(replayClassName, replayFieldName);
 							/*
-							 * stack:
-							 * src (fill incremented)
-							 * 0
-							 * dest
-							 * 0
-							 * length
+							 * stack: src (fill incremented) 0 dest 0 length
 							 */
 							mv.visitMethodInsn(INVOKESTATIC, "java/lang/System", "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V");
 							/*
-							 * stack:
-							 * dest popped
+							 * stack: dest popped
 							 */
 						} else {
 							switch (t.getSize()) {
@@ -296,34 +295,27 @@ public class NonDeterministicReplayMethodVisitor extends CloningAdviceAdapter im
 						}
 					}
 				}
-
-				if(opcode != INVOKESTATIC)
+
+				if (opcode != INVOKESTATIC)
 					mv.visitInsn(POP);
-
-
+
 				if (returnType.getSort() == Type.VOID)
 					mv.visitInsn(NOP);
 				else {
-					mv.visitFieldInsn(GETSTATIC, m.getReplayClassName(),
-							m.getLogFieldName(),
-							m.getLogFieldType().getDescriptor());
-					mv.visitFieldInsn(GETSTATIC, m.getReplayClassName(), m.getLogFieldName()+"_replayIndex", "I");
+					mv.visitFieldInsn(GETSTATIC, m.getReplayClassName(), m.getLogFieldName(), m.getLogFieldType().getDescriptor());
+
+					loadReplayIndex(m.getReplayClassName(), m.getLogFieldName());
 					mv.visitInsn(DUP);
 					Label fallThrough = new Label();
-					mv.visitFieldInsn(GETSTATIC, m.getReplayClassName(), m.getLogFieldName()+"_fill", "I");
+					mv.visitFieldInsn(GETSTATIC, m.getReplayClassName(), m.getLogFieldName() + "_fill", "I");
 					mv.visitJumpInsn(Opcodes.IF_ICMPNE, fallThrough);
 					mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(ReplayRunner.class), "loadNextLog", "()V");
 					mv.visitInsn(POP);
-					mv.visitFieldInsn(GETSTATIC, m.getReplayClassName(),
-							m.getLogFieldName() +"_replayIndex",
-							"I");
+					loadReplayIndex(m.getReplayClassName(), m.getLogFieldName());

 					mv.visitLabel(fallThrough);
-					mv.visitInsn(DUP);
-					mv.visitInsn(ICONST_1);
-					mv.visitInsn(IADD);
-					mv.visitFieldInsn(PUTSTATIC, m.getReplayClassName(), m.getLogFieldName()+"_replayIndex", "I");
 					arrayLoad(m.getReturnType());
+					incrementReplayIndex(m.getReplayClassName(), m.getLogFieldName());
 				}
 				//Unlock
 				super.visitFieldInsn(GETSTATIC, Type.getInternalName(Log.class), "logLock", Type.getDescriptor(Lock.class));