You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tc...@apache.org on 2012/06/29 09:56:30 UTC

svn commit: r1355256 - in /commons/sandbox/javaflow/trunk/src: main/java/org/apache/commons/javaflow/ main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ main/java/org/apache/commons/javaflow/utils/ test/java/org/apache/commons/javaflow/...

Author: tcurdt
Date: Fri Jun 29 07:56:24 2012
New Revision: 1355256

URL: http://svn.apache.org/viewvc?rev=1355256&view=rev
Log:
some cleanups, mostly white space and style changes, re-implementation of getIterator

Modified:
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationDeath.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/AsmClassTransformer.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationClassAdapter.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAnalyzer.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/MonitoringFrame.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/AsmTestSuite.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/helper/ClassTransformerClassLoader.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/BlackRed.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NestedSynchronized.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullLocalVariable.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
    commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java Fri Jun 29 07:56:24 2012
@@ -347,21 +347,21 @@ public final class ContinuationClassLoad
      */
     private Class<?> getClassFromStream(InputStream stream, String classname) throws IOException, SecurityException {
 
-    	final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try {
-	        
-        	int bytesRead;
-	        byte[] buffer = new byte[BUFFER_SIZE];
-	
-	        while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) {
-	            baos.write(buffer, 0, bytesRead);
-	        }
-	
-	        byte[] classData = baos.toByteArray();
-	        return defineClassFromData(classData, classname);
-        
+
+            int bytesRead;
+            byte[] buffer = new byte[BUFFER_SIZE];
+
+            while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) {
+                baos.write(buffer, 0, bytesRead);
+            }
+
+            byte[] classData = baos.toByteArray();
+            return defineClassFromData(classData, classname);
+
         } finally {
-        	baos.close();
+            baos.close();
         }
     }
 

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationDeath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationDeath.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationDeath.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationDeath.java Fri Jun 29 07:56:24 2012
@@ -27,10 +27,10 @@ import org.apache.commons.javaflow.bytec
  * This class is only for javaflow internal code.
  */
 public final class ContinuationDeath extends Error {
-    
-	private static final long serialVersionUID = 1L;
 
-	final String mode;
+    private static final long serialVersionUID = 1L;
+
+    final String mode;
 
     public ContinuationDeath(String mode) {
         this.mode = mode;

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/AsmClassTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/AsmClassTransformer.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/AsmClassTransformer.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/AsmClassTransformer.java Fri Jun 29 07:56:24 2012
@@ -1,19 +1,19 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 package org.apache.commons.javaflow.bytecode.transformation.asm;
 
 import java.io.IOException;
@@ -48,9 +48,9 @@ public final class AsmClassTransformer i
 
         cr.accept(
             new ContinuationClassAdapter(
-                decorateClassVisitor(cw, true, null/* System.err */)
+            decorateClassVisitor(cw, true, null/* System.err */)
             ), 
-        0);
+            0);
 
         final byte[] bytecode = cw.toByteArray();
 

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationClassAdapter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationClassAdapter.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationClassAdapter.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationClassAdapter.java Fri Jun 29 07:56:24 2012
@@ -1,19 +1,19 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 package org.apache.commons.javaflow.bytecode.transformation.asm;
 
 import org.apache.commons.javaflow.bytecode.Continuable;
@@ -30,35 +30,33 @@ public final class ContinuationClassAdap
         super(Opcodes.ASM4, cv);
     }
 
