changeset 399:e7734808d954

Chapter 2.a: Add large arrays tests.
author shade
date Tue, 28 Mar 2017 18:18:57 +0200
parents 2357daa047b7
children 6eac1601ff7a
files jcstress-test-gen/src/main/java/org/openjdk/jcstress/chapters/Chapter2aTestGenerator.java jcstress-test-gen/src/main/resources/copy/X-ArrayCloneCopyingTest.java.template jcstress-test-gen/src/main/resources/copy/X-ArrayManualCopyingTest.java.template jcstress-test-gen/src/main/resources/copy/X-ArraycopyCopyingTest.java.template jcstress-test-gen/src/main/resources/copy/X-ArraysCopyOfCopyingTest.java.template jcstress-test-gen/src/main/resources/copy/X-ObjectCloneCopyingTest.java.template jcstress-test-gen/src/main/resources/copy/X-ObjectManualCopyingTest.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-Arraycopy.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-ArraysCopyOf.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-Clone.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-LargeArraycopy.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-LargeArraysCopyOf.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-LargeClone.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-LargeManual.java.template jcstress-test-gen/src/main/resources/copy/arrays/X-Manual.java.template jcstress-test-gen/src/main/resources/copy/objects/X-Clone.java.template jcstress-test-gen/src/main/resources/copy/objects/X-Manual.java.template
diffstat 17 files changed, 887 insertions(+), 489 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-test-gen/src/main/java/org/openjdk/jcstress/chapters/Chapter2aTestGenerator.java	Tue Mar 28 16:28:36 2017 +0200
+++ b/jcstress-test-gen/src/main/java/org/openjdk/jcstress/chapters/Chapter2aTestGenerator.java	Tue Mar 28 18:18:57 2017 +0200
@@ -47,43 +47,71 @@
 
         makeTests(
                 dest,
-                GeneratorUtils.readFromResource("/copy/X-ObjectCloneCopyingTest.java.template"),
+                GeneratorUtils.readFromResource("/copy/objects/X-Clone.java.template"),
                 "copy.clone.objects",
                 new String[]{ "", "volatile" }
         );
 
         makeTests(
                 dest,
-                GeneratorUtils.readFromResource("/copy/X-ObjectManualCopyingTest.java.template"),
+                GeneratorUtils.readFromResource("/copy/objects/X-Manual.java.template"),
                 "copy.manual.objects",
                 new String[]{ "", "volatile" }
         );
 
         makeTests(
                 dest,
-                GeneratorUtils.readFromResource("/copy/X-ArraysCopyOfCopyingTest.java.template"),
-                "copy.copyof.arrays",
+                GeneratorUtils.readFromResource("/copy/arrays/X-ArraysCopyOf.java.template"),
+                "copy.copyof.arrays.small",
                 new String[]{ "", "volatile" }
         );
 
         makeTests(
                 dest,
-                GeneratorUtils.readFromResource("/copy/X-ArraycopyCopyingTest.java.template"),
-                "copy.arraycopy.arrays",
+                GeneratorUtils.readFromResource("/copy/arrays/X-LargeArraysCopyOf.java.template"),
+                "copy.copyof.arrays.large",
                 new String[]{ "", "volatile" }
         );
 
         makeTests(
                 dest,
-                GeneratorUtils.readFromResource("/copy/X-ArrayCloneCopyingTest.java.template"),
-                "copy.clone.arrays",
+                GeneratorUtils.readFromResource("/copy/arrays/X-Arraycopy.java.template"),
+                "copy.arraycopy.arrays.small",
                 new String[]{ "", "volatile" }
         );
 
         makeTests(
                 dest,
-                GeneratorUtils.readFromResource("/copy/X-ArrayManualCopyingTest.java.template"),
-                "copy.manual.arrays",
+                GeneratorUtils.readFromResource("/copy/arrays/X-LargeArraycopy.java.template"),
+                "copy.arraycopy.arrays.large",
+                new String[]{ "", "volatile" }
+        );
+
+        makeTests(
+                dest,
+                GeneratorUtils.readFromResource("/copy/arrays/X-Clone.java.template"),
+                "copy.clone.arrays.small",
+                new String[]{ "", "volatile" }
+        );
+
+        makeTests(
+                dest,
+                GeneratorUtils.readFromResource("/copy/arrays/X-LargeClone.java.template"),
+                "copy.clone.arrays.large",
+                new String[]{ "", "volatile" }
+        );
+
+        makeTests(
+                dest,
+                GeneratorUtils.readFromResource("/copy/arrays/X-Manual.java.template"),
+                "copy.manual.arrays.small",
+                new String[]{ "", "volatile" }
+        );
+
+        makeTests(
+                dest,
+                GeneratorUtils.readFromResource("/copy/arrays/X-LargeManual.java.template"),
+                "copy.manual.arrays.large",
                 new String[]{ "", "volatile" }
         );
     }
