COA

Jonathan Bell [2012-04-09 13:57:11]
COA
Filename
Columbus2Tester/apt_generated/edu/columbia/cs/psl/metamorphic/example/ProcessorTester_tests.java
Columbus2Tester/lib/cloning-1.7.9.jar
Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/AnotherClass.java
Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/ProcessorTester.java
Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/SimpleOverrider.java
cloning/src/main/java/com/rits/cloning/Cloner.java
columbus2/.classpath
columbus2/lib/cloning-1.7.9.jar
columbus2/src/edu/columbia/cs/psl/metamorphic/runtime/Interceptor.java
diff --git a/Columbus2Tester/apt_generated/edu/columbia/cs/psl/metamorphic/example/ProcessorTester_tests.java b/Columbus2Tester/apt_generated/edu/columbia/cs/psl/metamorphic/example/ProcessorTester_tests.java
index cc25921..ab6b99e 100644
--- a/Columbus2Tester/apt_generated/edu/columbia/cs/psl/metamorphic/example/ProcessorTester_tests.java
+++ b/Columbus2Tester/apt_generated/edu/columbia/cs/psl/metamorphic/example/ProcessorTester_tests.java
@@ -1,15 +1,6 @@
 package edu.columbia.cs.psl.metamorphic.example;
 public class ProcessorTester_tests {
 @SuppressWarnings("all")
-public static  java.lang.String pickFirstString_0 ( java.lang.String[] in, ProcessorTester ___object, java.lang.reflect.Method ___method) throws Exception {
-return (java.lang.String) ___method.invoke(___object,new edu.columbia.cs.psl.metamorphic.inputProcessor.impl.Shuffle().apply((Object) in));
-
-}
-@SuppressWarnings("all")
-public static  boolean pickFirstString_Check0 (java.lang.String orig, java.lang.String metamorphic, java.lang.String[] in) {
-if(orig == null && metamorphic != null) return false; if(orig == null && metamorphic == null) return true;return metamorphic.equals(orig);
-
-}@SuppressWarnings("all")
 public static  int findClosestValue_0 ( int[] values,  Integer target, ProcessorTester ___object, java.lang.reflect.Method ___method) throws Exception {
 return (Integer) ___method.invoke(___object,new edu.columbia.cs.psl.metamorphic.inputProcessor.impl.MultiplyByNumericConstant().apply((Object) values, 10), target * 10);

@@ -27,5 +18,23 @@ return (Integer) ___method.invoke(___object,new edu.columbia.cs.psl.metamorphic.
 public static  boolean findClosestValue_Check1 (int orig, int metamorphic, int[] values,  Integer target) {
 return metamorphic == orig + 10;

+}@SuppressWarnings("all")
+public static  java.lang.String pickFirstString_0 ( java.lang.String[] in, ProcessorTester ___object, java.lang.reflect.Method ___method) throws Exception {
+return (java.lang.String) ___method.invoke(___object,new edu.columbia.cs.psl.metamorphic.inputProcessor.impl.Shuffle().apply((Object) in));
+
+}
+@SuppressWarnings("all")
+public static  boolean pickFirstString_Check0 (java.lang.String orig, java.lang.String metamorphic, java.lang.String[] in) {
+if(orig == null && metamorphic != null) return false; if(orig == null && metamorphic == null) return true;return metamorphic.equals(orig);
+
+}@SuppressWarnings("all")
+public static  java.lang.String pickFirstString_1 ( java.lang.String[] in, ProcessorTester ___object, java.lang.reflect.Method ___method) throws Exception {
+return (java.lang.String) ___method.invoke(___object,new edu.columbia.cs.psl.metamorphic.inputProcessor.impl.Shuffle().apply((Object) in));
+
+}
+@SuppressWarnings("all")
+public static  boolean pickFirstString_Check1 (java.lang.String orig, java.lang.String metamorphic, java.lang.String[] in) {
+if(orig == null && metamorphic != null) return false; if(orig == null && metamorphic == null) return true;return metamorphic.equals(orig);
+
 }
 }
\ No newline at end of file
diff --git a/Columbus2Tester/lib/cloning-1.7.9.jar b/Columbus2Tester/lib/cloning-1.7.9.jar
index 7a6ed95..dfcc2aa 100644
Binary files a/Columbus2Tester/lib/cloning-1.7.9.jar and b/Columbus2Tester/lib/cloning-1.7.9.jar differ
diff --git a/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/AnotherClass.java b/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/AnotherClass.java
new file mode 100644
index 0000000..d087804
--- /dev/null
+++ b/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/AnotherClass.java
@@ -0,0 +1,5 @@
+package edu.columbia.cs.psl.metamorphic.example;
+
+public class AnotherClass {
+	public String foo = "foo";
+}
diff --git a/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/ProcessorTester.java b/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/ProcessorTester.java
index c763246..2ddd230 100644
--- a/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/ProcessorTester.java
+++ b/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/ProcessorTester.java
@@ -8,10 +8,11 @@ import edu.columbia.cs.psl.metamorphic.runtime.annotation.Rule;
 public class ProcessorTester {
     public static void main(String[] args) {
         ProcessorTester tester = new ProcessorTester();
-        System.out.println(tester.findClosestValue(new int[] {1,2,3,1000, 10,1000,40000}, 3));
+//        System.out.println(tester.findClosestValue(new int[] {1,2,3,1000, 10,1000,40000}, 3));
+        tester.cl.foo = "foobar";
         System.out.println(tester.pickFirstString(new String[] {"a","b","c","b","c","b","c","b","c","b","c","b","c","b","c"}));
-        SimpleExample ex2 = new SimpleExample();
-        ex2.go(new String[] {"d"});
+//        SimpleExample ex2 = new SimpleExample();
+//        ex2.go(new String[] {"d"});
     }
     @Metamorphic(rules = {
     		@Rule(test ="findClosestValue(\\MultiplyByNumericConstant(values, 10), target * 10)", check = "\\result * 10"),
@@ -38,22 +39,22 @@ public class ProcessorTester {
 	// this will give an error if the array is empty, but whatever... =)
 	return values[closestIndex];
   }
-
+    private String foo = "foo";
+    private AnotherClass cl = new AnotherClass();
 //    private static String[] myStuff = new String[] {"d","e","f"};
 //    private static String[] myStuff_2 = new String[] {"d","e","f"};
     @Metamorphic(rules = {
+    		@Rule(test = "pickFirstString(\\Shuffle(in))", check="\\result"),
     		@Rule(test = "pickFirstString(\\Shuffle(in))", check="\\result")})
     private String pickFirstString(String[] in)
-	{
-    	try
-    	{
-    		int childThread = AbstractInterceptor.getThreadChildId();
-    		System.out.println("I'm in child " + childThread);
-    	}
-    	catch(IllegalStateException ex)
-    	{
-    		System.out.println("I'm in a parent");
-    	}
-		return in[0];
+	{
+    	int childThread = AbstractInterceptor.getThreadChildId();
+    	System.out.println("I'm in child " + childThread);
+    	System.out.println(childThread + " ()AnotherClass's foo:" + cl.foo);
+    	cl.foo = "asdf"+childThread;
+    	System.out.println(childThread + "AnotherClass's foo:" + cl.foo);
+    	for(int i = 0; i < 100;i++)
+    	System.out.println(childThread + "AnotherClass's foo:" + cl.foo);
+    	return in[0];
 	}
 }
diff --git a/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/SimpleOverrider.java b/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/SimpleOverrider.java
new file mode 100644
index 0000000..3ee16aa
--- /dev/null
+++ b/Columbus2Tester/src/edu/columbia/cs/psl/metamorphic/example/SimpleOverrider.java
@@ -0,0 +1,9 @@
+package edu.columbia.cs.psl.metamorphic.example;
+
+public class SimpleOverrider extends SimpleExample {
+	@Override
+	public int findClosestValue(int[] values, int target)
+	{
+		return -10;
+	}
+}
diff --git a/cloning/src/main/java/com/rits/cloning/Cloner.java b/cloning/src/main/java/com/rits/cloning/Cloner.java
index 9f34ccd..31bbd2b 100644
--- a/cloning/src/main/java/com/rits/cloning/Cloner.java
+++ b/cloning/src/main/java/com/rits/cloning/Cloner.java
@@ -442,7 +442,8 @@ public class Cloner
 		{
 			final int length = Array.getLength(o);
 			final T newInstance = (T) Array.newInstance(clz.getComponentType(), length);
-			clones.put(o, newInstance);
+			if(clones != null)
+				clones.put(o, newInstance);
 			for (int i = 0; i < length; i++)
 			{
 				final Object v = Array.get(o, i);
diff --git a/columbus2/.classpath b/columbus2/.classpath
index 4396363..438db04 100644
--- a/columbus2/.classpath
+++ b/columbus2/.classpath
@@ -4,7 +4,7 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
 	<classpathentry kind="lib" path="lib/asm-all-4.0.jar" sourcepath="lib/asm-src.zip"/>
 	<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
-	<classpathentry kind="lib" path="lib/cloning-1.7.9.jar"/>
+	<classpathentry kind="lib" path="lib/cloning-1.7.9.jar" sourcepath="/cloning"/>
 	<classpathentry kind="lib" path="lib/objenesis-1.2.jar"/>
 	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/invivo-runtime"/>
 	<classpathentry kind="output" path="bin"/>
diff --git a/columbus2/lib/cloning-1.7.9.jar b/columbus2/lib/cloning-1.7.9.jar
index 7a6ed95..dfcc2aa 100644
Binary files a/columbus2/lib/cloning-1.7.9.jar and b/columbus2/lib/cloning-1.7.9.jar differ
diff --git a/columbus2/src/edu/columbia/cs/psl/metamorphic/runtime/Interceptor.java b/columbus2/src/edu/columbia/cs/psl/metamorphic/runtime/Interceptor.java
index c67cc9b..49d7aac 100644
--- a/columbus2/src/edu/columbia/cs/psl/metamorphic/runtime/Interceptor.java
+++ b/columbus2/src/edu/columbia/cs/psl/metamorphic/runtime/Interceptor.java
@@ -7,7 +7,10 @@ import org.apache.log4j.Logger;



+import edu.columbia.cs.psl.invivo.runtime.AbstractDeepCloningInterceptor;
 import edu.columbia.cs.psl.invivo.runtime.AbstractInterceptor;
+import edu.columbia.cs.psl.invivo.runtime.AbstractLazyCloningInterceptor;
+import edu.columbia.cs.psl.invivo.runtime.InvivoPreMain;
 import edu.columbia.cs.psl.invivo.struct.MethodInvocation;
 import edu.columbia.cs.psl.metamorphic.runtime.annotation.Metamorphic;
 import edu.columbia.cs.psl.metamorphic.runtime.annotation.Rule;
@@ -23,7 +26,7 @@ import edu.columbia.cs.psl.metamorphic.struct.MetamorphicMethodInvocation;
  * @author jon
  *
  */
-public class Interceptor extends AbstractInterceptor {
+public class Interceptor extends AbstractLazyCloningInterceptor {
 	private HashMap<Integer, MetamorphicMethodInvocation> invocations = new HashMap<Integer, MetamorphicMethodInvocation>();
 	private Integer invocationId = 0;
 	private Class<?> testerClass;
@@ -38,25 +41,17 @@ public class Interceptor extends AbstractInterceptor {
 			e.printStackTrace();
 		}
 	}
-	public int onEnter(Object callee, Method method, Object[] params)
-	{
-		if(isChild(callee))
-			return -1;
-
-		int retId = 0;
-		//Get our invocation id
-		synchronized(invocationId)
-		{
-			invocationId++;
-			retId = invocationId;
-		}
+
+	@Override
+	public Object onCall(Object callee, Method method, Object[] params) {
+
 		//Create a new invocation object to store
 		final MetamorphicMethodInvocation inv = new MetamorphicMethodInvocation();
 		inv.params = params;
 		inv.method = method;
 		inv.callee = callee;
 		inv.orig_params = deepClone(params); //Used for the check method, in case you care to refer to them in the rule
-
+
 		//Find the rules
 		Rule[] rules = method.getAnnotation(Metamorphic.class).rules();

@@ -77,20 +72,19 @@ public class Interceptor extends AbstractInterceptor {
 			childParams[i] = params[i];
 			checkTypes[i+2] = params[i].getClass();
 		}
+		inv.thread = createRunnerThread(inv,false);

-
-		invocations.put(retId, inv);
-
+		Object calleeClone = deepClone(inv.callee);
 		inv.children = new MetamorphicMethodInvocation[rules.length];
 		for(int i = 0; i < rules.length;i++)
 		{
 			inv.children[i] = new MetamorphicMethodInvocation();
 			inv.children[i].parent = inv;
-			inv.children[i].callee = deepClone(inv.callee);
+			inv.children[i].callee = shallowClone(calleeClone);
 			((MetamorphicMethodInvocation) inv.children[i]).rule = rules[i];
 			try {
-				inv.children[i].method = getMethod(inv.method.getName()+"_"+i, childTestParamTypes,testerClass);
-				inv.children[i].checkMethod = getMethod(inv.method.getName()+"_Check"+i, checkTypes,testerClass);
+				inv.children[i].method = getMethod(inv.method.getName().substring(InvivoPreMain.config.getInterceptedPrefix().length())+"_"+i, childTestParamTypes,testerClass);
+				inv.children[i].checkMethod = getMethod(inv.method.getName().substring(InvivoPreMain.config.getInterceptedPrefix().length())+"_Check"+i, checkTypes,testerClass);
 			} catch (SecurityException e1) {
 				logger.error("Error looking up method/check method for " + inv.method.getName()+"_"+i, e1);
 			} catch (NoSuchMethodException e1) {
@@ -103,39 +97,21 @@ public class Interceptor extends AbstractInterceptor {
 			inv.children[i].thread= createChildThread(inv.children[i]);
 			inv.children[i].thread.start();
 		}
-		return retId;
-	}
-
-	public void onExit(Object val, int op, int id)
-	{
-		if(id < 0)
-			return;
-		try
-		{
-		MetamorphicMethodInvocation inv = invocations.remove(id);
-		inv.returnValue = val;
-		Object[] checkParams = new Object[inv.params.length + 2];
-		for(int i =0;i<inv.params.length;i++)
-			checkParams[i+2] = inv.orig_params[i];
+
+
+		inv.thread.start();
+		try{
+		inv.thread.join();
 		for(MethodInvocation i : inv.children)
 		{
 			i.thread.join();
-			logger.info("\tChild"+getChildId(i.callee) +" finished");
-
-
-			checkParams[0] = val;
-			checkParams[1] = i.returnValue;
-			if(((Boolean)i.checkMethod.invoke(null, checkParams)) == false)
-			{
-				throw new IllegalStateException("Metamorphic property has been violated on " + inv.method +". Rule: [" + ((MetamorphicMethodInvocation) i).rule +"]. Outputs were [" + val+"], ["+i.returnValue+"]");
-			}
 		}
-		logger.info("Invocation result: " + inv);
 		}
 		catch(Exception ex)
 		{
 			ex.printStackTrace();
 		}
+		return inv.returnValue;
 	}

 }