-    public void visit( int version, int access, String name, String signature, String superName, String[] interfaces ) {
+    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
         className = name;
-        
+
         // Check that it doesn't implement Continuable (already been instrumented)
         String[] newInterfaces = new String[interfaces.length + 1];
-        for(int i = 0; i < interfaces.length; i++)
-        {
-            if(interfaces[i].equals(Type.getInternalName(Continuable.class)))
-            {
+        for (int i = 0; i < interfaces.length; i++) {
+            if (interfaces[i].equals(Type.getInternalName(Continuable.class))) {
                 throw new RuntimeException(className + " has already been instrumented");
             }
-            
+
             newInterfaces[i] = interfaces[i];
         }
-        
+
         // Add the Continuable interface so that the class is marked and wont be instrumented again by mistake
         newInterfaces[newInterfaces.length - 1] = Type.getInternalName(Continuable.class);
 
-        cv.visit(version, access, name, signature, superName, newInterfaces);        
+        cv.visit(version, access, name, signature, superName, newInterfaces);
     }
 
-    public MethodVisitor visitMethod( int access, String name, String desc, String signature, String[] exceptions ) {
+    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
         MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
         // TODO skip native and abstract methods?
-        if (!"<init>".equals(name) && mv!=null) {  
+        if (!"<init>".equals(name) && mv != null) {
             return new ContinuationMethodAnalyzer(className, this.cv, mv, access, name, desc, signature, exceptions);
         }
         return mv;
-   }
-    
+    }
+
 }
 

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java Fri Jun 29 07:56:24 2012
@@ -310,12 +310,14 @@ public final class ContinuationMethodAda
     }
 
     static boolean isNull(BasicValue value) {
-      if (null == value)
-        return true;
-      if (!value.isReference())
-        return false;
-      final Type type = value.getType();
-      return "Lnull;".equals(type.getDescriptor()); 
+        if (null == value) {
+            return true;
+        }
+        if (!value.isReference()) {
+            return false;
+        }
+        final Type type = value.getType();
+        return "Lnull;".equals(type.getDescriptor()); 
     }
 
     void pushDefault(Type type) {

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAnalyzer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAnalyzer.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAnalyzer.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAnalyzer.java Fri Jun 29 07:56:24 2012
@@ -315,8 +315,8 @@ public class ContinuationMethodAnalyzer 
     boolean needsFrameGuard(int opcode, String owner, String name, String desc) {
         /* TODO: need to customize a way enchancer skips classes/methods
             if (owner.startsWith("java/")) {
-            	System.out.println("SKIP:: " + owner + "." + name + desc);
-            	return false;
+                System.out.println("SKIP:: " + owner + "." + name + desc);
+                return false;
             }
         */
 

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/MonitoringFrame.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/MonitoringFrame.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/MonitoringFrame.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/MonitoringFrame.java Fri Jun 29 07:56:24 2012
@@ -27,7 +27,7 @@ import java.util.LinkedList;
 import java.util.List;
 
 public final class MonitoringFrame extends Frame {
-    
+
     // keeps track of monitored locals
     private List<Integer> monitored;
 
@@ -42,15 +42,15 @@ public final class MonitoringFrame exten
 
     public void execute(AbstractInsnNode insn, Interpreter interpreter)
             throws AnalyzerException {
-        
-    	boolean never = false;
+
+        boolean never = false;
         if (never) {
             super.execute(insn, interpreter);
             return;
         }
 
         int insnOpcode = insn.getOpcode();
-        
+
         if (insnOpcode == Opcodes.MONITORENTER || insnOpcode == Opcodes.MONITOREXIT) {
             Value pop = pop();
             interpreter.unaryOperation(insn, pop);
@@ -59,7 +59,7 @@ public final class MonitoringFrame exten
             for (int i = 0; i < getLocals(); i++) {
                 if (getLocal(i) == pop) local = i;
             }
-            
+
             if (local > -1) {
                 if (insnOpcode == Opcodes.MONITORENTER) {
                     monitorEnter(local);
@@ -82,7 +82,7 @@ public final class MonitoringFrame exten
         }
         return this;
     }
-    
+
     public int[] getMonitored() {
         int[] res = new int[monitored.size()];
         for (int i = 0; i < monitored.size(); i++) {
@@ -90,11 +90,11 @@ public final class MonitoringFrame exten
         }
         return res;
     }
-    
+
     public void monitorEnter(int local) {
         monitored.add(new Integer(local));
     }
-    
+
     public void monitorExit(int local) {
         int index = monitored.lastIndexOf(local);
         if (index == -1) {

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java (original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java Fri Jun 29 07:56:24 2012
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,20 +29,20 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 public final class ReflectionUtils {
-    
+
     private final static Log log = LogFactory.getLog(ReflectionUtils.class);
-    
-	public interface Matcher {
+
+    public interface Matcher {
         boolean matches(final String pName);
     }
-	    
+
     public interface Indexer {
         void put(final Map<String, Object> pMap, final String pKey, final Object pObject);
     }
-	    
+
     private static Indexer defaultIndexer = new DefaultIndexer();
     private static Matcher defaultMatcher = new DefaultMatcher();
-	    
+
     public static class DefaultMatcher implements Matcher {
         public boolean matches(final String pName) {
             return true;
@@ -54,30 +54,30 @@ public final class ReflectionUtils {
             pMap.put(pKey, pObject);
         }
     }
-	    
+
     public static Map<String, Object> discoverFields(
             final Class<?> pClazz,
             final Matcher pMatcher
             ) {
-        
+
         return discoverFields(pClazz, pMatcher, defaultIndexer);
     }
 
     public static Map<String, Object> discoverFields(
             final Class<?> pClazz
             ) {
-        
+
         return discoverFields(pClazz, defaultMatcher, defaultIndexer);
     }
-    
+
     public static Map<String, Object> discoverFields(
             final Class<?> pClazz,
             final Matcher pMatcher,
             final Indexer pIndexer
             ) {
-        
+
         log.debug("discovering fields on " + pClazz.getName());
-        
+
         final Map<String, Object> result = new HashMap<String, Object>();
 
         Class<?> current = pClazz;
@@ -87,40 +87,40 @@ public final class ReflectionUtils {
                 final String fname = fields[i].getName();
                 if (pMatcher.matches(fname)) {
                     pIndexer.put(result, fname, fields[i]);
-                    
+
                     log.debug("discovered field " + fname + " -> " + fields[i]);
                 }
             }
             current = current.getSuperclass();
         } while(current != null);
-     
+
         return result;
-    }    
+    }
+
 
-    
     public static Map<String, Object> discoverMethods(
             final Class<?> pClazz,
             final Matcher pMatcher
             ) {
-        
+
         return discoverMethods(pClazz, pMatcher, defaultIndexer);
     }
 
     public static Map<String, Object> discoverMethods(
             final Class<?> pClazz
             ) {
-        
+
         return discoverMethods(pClazz, defaultMatcher, defaultIndexer);
     }
-    
+
     public static Map<String, Object> discoverMethods(
             final Class<?> pClazz,
             final Matcher pMatcher,
             final Indexer pIndexer
             ) {
-        
+
         log.debug("discovering methods on " + pClazz.getName());
-        
+
         final Map<String, Object> result = new HashMap<String, Object>();
 
         Class<?> current = pClazz;
@@ -136,9 +136,9 @@ public final class ReflectionUtils {
             }
             current = current.getSuperclass();
         } while(current != null);
-     
+
         return result;
-    }    
+    }
 
     public static Object cast(Object o) throws IOException, ClassNotFoundException {
         final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
@@ -148,12 +148,12 @@ public final class ReflectionUtils {
         final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
         return ois.readObject();
       }
-    
+
     public static String getClassName(final Object o) {
         if (o == null) {
             return "unknown";
         }
-        
+
         return o.getClass().getName() + "@" + o.hashCode();
     }
 
@@ -161,7 +161,7 @@ public final class ReflectionUtils {
         if (o == null) {
             return "unknown";
         }
-        
+
         return getClassName(o.getClass().getClassLoader());
     }
 }

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/AsmTestSuite.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/AsmTestSuite.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/AsmTestSuite.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/AsmTestSuite.java Fri Jun 29 07:56:24 2012
@@ -48,37 +48,37 @@ public final class AsmTestSuite extends 
     @SuppressWarnings("unchecked")
     public static Test suite() throws Exception {
 
-		// LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", SimpleLog.class.getName());
-		// System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "debug");
-		
+        // LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", SimpleLog.class.getName());
+        // System.setProperty("org.apache.commons.logging.simplelog.defaultlog", "debug");
+        
         final ClassTransformerClassLoader classloader =
             new ClassTransformerClassLoader(
-            	    new AsmClassTransformer(),
-                    new Class[] { // instrument
-                        BlackRed.class,
-                        ClassAccess1.class,
-                        ClassAccess2.class,
-                        ClassAccess3.class,
-                        CounterFlow.class,
-                        ConstructorInvocation.class,
-                        DefaultConstructor.class,
-                        NestedSynchronized.class,
-                        NewObject.class,
-                        NoReference.class,
-                        NullVariableMethodFlow.class,
-                        NullLocalVariable.class,
-                        RewriteBugs.class,
-                        Simple.class,
-                        SimpleSerializable.class,
-                        SimpleSynchronized.class,
-                        SimpleTryCatch.class,
-                        Stack.class,
-                        },  
-                    new Class[] { // load
-                        VerificationTestCase.class,
-                        SerializationTestCase.class
-                        }  
-                    );
+                new AsmClassTransformer(),
+                new Class[] { // instrument
+                    BlackRed.class,
+                    ClassAccess1.class,
+                    ClassAccess2.class,
+                    ClassAccess3.class,
+                    CounterFlow.class,
+                    ConstructorInvocation.class,
+                    DefaultConstructor.class,
+                    NestedSynchronized.class,
+                    NewObject.class,
+                    NoReference.class,
+                    NullVariableMethodFlow.class,
+                    NullLocalVariable.class,
+                    RewriteBugs.class,
+                    Simple.class,
+                    SimpleSerializable.class,
+                    SimpleSynchronized.class,
+                    SimpleTryCatch.class,
+                    Stack.class,
+                    },  
+                new Class[] { // load
+                    VerificationTestCase.class,
+                    SerializationTestCase.class
+                    }  
+                );
         
         final TestSuite suite = new TestSuite();
         suite.setName("ASM");

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/helper/ClassTransformerClassLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/helper/ClassTransformerClassLoader.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/helper/ClassTransformerClassLoader.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/helper/ClassTransformerClassLoader.java Fri Jun 29 07:56:24 2012
@@ -39,17 +39,17 @@ public final class ClassTransformerClass
     private final Set<String> load;
 
     public ClassTransformerClassLoader(final ResourceTransformer pTransformer, final Class<?>[] pInstrument, final Class<?>[] pLoad) {
-    	
-    	instrument = new HashSet<String>(pInstrument.length);
-    	for (int i = 0; i < pInstrument.length; i++) {
-			instrument.add(pInstrument[i].getName());
-		}
-
-    	load = new HashSet<String>(pLoad.length);
-    	for (int i = 0; i < pLoad.length; i++) {
-    		load.add(pLoad[i].getName());
-		}
-    	
+        
+        instrument = new HashSet<String>(pInstrument.length);
+        for (int i = 0; i < pInstrument.length; i++) {
+            instrument.add(pInstrument[i].getName());
+        }
+
+        load = new HashSet<String>(pLoad.length);
+        for (int i = 0; i < pLoad.length; i++) {
+            load.add(pLoad[i].getName());
+        }
+        
         transformer = pTransformer;
     }
 
@@ -63,30 +63,30 @@ public final class ClassTransformerClass
         new File("target/test-instrumentation").mkdirs();
 
         CheckClassAdapter.verify(new ClassReader(newClass), true, new PrintWriter(
-                new FileOutputStream("target/test-instrumentation/" + transformer.getClass().getSimpleName()
-                        + "_" + pName + ".new.check")));
+            new FileOutputStream("target/test-instrumentation/" + transformer.getClass().getSimpleName()
+                + "_" + pName + ".new.check")));
 
         new ClassReader(oldClass).accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
-                new FileOutputStream("target/test-instrumentation/" + transformer.getClass().getSimpleName() 
-                        + "_" + pName + ".old"))), 0);
+            new FileOutputStream("target/test-instrumentation/" + transformer.getClass().getSimpleName() 
+                + "_" + pName + ".old"))), 0);
 
         new ClassReader(newClass).accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(
-                new FileOutputStream("target/test-instrumentation/" + transformer.getClass().getSimpleName()
-                        + "_" + pName + ".new"))), 0);
+            new FileOutputStream("target/test-instrumentation/" + transformer.getClass().getSimpleName()
+                + "_" + pName + ".new"))), 0);
 
         return newClass;
     }
 
     
     public Class<?> loadClass( final String name ) throws ClassNotFoundException {
-    	
+        
         final int i = name.indexOf('$');
         final String key;
         
         if (i == -1) {
-        	key = name;
+            key = name;
         } else {
-        	key = name.substring(0, i);
+            key = name.substring(0, i);
         }
         
         if (instrument.contains(key) || load.contains(key)) {
@@ -99,10 +99,10 @@ public final class ClassTransformerClass
                 
                 if (instrument.contains(key)) {
                     // System.err.println("Instrumenting: " + name);
-                	bytecode = transform(name, is);
+                    bytecode = transform(name, is);
                 } else {
                     // System.err.println("Loading: " + name);
-					bytecode = new ClassReader(is).b;                	
+                    bytecode = new ClassReader(is).b;                   
                 }
                 
                 return super.defineClass(name, bytecode, 0, bytecode.length);

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/BlackRed.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/BlackRed.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/BlackRed.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/BlackRed.java Fri Jun 29 07:56:24 2012
@@ -28,48 +28,48 @@ import java.io.Serializable;
 @SuppressWarnings("unused")
 public final class BlackRed implements Runnable, Serializable {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
 
-	public void run() {
-		// new Black( new Red( new Black( new Suspend()))).run();
-		new Black( new Suspend()).run();
-	}
+    public void run() {
+        // new Black( new Red( new Black( new Suspend()))).run();
+        new Black( new Suspend()).run();
+    }
 
 
-	class Black implements Runnable {
-		final Runnable r;
+    class Black implements Runnable {
+        final Runnable r;
 
-		public Black( Runnable r) {
-			this.r = r;
-		}
+        public Black( Runnable r) {
+            this.r = r;
+        }
 
-		public void run() {
+        public void run() {
             String s = "foo"; // have some random variable
-			r.run();
-		}
-	}
-
-
-	class Red implements Runnable {
-		final Runnable r;
-
-		public Red( Runnable r) {
-			this.r = r;
-		}
-
-		public void run() {
-			int i = 5; // have some random variable
-			r.run();
-		}
-	}
-
-
-	class Suspend implements Runnable {
-		public void run() {
-			Continuation.suspend();
-		}
-	}
+            r.run();
+        }
+    }
+
+
+    class Red implements Runnable {
+        final Runnable r;
+
+        public Red( Runnable r) {
+            this.r = r;
+        }
+
+        public void run() {
+            int i = 5; // have some random variable
+            r.run();
+        }
+    }
+
+
+    class Suspend implements Runnable {
+        public void run() {
+            Continuation.suspend();
+        }
+    }
 
 }
 

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NestedSynchronized.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NestedSynchronized.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NestedSynchronized.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NestedSynchronized.java Fri Jun 29 07:56:24 2012
@@ -1,86 +1,86 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 package org.apache.commons.javaflow.rewrite;
 
 import org.apache.commons.javaflow.Continuation;
 
 public final class NestedSynchronized implements Runnable {
 
-        public boolean a = false;
-        public boolean b = false;
-        public boolean c = false;
-        public boolean d = false;
-        public boolean e = false;
-        public boolean f = false;
-        public boolean g = false;
-        public boolean h = false;
-        public boolean i = false;
-        public boolean j = false;
-        
-        private Object o = new Object();
-
-        public void run() {		
-                try {
-                    o.notify();
-                } catch (IllegalMonitorStateException e) {
-                    a = true;
-                }
-                Continuation.suspend();
-                try {
-                    o.notify();
-                } catch (IllegalMonitorStateException e) {
-                    b = true;
-                }
-                synchronized(o) {
-                        c = true;
-                        o.notify();
-                        method();
-                        o.notify();
-                        h = true;
-                }
-                try {
-                    o.notify();
-                } catch (IllegalMonitorStateException e) {
-                    i = true;
-                }
-                Continuation.suspend();
-                try {
-                    o.notify();
-                } catch (IllegalMonitorStateException e) {
-                    j = true;
-                }
-        }
-
-        public void method() {
-            try {
-                d = true;
-                o.notify();
-                nested();
-            } finally {
-                o.notify();
-                g = true;
-            }
-        }
-
-        public void nested() {
-            e = true;
-            Continuation.suspend();
+    public boolean a = false;
+    public boolean b = false;
+    public boolean c = false;
+    public boolean d = false;
+    public boolean e = false;
+    public boolean f = false;
+    public boolean g = false;
+    public boolean h = false;
+    public boolean i = false;
+    public boolean j = false;
+
+    private Object o = new Object();
+
+    public void run() {
+        try {
+            o.notify();
+        } catch (IllegalMonitorStateException e) {
+            a = true;
+        }
+        Continuation.suspend();
+        try {
+            o.notify();
+        } catch (IllegalMonitorStateException e) {
+            b = true;
+        }
+        synchronized(o) {
+            c = true;
+            o.notify();
+            method();
+            o.notify();
+            h = true;
+        }
+        try {
+            o.notify();
+        } catch (IllegalMonitorStateException e) {
+            i = true;
+        }
+        Continuation.suspend();
+        try {
+            o.notify();
+        } catch (IllegalMonitorStateException e) {
+            j = true;
+        }
+    }
+
+    public void method() {
+        try {
+            d = true;
             o.notify();
-            f = true;
+            nested();
+        } finally {
+            o.notify();
+            g = true;
         }
+    }
+
+    public void nested() {
+        e = true;
+        Continuation.suspend();
+        o.notify();
+        f = true;
+    }
 
 }

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NoReference.java Fri Jun 29 07:56:24 2012
@@ -1,28 +1,28 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 package org.apache.commons.javaflow.rewrite;
 
 import org.apache.commons.javaflow.Continuation;
 
 public final class NoReference implements Runnable {
 
-  public void run() {
-    new Object();
-    Continuation.suspend();
-  }
+    public void run() {
+        new Object();
+        Continuation.suspend();
+    }
 
 }
\ No newline at end of file

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullLocalVariable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullLocalVariable.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullLocalVariable.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullLocalVariable.java Fri Jun 29 07:56:24 2012
@@ -20,8 +20,9 @@ public class NullLocalVariable implement
     @SuppressWarnings("null")
     public void method1() {
         Integer result = null;
-        if (result != 0)
+        if (result != 0) {
             result = 1;
+        }
     }
 
     @SuppressWarnings("unused")

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/NullVariableMethodFlow.java Fri Jun 29 07:56:24 2012
@@ -39,8 +39,9 @@ public class NullVariableMethodFlow impl
             x = session.getProperty("b");
         }
 
-        if (y == null)
+        if (y == null) {
             y = x;
+        }
 
         return y;
     }

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/RewriteBugs.java Fri Jun 29 07:56:24 2012
@@ -26,145 +26,130 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-@SuppressWarnings({ "unchecked", "rawtypes" })
+@SuppressWarnings({"unchecked", "rawtypes"})
 public final class RewriteBugs implements Runnable {
 
     public void run() {
-        RewriteBugs.calculateCartesianProduct(new String[]{"a","b"}, new Object[]{"1","2"});
+        RewriteBugs.calculateCartesianProduct(new String[]{"a", "b"}, new Object[]{"1", "2"});
     }
 
-	/**
-	 * 
-	 * ASM rewriting BUG!
-	 * 
-	 *  Calculate the cartesian product of parameters.
-	 *  Example: names = {"a", "b"}, values = {{"1", "2"}, {"3", "4"}}
-	 *  		 result = {{"a"="1", "b"="3"}, {"a"="2", "b"="3"}, {"a"="1", "b"="4"}, {"a=2", b="4"}}
-	 *  @param names The names.
-	 *  @param values The values (must be some form of collection, i.e. array, list, iterator etc.)
-	 */
-    public static List calculateCartesianProduct(String[] names, Object[] values)
-	{
-		//ArrayList ret = SCollection.createArrayList();
-		ArrayList ret = new ArrayList();
-		if(names==null || values==null)
-			return ret;
-		if(names.length!=values.length)
-			throw new IllegalArgumentException("Must have same length: "+names.length+" "+values.length);
-		
-		//HashMap binding = SCollection.createHashMap();
-		HashMap binding = new HashMap();
-		Iterator[] iters = new Iterator[values.length];
-		
-		for(int i=0; i<values.length; i++)
-		{
-			// When one collection is empty -> no binding at all.
-			// First binding consists of all first elements.
-			//iters[i] = SReflect.getIterator(values[i]);
-			iters[i] = RewriteBugs.getIterator(values[i]);
-			if(!iters[i].hasNext())
-			{
-				return ret;
-			}
-			else
-			{
-				binding.put(names[i], iters[i].next());
-			}
-		}
-		ret.add(binding);
-		
-		// Iterate through binding sets for subsequent bindings.
-		while(true)
-		{
-			// Calculate next binding.
-			// Copy old binding and change one value.
-			binding = (HashMap)binding.clone();
-			int i = 0;
-			for(; i<values.length && !iters[i].hasNext(); i++)
-			{
-				// Overflow: Re-init iterator.
-				//iters[i] = SReflect.getIterator(values[i]);
-				iters[i] = RewriteBugs.getIterator(values[i]);
-				binding.put(names[i], iters[i].next());
-			}
-			if(i<iters.length)
-			{
-				binding.put(names[i], iters[i].next());
-			}
-			else
-			{
-				// Overflow in last iterator: done.
-				// Hack: Unnecessarily re-inits all iterators before break ?
-				break;
-			}
-			ret.add(binding);
-		}
-		
-		return ret;
-	}
-	
-	
-	
-	// 
-	// ---- helper methods -- copied from jadex utility classes -----
-	//
-	
-	/**
-	 *  Get an iterator for an arbitrary collection object.
-	 *  Supports iterators, enumerations, java.util.Collections,
-	 *  java.util.Maps, arrays. Null is converted to empty iterator.
-	 *  @param collection	The collection object.
-	 *  @return An iterator over the collection.
-	 *  @throws IllegalArgumentException when argument is not
-	 * 		one of (Iterator, Enumeration, Collection, Map, Array).
-	 */
-	public static Iterator	getIterator(Object collection)
-	{
-		if(collection==null)
-		{
-			return Collections.EMPTY_LIST.iterator();
-		}
-		else if(collection instanceof Iterator)
-		{
-			return (Iterator)collection;
-		}
-		else if(collection instanceof Enumeration)
-		{
-			// Return enumeration wrapper.
-			final Enumeration eoc	= (Enumeration)collection;
-			return new Iterator()
-			{
-				public boolean	hasNext()	{return eoc.hasMoreElements();}
-				public Object	next()	{return eoc.nextElement();}
-				public void	remove(){throw new UnsupportedOperationException(
-					"remove() not supported for enumerations");}
-			};
-		}
-		else if(collection instanceof Collection)
-		{
-			return ((Collection)collection).iterator();
-		}
-		else if(collection instanceof Map)
-		{
-			return ((Map)collection).values().iterator();
-		}
-		else if(collection!=null && collection.getClass().isArray())
-		{
-			// Return array wrapper.
-			final Object array	= collection;
-			return new Iterator()
-			{
-				int i=0;
-				public boolean	hasNext()	{return i<Array.getLength(array);}
-				public Object	next()	{return Array.get(array, i++);}
-				public void	remove()	{throw new UnsupportedOperationException(
-					"remove() not supported for arrays");}
-			};
-		}
-		else
-		{
-			throw new IllegalArgumentException("Cannot iterate over "+collection);
-		}
-	}
-	
+    /**
+     * ASM rewriting BUG!
+     * <p/>
+     * Calculate the cartesian product of parameters.
+     * Example: names = {"a", "b"}, values = {{"1", "2"}, {"3", "4"}}
+     * result = {{"a"="1", "b"="3"}, {"a"="2", "b"="3"}, {"a"="1", "b"="4"}, {"a=2", b="4"}}
+     *
+     * @param names  The names.
+     * @param values The values (must be some form of collection, i.e. array, list, iterator etc.)
+     */
+    public static List calculateCartesianProduct(String[] names, Object[] values) {
+        //ArrayList ret = SCollection.createArrayList();
+        ArrayList ret = new ArrayList();
+        if (names == null || values == null) {
+            return ret;
+        }
+        if (names.length != values.length) {
+            throw new IllegalArgumentException("Must have same length: " + names.length + " " + values.length);
+        }
+
+        //HashMap binding = SCollection.createHashMap();
+        HashMap binding = new HashMap();
+        Iterator[] iters = new Iterator[values.length];
+
+        for (int i = 0; i < values.length; i++) {
+            // When one collection is empty -> no binding at all.
+            // First binding consists of all first elements.
+            //iters[i] = SReflect.getIterator(values[i]);
+            iters[i] = RewriteBugs.getIterator(values[i]);
+            if (!iters[i].hasNext()) {
+                return ret;
+            } else {
+                binding.put(names[i], iters[i].next());
+            }
+        }
+        ret.add(binding);
+
+        // Iterate through binding sets for subsequent bindings.
+        while (true) {
+            // Calculate next binding.
+            // Copy old binding and change one value.
+            binding = (HashMap) binding.clone();
+            int i = 0;
+            for (; i < values.length && !iters[i].hasNext(); i++) {
+                // Overflow: Re-init iterator.
+                //iters[i] = SReflect.getIterator(values[i]);
+                iters[i] = RewriteBugs.getIterator(values[i]);
+                binding.put(names[i], iters[i].next());
+            }
+            if (i < iters.length) {
+                binding.put(names[i], iters[i].next());
+            } else {
+                // Overflow in last iterator: done.
+                // Hack: Unnecessarily re-inits all iterators before break ?
+                break;
+            }
+            ret.add(binding);
+        }
+
+        return ret;
+    }
+
+    // get iterator for object if possible
+    private static Iterator getIterator(Object collection) {
+        if (collection == null) {
+            return Collections.EMPTY_LIST.iterator();
+        }
+
+        if (collection instanceof Iterator) {
+            return (Iterator) collection;
+        }
+
+        if (collection instanceof Enumeration) {
+            final Enumeration e = (Enumeration) collection;
+            return new Iterator() {
+                public boolean hasNext() {
+                    return e.hasMoreElements();
+                }
+
+                public Object next() {
+                    return e.nextElement();
+                }
+
+                public void remove() {
+                    throw new UnsupportedOperationException("remove not supported");
+                }
+            };
+        }
+
+        if (collection instanceof Collection) {
+            return ((Collection) collection).iterator();
+        }
+
+        if (collection instanceof Map) {
+            return ((Map) collection).values().iterator();
+        }
+
+        if (collection != null && collection.getClass().isArray()) {
+
+            final Object array = collection;
+            return new Iterator() {
+                int i = 0;
+
+                public boolean hasNext() {
+                    return i < Array.getLength(array);
+                }
+
+                public Object next() {
+                    return Array.get(array, i++);
+                }
+
+                public void remove() {
+                    throw new UnsupportedOperationException("remove not supported");
+                }
+            };
+        }
+
+        throw new IllegalArgumentException("cannot iterate over " + collection);
+    }
 }
\ No newline at end of file

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleSynchronized.java Fri Jun 29 07:56:24 2012
@@ -20,27 +20,27 @@ import org.apache.commons.javaflow.Conti
 
 public final class SimpleSynchronized implements Runnable {
 
-	public boolean a = false;
-	public boolean b = false;
-	public boolean c = false;
-	public boolean d = false;
-	public boolean e = false;
-	public boolean f = false;
+    public boolean a = false;
+    public boolean b = false;
+    public boolean c = false;
+    public boolean d = false;
+    public boolean e = false;
+    public boolean f = false;
 
-	private Object o = new Object();
-	
-	public void run() {		
-		a = true;
-		Continuation.suspend();
-		b = true;
-		synchronized(o) {
-			c = true;
-			Continuation.suspend();
-			d = true;
-		}
-		e = true;
-		Continuation.suspend();
-		f = true;		
+    private Object o = new Object();
+
+    public void run() {
+        a = true;
+        Continuation.suspend();
+        b = true;
+        synchronized(o) {
+            c = true;
+            Continuation.suspend();
+            d = true;
+        }
+        e = true;
+        Continuation.suspend();
+        f = true;
     }
 
 }
\ No newline at end of file

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/rewrite/SimpleTryCatch.java Fri Jun 29 07:56:24 2012
@@ -20,36 +20,36 @@ import org.apache.commons.javaflow.Conti
 
 public final class SimpleTryCatch implements Runnable {
 
-	public boolean a = false;
-	public boolean b = false;
-	public boolean c = false;
-	public boolean d = false;
-	public boolean e = false;
-	public boolean f = false;
+    public boolean a = false;
+    public boolean b = false;
+    public boolean c = false;
+    public boolean d = false;
+    public boolean e = false;
+    public boolean f = false;
 
-	private final boolean throwException;
-	
-	public SimpleTryCatch(final boolean pThrowException) {
-		throwException = pThrowException;
-	}
-	
-	public void run() {
-    	try {
-    		a = true;
-    		Continuation.suspend();
-    		if (throwException) {
-    			throw new Exception("exception");
-    		}
-    		b = true;
-    	} catch(Exception e) {
-    		c = true;
-    		Continuation.suspend();
-    		d = true;
-    	} finally {
-    		e = true;
-    		Continuation.suspend();
-    		f = true;
-    	}    	
+    private final boolean throwException;
+    
+    public SimpleTryCatch(final boolean pThrowException) {
+        throwException = pThrowException;
+    }
+    
+    public void run() {
+        try {
+            a = true;
+            Continuation.suspend();
+            if (throwException) {
+                throw new Exception("exception");
+            }
+            b = true;
+        } catch(Exception e) {
+            c = true;
+            Continuation.suspend();
+            d = true;
+        } finally {
+            e = true;
+            Continuation.suspend();
+            f = true;
+        }       
     }
 
 }
\ No newline at end of file

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/SerializationTestCase.java Fri Jun 29 07:56:24 2012
@@ -46,19 +46,19 @@ public final class SerializationTestCase
     }
 
     public void testSuspend() throws Exception {
-        assertTrue(fromSuite());        
+        assertTrue(fromSuite());
         final SimpleSerializable r = new SimpleSerializable();
         assertTrue(r.g == -1);
         assertTrue(r.l == -1);
         Continuation c1 = Continuation.startWith(r);
         assertTrue(r.g == 0);
         assertTrue(r.l == 0);
-        
+
         output = File.createTempFile("continuation", "xml");
         output.deleteOnExit();
 
         saveJDK(c1, output);
-        
+
     }
 
     public class ObjectInputStreamExt extends ObjectInputStream {
@@ -73,16 +73,16 @@ public final class SerializationTestCase
         @SuppressWarnings("rawtypes")
         protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
 
-        	return Class.forName(classDesc.getName(), true, classloader);
+            return Class.forName(classDesc.getName(), true, classloader);
         }
 
         @SuppressWarnings("rawtypes")
         protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
             Class[] cinterfaces = new Class[interfaces.length];
             for (int i = 0; i < interfaces.length; i++) {
-            	cinterfaces[i] = Class.forName(interfaces[i], true, classloader);
+                cinterfaces[i] = Class.forName(interfaces[i], true, classloader);
             }
-            
+
             try {
                 return Proxy.getProxyClass(classloader, cinterfaces);
             } catch (IllegalArgumentException e) {
@@ -90,36 +90,36 @@ public final class SerializationTestCase
             }
         }
     }