--- a/jcstress-test-gen/src/main/resources/copy/X-ArrayCloneCopyingTest.java.template	Tue Mar 28 16:28:36 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2017, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package $package$;
-
-import java.util.Arrays;
-import org.openjdk.jcstress.annotations.*;
-import org.openjdk.jcstress.infra.results.*;
-
-#warn
-
-/**
- * Tests if arrays experience coherence failures.
- */
-@JCStressTest
-#if[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
-#else[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
-#end[safe]
-#if[alwaysAtomic]
-@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
-#else[alwaysAtomic]
-@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
-#end[alwaysAtomic]
-@State
-public class $name$ {
-
-    static final $type$[] src;
-    static {
-       src = new $type$[1];
-       src[0] = $setLiteral$;
-    }
-
-    $modifier$$type$[] copy;
-
-    @Actor
-    public void actor1() {
-        copy = src.clone();
-    }
-
-    @Actor
-    public void actor2(ZI$T$_Result r) {
-        $type$[] t = copy;
-        if (t != null) {
-          r.r1 = (t.getClass() == $type$[].class);
-          r.r2 = t.length;
-          r.r3 = t[0];
-        } else {
-          r.r1 = true;
-          r.r2 = 1;
-          r.r3 = $setLiteral$;
-        }
-    }
-
-}
--- a/jcstress-test-gen/src/main/resources/copy/X-ArrayManualCopyingTest.java.template	Tue Mar 28 16:28:36 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2017, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package $package$;
-
-import java.util.Arrays;
-import org.openjdk.jcstress.annotations.*;
-import org.openjdk.jcstress.infra.results.*;
-
-#warn
-
-/**
- * Tests if arrays experience coherence failures.
- */
-@JCStressTest
-#if[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
-#else[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
-#end[safe]
-#if[alwaysAtomic]
-@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
-#else[alwaysAtomic]
-@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
-#end[alwaysAtomic]
-@State
-public class $name$ {
-
-    static final $type$[] src;
-    static {
-       src = new $type$[1];
-       src[0] = $setLiteral$;
-    }
-
-    $modifier$$type$[] copy;
-
-    @Actor
-    public void actor1() {
-        $type$[] c = new $type$[1];
-        c[0] = src[0];
-        copy = c;
-    }
-
-    @Actor
-    public void actor2(ZI$T$_Result r) {
-        $type$[] t = copy;
-        if (t != null) {
-          r.r1 = (t.getClass() == $type$[].class);
-          r.r2 = t.length;
-          r.r3 = t[0];
-        } else {
-          r.r1 = true;
-          r.r2 = 1;
-          r.r3 = $setLiteral$;
-        }
-    }
-
-}
--- a/jcstress-test-gen/src/main/resources/copy/X-ArraycopyCopyingTest.java.template	Tue Mar 28 16:28:36 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2017, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package $package$;
-
-import java.util.Arrays;
-import org.openjdk.jcstress.annotations.*;
-import org.openjdk.jcstress.infra.results.*;
-
-#warn
-
-/**
- * Tests if arrays experience coherence failures.
- */
-@JCStressTest
-#if[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
-#else[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
-#end[safe]
-#if[alwaysAtomic]
-@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
-#else[alwaysAtomic]
-@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
-#end[alwaysAtomic]
-@State
-public class $name$ {
-
-    static final $type$[] src;
-    static {
-       src = new $type$[1];
-       src[0] = $setLiteral$;
-    }
-
-    $modifier$$type$[] copy;
-
-    @Actor
-    public void actor1() {
-        $type$[] c = new $type$[1];
-        System.arraycopy(src, 0, c, 0, 1);
-        copy = c;
-    }
-
-    @Actor
-    public void actor2(ZI$T$_Result r) {
-        $type$[] t = copy;
-        if (t != null) {
-          r.r1 = (t.getClass() == $type$[].class);
-          r.r2 = t.length;
-          r.r3 = t[0];
-        } else {
-          r.r1 = true;
-          r.r2 = 1;
-          r.r3 = $setLiteral$;
-        }
-    }
-
-}
--- a/jcstress-test-gen/src/main/resources/copy/X-ArraysCopyOfCopyingTest.java.template	Tue Mar 28 16:28:36 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2017, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package $package$;
-
-import java.util.Arrays;
-import org.openjdk.jcstress.annotations.*;
-import org.openjdk.jcstress.infra.results.*;
-
-#warn
-
-/**
- * Tests if arrays experience coherence failures.
- */
-@JCStressTest
-#if[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
-#else[safe]
-@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
-#end[safe]
-#if[alwaysAtomic]
-@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
-#else[alwaysAtomic]
-@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
-#end[alwaysAtomic]
-@State
-public class $name$ {
-
-    static final $type$[] src;
-    static {
-       src = new $type$[1];
-       src[0] = $setLiteral$;
-    }
-
-    $modifier$$type$[] copy;
-
-    @Actor
-    public void actor1() {
-        copy = Arrays.copyOf(src, 1);
-    }
-
-    @Actor
-    public void actor2(ZI$T$_Result r) {
-        $type$[] t = copy;
-        if (t != null) {
-          r.r1 = (t.getClass() == $type$[].class);
-          r.r2 = t.length;
-          r.r3 = t[0];
-        } else {
-          r.r1 = true;
-          r.r2 = 1;
-          r.r3 = $setLiteral$;
-        }
-    }
-
-}
--- a/jcstress-test-gen/src/main/resources/copy/X-ObjectCloneCopyingTest.java.template	Tue Mar 28 16:28:36 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2017, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package $package$;
-
-import java.util.Arrays;
-import org.openjdk.jcstress.annotations.*;
-import org.openjdk.jcstress.infra.results.*;
-
-#warn
-
-/**
- * Tests if arrays experience coherence failures.
- */
-@JCStressTest
-#if[safe]
-@Outcome(id = "$default$", expect = Expect.FORBIDDEN, desc = "Seeing object, but not its contents.")
-#else[safe]
-@Outcome(id = "$default$", expect = Expect.ACCEPTABLE, desc = "Seeing object, but not its contents.")
-#end[safe]
-#if[alwaysAtomic]
-@Outcome(id = "$set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
-#else[alwaysAtomic]
-@Outcome(id = ".*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
-#end[alwaysAtomic]
-@State
-public class $name$ {
-
-    static class Data implements Cloneable {
-        $type$ f;
-
-        @Override
-        public Data clone() throws CloneNotSupportedException {
-            return (Data)super.clone();
-        }
-    }
-
-    static final Data src;
-
-    static {
-        src = new Data();
-        src.f = $setLiteral$;
-    }
-
-    $modifier$ Data copy;
-
-    @Actor
-    public void actor1() {
-        try {
-            copy = src.clone();
-        } catch (Exception e) {
-            // okay
-        }
-    }
-
-    @Actor
-    public void actor2($T$_Result r) {
-        Data d = copy;
-        if (d != null) {
-          r.r1 = d.f;
-        } else {
-          r.r1 = $setLiteral$;
-        }
-    }
-
-}
--- a/jcstress-test-gen/src/main/resources/copy/X-ObjectManualCopyingTest.java.template	Tue Mar 28 16:28:36 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2017, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package $package$;
-
-import java.util.Arrays;
-import org.openjdk.jcstress.annotations.*;
-import org.openjdk.jcstress.infra.results.*;
-
-#warn
-
-/**
- * Tests if arrays experience coherence failures.
- */
-@JCStressTest
-#if[safe]
-@Outcome(id = "$default$", expect = Expect.FORBIDDEN, desc = "Seeing object, but not its contents.")
-#else[safe]
-@Outcome(id = "$default$", expect = Expect.ACCEPTABLE, desc = "Seeing object, but not its contents.")
-#end[safe]
-#if[alwaysAtomic]
-@Outcome(id = "$set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
-#else[alwaysAtomic]
-@Outcome(id = ".*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
-#end[alwaysAtomic]
-@State
-public class $name$ {
-
-    static class Data implements Cloneable {
-        $type$ f;
-    }
-
-    static final Data src;
-
-    static {
-        src = new Data();
-        src.f = $setLiteral$;
-    }
-
-    $modifier$ Data copy;
-
-    @Actor
-    public void actor1() {
-        Data d = new Data();
-        d.f = src.f;
-        copy = d;
-    }
-
-    @Actor
-    public void actor2($T$_Result r) {
-        Data d = copy;
-        if (d != null) {
-          r.r1 = d.f;
-        } else {
-          r.r1 = $setLiteral$;
-        }
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-Arraycopy.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+#if[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
+#else[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
+#end[safe]
+#if[alwaysAtomic]
+@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
+#else[alwaysAtomic]
+@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
+#end[alwaysAtomic]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[1];
+       src[0] = $setLiteral$;
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        $type$[] c = new $type$[1];
+        System.arraycopy(src, 0, c, 0, 1);
+        copy = c;
+    }
+
+    @Actor
+    public void actor2(ZI$T$_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          r.r3 = t[0];
+        } else {
+          r.r1 = true;
+          r.r2 = 1;
+          r.r3 = $setLiteral$;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-ArraysCopyOf.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+#if[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
+#else[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
+#end[safe]
+#if[alwaysAtomic]
+@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
+#else[alwaysAtomic]
+@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
+#end[alwaysAtomic]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[1];
+       src[0] = $setLiteral$;
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        copy = Arrays.copyOf(src, 1);
+    }
+
+    @Actor
+    public void actor2(ZI$T$_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          r.r3 = t[0];
+        } else {
+          r.r1 = true;
+          r.r2 = 1;
+          r.r3 = $setLiteral$;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-Clone.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+#if[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
+#else[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
+#end[safe]
+#if[alwaysAtomic]
+@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
+#else[alwaysAtomic]
+@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
+#end[alwaysAtomic]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[1];
+       src[0] = $setLiteral$;
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        copy = src.clone();
+    }
+
+    @Actor
+    public void actor2(ZI$T$_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          r.r3 = t[0];
+        } else {
+          r.r1 = true;
+          r.r2 = 1;
+          r.r3 = $setLiteral$;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-LargeArraycopy.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+@Outcome(id = "true, 2097152, 0", expect = Expect.ACCEPTABLE,  desc = "Seeing array with all elements set.")
+#if[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are weird")
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are weird")
+#if[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default/weird")
+#end[alwaysAtomic]
+#end[safe]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[2 * 1024 * 1024];
+       for (int c = 0; c < src.length; c++) {
+         src[c] = $setLiteral$;
+       }
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        $type$[] c = new $type$[2097152];
+        System.arraycopy(src, 0, c, 0, 2097152);
+        copy = c;
+    }
+
+    @Actor
+    public void actor2(ZII_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          boolean hasDefaults = false;
+          boolean hasWeird = false;
+          for ($type$ c : t) {
+            boolean set = (c == $setLiteral$);
+            boolean def = (c == $defaultLiteral$);
+            hasDefaults |= def;
+            hasWeird |= !def && !set;
+          }
+          r.r3 = (hasDefaults ? 1 : 0) + (hasWeird ? 2 : 0);
+        } else {
+          r.r1 = true;
+          r.r2 = 2097152;
+          r.r3 = 0;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-LargeArraysCopyOf.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+@Outcome(id = "true, 2097152, 0", expect = Expect.ACCEPTABLE,  desc = "Seeing array with all elements set.")
+#if[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are weird")
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are weird")
+#if[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default/weird")
+#end[alwaysAtomic]
+#end[safe]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[2 * 1024 * 1024];
+       for (int c = 0; c < src.length; c++) {
+         src[c] = $setLiteral$;
+       }
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        copy = Arrays.copyOf(src, 2097152);
+    }
+
+    @Actor
+    public void actor2(ZII_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          boolean hasDefaults = false;
+          boolean hasWeird = false;
+          for ($type$ c : t) {
+            boolean set = (c == $setLiteral$);
+            boolean def = (c == $defaultLiteral$);
+            hasDefaults |= def;
+            hasWeird |= !def && !set;
+          }
+          r.r3 = (hasDefaults ? 1 : 0) + (hasWeird ? 2 : 0);
+        } else {
+          r.r1 = true;
+          r.r2 = 2097152;
+          r.r3 = 0;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-LargeClone.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+@Outcome(id = "true, 2097152, 0", expect = Expect.ACCEPTABLE,  desc = "Seeing array with all elements set.")
+#if[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are weird")
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are weird")
+#if[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default/weird")
+#end[alwaysAtomic]
+#end[safe]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[2 * 1024 * 1024];
+       for (int c = 0; c < src.length; c++) {
+         src[c] = $setLiteral$;
+       }
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        copy = src.clone();
+    }
+
+    @Actor
+    public void actor2(ZII_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          boolean hasDefaults = false;
+          boolean hasWeird = false;
+          for ($type$ c : t) {
+            boolean set = (c == $setLiteral$);
+            boolean def = (c == $defaultLiteral$);
+            hasDefaults |= def;
+            hasWeird |= !def && !set;
+          }
+          r.r3 = (hasDefaults ? 1 : 0) + (hasWeird ? 2 : 0);
+        } else {
+          r.r1 = true;
+          r.r2 = 2097152;
+          r.r3 = 0;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-LargeManual.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+@Outcome(id = "true, 2097152, 0", expect = Expect.ACCEPTABLE,  desc = "Seeing array with all elements set.")
+#if[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are weird")
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[safe]
+@Outcome(id = "true, 2097152, 1", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default")
+@Outcome(id = "true, 2097152, 2", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are weird")
+#if[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.FORBIDDEN,   desc = "Seeing array, but some contents are default/weird")
+#else[alwaysAtomic]
+@Outcome(id = "true, 2097152, 3", expect = Expect.ACCEPTABLE,  desc = "Seeing array, but some contents are default/weird")
+#end[alwaysAtomic]
+#end[safe]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[2 * 1024 * 1024];
+       for (int c = 0; c < src.length; c++) {
+         src[c] = $setLiteral$;
+       }
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        $type$[] c = new $type$[2097152];
+        for (int t = 0; t < src.length; t++) {
+           c[t] = src[t];
+        }
+        copy = c;
+    }
+
+    @Actor
+    public void actor2(ZII_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          boolean hasDefaults = false;
+          boolean hasWeird = false;
+          for ($type$ c : t) {
+            boolean set = (c == $setLiteral$);
+            boolean def = (c == $defaultLiteral$);
+            hasDefaults |= def;
+            hasWeird |= !def && !set;
+          }
+          r.r3 = (hasDefaults ? 1 : 0) + (hasWeird ? 2 : 0);
+        } else {
+          r.r1 = true;
+          r.r2 = 2097152;
+          r.r3 = 0;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/arrays/X-Manual.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+#if[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
+#else[safe]
+@Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
+#end[safe]
+#if[alwaysAtomic]
+@Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
+#else[alwaysAtomic]
+@Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
+#end[alwaysAtomic]
+@State
+public class $name$ {
+
+    static final $type$[] src;
+    static {
+       src = new $type$[1];
+       src[0] = $setLiteral$;
+    }
+
+    $modifier$$type$[] copy;
+
+    @Actor
+    public void actor1() {
+        $type$[] c = new $type$[1];
+        c[0] = src[0];
+        copy = c;
+    }
+
+    @Actor
+    public void actor2(ZI$T$_Result r) {
+        $type$[] t = copy;
+        if (t != null) {
+          r.r1 = (t.getClass() == $type$[].class);
+          r.r2 = t.length;
+          r.r3 = t[0];
+        } else {
+          r.r1 = true;
+          r.r2 = 1;
+          r.r3 = $setLiteral$;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/objects/X-Clone.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+#if[safe]
+@Outcome(id = "$default$", expect = Expect.FORBIDDEN, desc = "Seeing object, but not its contents.")
+#else[safe]
+@Outcome(id = "$default$", expect = Expect.ACCEPTABLE, desc = "Seeing object, but not its contents.")
+#end[safe]
+#if[alwaysAtomic]
+@Outcome(id = "$set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
+#else[alwaysAtomic]
+@Outcome(id = ".*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
+#end[alwaysAtomic]
+@State
+public class $name$ {
+
+    static class Data implements Cloneable {
+        $type$ f;
+
+        @Override
+        public Data clone() throws CloneNotSupportedException {
+            return (Data)super.clone();
+        }
+    }
+
+    static final Data src;
+
+    static {
+        src = new Data();
+        src.f = $setLiteral$;
+    }
+
+    $modifier$ Data copy;
+
+    @Actor
+    public void actor1() {
+        try {
+            copy = src.clone();
+        } catch (Exception e) {
+            // okay
+        }
+    }
+
+    @Actor
+    public void actor2($T$_Result r) {
+        Data d = copy;
+        if (d != null) {
+          r.r1 = d.f;
+        } else {
+          r.r1 = $setLiteral$;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jcstress-test-gen/src/main/resources/copy/objects/X-Manual.java.template	Tue Mar 28 18:18:57 2017 +0200
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package $package$;
+
+import java.util.Arrays;
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.*;
+
+#warn
+
+/**
+ * Tests if arrays experience coherence failures.
+ */
+@JCStressTest
+#if[safe]
+@Outcome(id = "$default$", expect = Expect.FORBIDDEN, desc = "Seeing object, but not its contents.")
+#else[safe]
+@Outcome(id = "$default$", expect = Expect.ACCEPTABLE, desc = "Seeing object, but not its contents.")
+#end[safe]
+#if[alwaysAtomic]
+@Outcome(id = "$set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
+#else[alwaysAtomic]
+@Outcome(id = ".*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
+#end[alwaysAtomic]
+@State
+public class $name$ {
+
+    static class Data implements Cloneable {
+        $type$ f;
+    }
+
+    static final Data src;
+
+    static {
+        src = new Data();
+        src.f = $setLiteral$;
+    }
+
+    $modifier$ Data copy;
+
+    @Actor
+    public void actor1() {
+        Data d = new Data();
+        d.f = src.f;
+        copy = d;
+    }
+
+    @Actor
+    public void actor2($T$_Result r) {
+        Data d = copy;
+        if (d != null) {
+          r.r1 = d.f;
+        } else {
+          r.r1 = $setLiteral$;
+        }
+    }
+
+}