-    
-    
+
+
     private void saveJDK(final Object c1, final File output) throws IOException {
-    	final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(output));    	
-    	oos.writeObject(c1); 
-    	oos.close(); 
+        final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(output));
+        oos.writeObject(c1);
+        oos.close();
     }
 
     private Object loadJDK(final File input) throws IOException, ClassNotFoundException {
-    	final ObjectInputStream ois = new ObjectInputStreamExt(new FileInputStream(input), this.getClass().getClassLoader());
-    	final Object o = ois.readObject();
-    	ois.close();
-    	return o;
+        final ObjectInputStream ois = new ObjectInputStreamExt(new FileInputStream(input), this.getClass().getClassLoader());
+        final Object o = ois.readObject();
+        ois.close();
+        return o;
     }
-    
+
     public void testResume() throws Exception {
-        assertTrue(fromSuite());        
+        assertTrue(fromSuite());
         testSuspend();
         assertTrue("suspend must succeed to create the output first", output != null);
 
         assertEquals(output.length(), 562);
-        
+
         final Object o = loadJDK(output);
-        
+
         assertTrue(o instanceof Continuation);
         final Continuation c1 = (Continuation) o;
         final StackRecorder sr1 = (StackRecorder) PrivateAccessor.getField(c1,"stackRecorder");
         final Runnable r1 = (Runnable) PrivateAccessor.getField(sr1, "runnable");
         assertEquals(SimpleSerializable.class.getName(), r1.getClass().getName());
-        
+
         final SimpleSerializable ss1 = (SimpleSerializable)r1;
         assertTrue(ss1.g == 0);
         assertTrue(ss1.l == 0);
@@ -135,7 +135,7 @@ public final class SerializationTestCase
 
 
     public void testSerializableCheck() throws Exception {
-        assertTrue(fromSuite());        
+        assertTrue(fromSuite());
         final Runnable r1 = new Simple();
         Continuation c1 = Continuation.startWith(r1);
         assertTrue(c1 != null);

Modified: commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java?rev=1355256&r1=1355255&r2=1355256&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java (original)
+++ commons/sandbox/javaflow/trunk/src/test/java/org/apache/commons/javaflow/suite/VerificationTestCase.java Fri Jun 29 07:56:24 2012
@@ -41,345 +41,345 @@ import org.apache.commons.javaflow.rewri
 
 public final class VerificationTestCase extends TestCase {
 
-	private boolean fromSuite() {
-		final String cl = this.getClass().getClassLoader().getClass().getName();
-		return cl.contains("ClassTransformerClassLoader");
-	}
-
-	public void testBlackRed2() {
-		assertTrue(fromSuite());
-		final Runnable r = new BlackRed();
-		final Continuation c1 = Continuation.startWith(r);
-		assertTrue(c1 != null);
-		final Continuation c2 = Continuation.continueWith(c1);
-		assertTrue(c2 == null);
-	}
-
-	public void testClassAccess1() throws Exception {
-		assertTrue(fromSuite());
-		final ClassAccess1 r = new ClassAccess1();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c != null);
-	}
-
-	public void testClassAccess2() throws Exception {
-		assertTrue(fromSuite());
-		final ClassAccess2 r = new ClassAccess2();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c != null);
-	}
-
-	public void testClassAccess3() throws Exception {
-		assertTrue(fromSuite());
-		final ClassAccess3 r = new ClassAccess3();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c != null);
-	}
-
-	public void testCounter() {
-		assertTrue(fromSuite());
-		final int count = 5;
-		final Runnable r = new CounterFlow(count);
-		int i = 0;
-		Continuation c = Continuation.startWith(r);
-		while (c != null) {
-			c = Continuation.continueWith(c);
-			i++;
-		}
-		assertTrue(i == count);
-	}
-
-	public void testInvoker() {
-		assertTrue(fromSuite());
-		Runnable o = new DefaultConstructor();
-		Continuation c = Continuation.startWith(o);
-		assertTrue(c == null);
-	}
-
-	public void testInvoker2() {
-		assertTrue(fromSuite());
-		final Runnable r = new Simple();
-		final Runnable o = new Invoker(r);
-		final Continuation c = Continuation.startWith(o);
-		assertNotNull(c);
-	}
-
-	public void testConstructorInvocation() throws Exception {
-		assertTrue(fromSuite());
-		final Runnable r = new ConstructorInvocation();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c != null);
-		final Continuation c2 = Continuation.continueWith(c);
-		assertTrue(c2 == null);
-	}
-
-	public void testNewObject() throws Exception {
-		assertTrue(fromSuite());
-		final Runnable r = new NewObject();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c == null);
-	}
-
-	public void testNullVariableMethodFlow() throws Exception {
-		assertTrue(fromSuite());
-		final Runnable r = new NullVariableMethodFlow();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c == null);
-	}
-	
-	public void testNullLocalVariable() throws Exception {
-		assertTrue(fromSuite());
-		final Runnable r = new NullLocalVariable();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c == null);
-	}
-
-	public void testNoReference() throws Exception {
-		assertTrue(fromSuite());
-		final Runnable r = new NoReference();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c != null);
-	}
-
-	public void testSimpleSuspendResume() throws Exception {
-		assertTrue(fromSuite());
-		final SimpleSerializable r = new SimpleSerializable();
-		assertTrue(r.g == -1);
-		assertTrue(r.l == -1);
-		Continuation c1 = Continuation.startWith(r);
-		assertNotNull(c1);
-		assertTrue(r.g == 0);
-		assertTrue(r.l == 0);
-		Continuation c2 = Continuation.continueWith(c1);
-		assertNotNull(c2);
-		assertTrue(r.g == 1);
-		assertTrue(r.l == 1);
-		Continuation c3 = Continuation.continueWith(c2);
-		assertNotNull(c3);
-		assertTrue(r.g == 2);
-		assertTrue(r.l == 2);
-	}
-
-	public void testContinuationBranching() throws Exception {
-		assertTrue(fromSuite());
-		final SimpleSerializable r = new SimpleSerializable();
-		assertTrue(r.g == -1);
-		assertTrue(r.l == -1);
-		Continuation c1 = Continuation.startWith(r);
-		assertNotNull(c1);
-		assertTrue(r.g == 0);
-		assertTrue(r.l == 0);
-		Continuation c2 = Continuation.continueWith(c1);
-		assertNotNull(c2);
-		assertTrue(r.g == 1);
-		assertTrue(r.l == 1);
-		Continuation c31 = Continuation.continueWith(c2);
-		assertNotNull(c31);
-		assertTrue(r.g == 2);
-		assertTrue(r.l == 2);
-		Continuation c32 = Continuation.continueWith(c2);
-		assertNotNull(c32);
-		assertTrue(r.g == 3);
-		assertTrue(r.l == 2);
-	}
-
-	public void testSimpleSuspend() throws Exception {
-		assertTrue(fromSuite());
-		final Simple r = new Simple();
-		final Continuation c = Continuation.startWith(r);
-		assertTrue(c != null);
-	}
-
-	public void testSimpleTryCatchWithoutException() throws Exception {
-		assertTrue(fromSuite());
-		final SimpleTryCatch r = new SimpleTryCatch(false);
-		Continuation c;
-
-		c = Continuation.startWith(r); // suspend within the try/catch
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertFalse(r.b);
-		assertFalse(r.c);
-		assertFalse(r.d);
-		assertFalse(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // continue without exception and end
-											// in finally
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertFalse(r.c);
-		assertFalse(r.d);
-		assertTrue(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // continue within the finally and end
-											// in return
-		assertTrue(c == null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertFalse(r.c);
-		assertFalse(r.d);
-		assertTrue(r.e);
-		assertTrue(r.f);
-
-	}
-
-	public void testSimpleTryCatchWithException() throws Exception {
-		assertTrue(fromSuite());
-		final SimpleTryCatch r = new SimpleTryCatch(true);
-		Continuation c;
-
-		c = Continuation.startWith(r); // suspend in the try/catch
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertFalse(r.b);
-		assertFalse(r.c);
-		assertFalse(r.d);
-		assertFalse(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // exception jumps into exception
-											// block and suspends
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertFalse(r.b);
-		assertTrue(r.c);
-		assertFalse(r.d);
-		assertFalse(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // continue in the exception block and
-											// then suspends in finally
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertFalse(r.b);
-		assertTrue(r.c);
-		assertTrue(r.d);
-		assertTrue(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // continue in finally
-		assertTrue(c == null);
-		assertTrue(r.a);
-		assertFalse(r.b);
-		assertTrue(r.c);
-		assertTrue(r.d);
-		assertTrue(r.e);
-		assertTrue(r.f);
-	}
-
-	public void testSimpleSynchronized() throws Exception {
-		assertTrue(fromSuite());
-		final SimpleSynchronized r = new SimpleSynchronized();
-		Continuation c;
-
-		c = Continuation.startWith(r); // suspend right away
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertFalse(r.b);
-		assertFalse(r.c);
-		assertFalse(r.d);
-		assertFalse(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // resume and run into synchronized
-											// block where we suspend again
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertTrue(r.c);
-		assertFalse(r.d);
-		assertFalse(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // continue inside the synchronized
-											// block and suspend after
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertTrue(r.c);
-		assertTrue(r.d);
-		assertTrue(r.e);
-		assertFalse(r.f);
-
-		c = Continuation.continueWith(c); // resume and then return
-		assertTrue(c == null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertTrue(r.c);
-		assertTrue(r.d);
-		assertTrue(r.e);
-		assertTrue(r.f);
-	}
-
-	public void testStack() throws Exception {
-		assertTrue(fromSuite());
-		final Runnable r = new Stack();
-		final Continuation c = Continuation.startWith(r);
-		assertNull(c); // does not have a suspend
-	}
-
-	public void testNestedSynchronized() throws Exception {
-		final NestedSynchronized r = new NestedSynchronized();
-		Continuation c;
-
-		c = Continuation.startWith(r);
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertFalse(r.b);
-		assertFalse(r.c);
-		assertFalse(r.d);
-		assertFalse(r.e);
-		assertFalse(r.f);
-		assertFalse(r.g);
-		assertFalse(r.h);
-		assertFalse(r.i);
-		assertFalse(r.j);
-
-		c = Continuation.continueWith(c);
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertTrue(r.c);
-		assertTrue(r.d);
-		assertTrue(r.e);
-		assertFalse(r.f);
-		assertFalse(r.g);
-		assertFalse(r.h);
-		assertFalse(r.i);
-		assertFalse(r.j);
-
-		c = Continuation.continueWith(c);
-		assertTrue(c != null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertTrue(r.c);
-		assertTrue(r.d);
-		assertTrue(r.e);
-		assertTrue(r.f);
-		assertTrue(r.g);
-		assertTrue(r.h);
-		assertTrue(r.i);
-		assertFalse(r.j);
-
-		c = Continuation.continueWith(c);
-		assertTrue(c == null);
-		assertTrue(r.a);
-		assertTrue(r.b);
-		assertTrue(r.c);
-		assertTrue(r.d);
-		assertTrue(r.e);
-		assertTrue(r.f);
-		assertTrue(r.g);
-		assertTrue(r.h);
-		assertTrue(r.i);
-		assertTrue(r.j);
-	}
-
-	public void testASMRewriteBug() throws Exception {
-		RewriteBugs.calculateCartesianProduct(new String[] { "a", "b" },
-				new Object[][] { { "1", "2" }, { "3", "4" } });
-	}
+    private boolean fromSuite() {
+        final String cl = this.getClass().getClassLoader().getClass().getName();
+        return cl.contains("ClassTransformerClassLoader");
+    }
+
+    public void testBlackRed2() {
+        assertTrue(fromSuite());
+        final Runnable r = new BlackRed();
+        final Continuation c1 = Continuation.startWith(r);
+        assertTrue(c1 != null);
+        final Continuation c2 = Continuation.continueWith(c1);
+        assertTrue(c2 == null);
+    }
+
+    public void testClassAccess1() throws Exception {
+        assertTrue(fromSuite());
+        final ClassAccess1 r = new ClassAccess1();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+
+    public void testClassAccess2() throws Exception {
+        assertTrue(fromSuite());
+        final ClassAccess2 r = new ClassAccess2();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+
+    public void testClassAccess3() throws Exception {
+        assertTrue(fromSuite());
+        final ClassAccess3 r = new ClassAccess3();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+
+    public void testCounter() {
+        assertTrue(fromSuite());
+        final int count = 5;
+        final Runnable r = new CounterFlow(count);
+        int i = 0;
+        Continuation c = Continuation.startWith(r);
+        while (c != null) {
+            c = Continuation.continueWith(c);
+            i++;
+        }
+        assertTrue(i == count);
+    }
+
+    public void testInvoker() {
+        assertTrue(fromSuite());
+        Runnable o = new DefaultConstructor();
+        Continuation c = Continuation.startWith(o);
+        assertTrue(c == null);
+    }
+
+    public void testInvoker2() {
+        assertTrue(fromSuite());
+        final Runnable r = new Simple();
+        final Runnable o = new Invoker(r);
+        final Continuation c = Continuation.startWith(o);
+        assertNotNull(c);
+    }
+
+    public void testConstructorInvocation() throws Exception {
+        assertTrue(fromSuite());
+        final Runnable r = new ConstructorInvocation();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+        final Continuation c2 = Continuation.continueWith(c);
+        assertTrue(c2 == null);
+    }
+
+    public void testNewObject() throws Exception {
+        assertTrue(fromSuite());
+        final Runnable r = new NewObject();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c == null);
+    }
+
+    public void testNullVariableMethodFlow() throws Exception {
+        assertTrue(fromSuite());
+        final Runnable r = new NullVariableMethodFlow();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c == null);
+    }
+
+    public void testNullLocalVariable() throws Exception {
+        assertTrue(fromSuite());
+        final Runnable r = new NullLocalVariable();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c == null);
+    }
+
+    public void testNoReference() throws Exception {
+        assertTrue(fromSuite());
+        final Runnable r = new NoReference();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+
+    public void testSimpleSuspendResume() throws Exception {
+        assertTrue(fromSuite());
+        final SimpleSerializable r = new SimpleSerializable();
+        assertTrue(r.g == -1);
+        assertTrue(r.l == -1);
+        Continuation c1 = Continuation.startWith(r);
+        assertNotNull(c1);
+        assertTrue(r.g == 0);
+        assertTrue(r.l == 0);
+        Continuation c2 = Continuation.continueWith(c1);
+        assertNotNull(c2);
+        assertTrue(r.g == 1);
+        assertTrue(r.l == 1);
+        Continuation c3 = Continuation.continueWith(c2);
+        assertNotNull(c3);
+        assertTrue(r.g == 2);
+        assertTrue(r.l == 2);
+    }
+
+    public void testContinuationBranching() throws Exception {
+        assertTrue(fromSuite());
+        final SimpleSerializable r = new SimpleSerializable();
+        assertTrue(r.g == -1);
+        assertTrue(r.l == -1);
+        Continuation c1 = Continuation.startWith(r);
+        assertNotNull(c1);
+        assertTrue(r.g == 0);
+        assertTrue(r.l == 0);
+        Continuation c2 = Continuation.continueWith(c1);
+        assertNotNull(c2);
+        assertTrue(r.g == 1);
+        assertTrue(r.l == 1);
+        Continuation c31 = Continuation.continueWith(c2);
+        assertNotNull(c31);
+        assertTrue(r.g == 2);
+        assertTrue(r.l == 2);
+        Continuation c32 = Continuation.continueWith(c2);
+        assertNotNull(c32);
+        assertTrue(r.g == 3);
+        assertTrue(r.l == 2);
+    }
+
+    public void testSimpleSuspend() throws Exception {
+        assertTrue(fromSuite());
+        final Simple r = new Simple();
+        final Continuation c = Continuation.startWith(r);
+        assertTrue(c != null);
+    }
+
+    public void testSimpleTryCatchWithoutException() throws Exception {
+        assertTrue(fromSuite());
+        final SimpleTryCatch r = new SimpleTryCatch(false);
+        Continuation c;
+
+        c = Continuation.startWith(r); // suspend within the try/catch
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // continue without exception and end
+                                            // in finally
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // continue within the finally and end
+                                            // in return
+        assertTrue(c == null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);
+
+    }
+
+    public void testSimpleTryCatchWithException() throws Exception {
+        assertTrue(fromSuite());
+        final SimpleTryCatch r = new SimpleTryCatch(true);
+        Continuation c;
+
+        c = Continuation.startWith(r); // suspend in the try/catch
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // exception jumps into exception
+                                            // block and suspends
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertTrue(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // continue in the exception block and
+                                            // then suspends in finally
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // continue in finally
+        assertTrue(c == null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);
+    }
+
+    public void testSimpleSynchronized() throws Exception {
+        assertTrue(fromSuite());
+        final SimpleSynchronized r = new SimpleSynchronized();
+        Continuation c;
+
+        c = Continuation.startWith(r); // suspend right away
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // resume and run into synchronized
+                                            // block where we suspend again
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // continue inside the synchronized
+                                            // block and suspend after
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+
+        c = Continuation.continueWith(c); // resume and then return
+        assertTrue(c == null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);
+    }
+
+    public void testStack() throws Exception {
+        assertTrue(fromSuite());
+        final Runnable r = new Stack();
+        final Continuation c = Continuation.startWith(r);
+        assertNull(c); // does not have a suspend
+    }
+
+    public void testNestedSynchronized() throws Exception {
+        final NestedSynchronized r = new NestedSynchronized();
+        Continuation c;
+
+        c = Continuation.startWith(r);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertFalse(r.b);
+        assertFalse(r.c);
+        assertFalse(r.d);
+        assertFalse(r.e);
+        assertFalse(r.f);
+        assertFalse(r.g);
+        assertFalse(r.h);
+        assertFalse(r.i);
+        assertFalse(r.j);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertFalse(r.f);
+        assertFalse(r.g);
+        assertFalse(r.h);
+        assertFalse(r.i);
+        assertFalse(r.j);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c != null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);
+        assertTrue(r.g);
+        assertTrue(r.h);
+        assertTrue(r.i);
+        assertFalse(r.j);
+
+        c = Continuation.continueWith(c);
+        assertTrue(c == null);
+        assertTrue(r.a);
+        assertTrue(r.b);
+        assertTrue(r.c);
+        assertTrue(r.d);
+        assertTrue(r.e);
+        assertTrue(r.f);
+        assertTrue(r.g);
+        assertTrue(r.h);
+        assertTrue(r.i);
+        assertTrue(r.j);
+    }
+
+    public void testASMRewriteBug() throws Exception {
+        RewriteBugs.calculateCartesianProduct(new String[] { "a", "b" },
+                new Object[][] { { "1", "2" }, { "3", "4" } });
+    }
 }