comparison jcstress-test-gen/src/main/resources/copy/X-ArraysCopyOfCopyingTest.java.template @ 398:2357daa047b7

Chapter 2.a: Copying (manual, clone, arraycopy, copyOf) tests.
author shade
date Tue, 28 Mar 2017 16:28:36 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:21d3c432bdc3
1 /*
2 * Copyright (c) 2017, Red Hat Inc. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package $package$;
26
27 import java.util.Arrays;
28 import org.openjdk.jcstress.annotations.*;
29 import org.openjdk.jcstress.infra.results.*;
30
31 #warn
32
33 /**
34 * Tests if arrays experience coherence failures.
35 */
36 @JCStressTest
37 #if[safe]
38 @Outcome(id = "true, 1, $default$", expect = Expect.FORBIDDEN, desc = "Seeing array, but not its contents.")
39 #else[safe]
40 @Outcome(id = "true, 1, $default$", expect = Expect.ACCEPTABLE, desc = "Seeing array, but not its contents.")
41 #end[safe]
42 #if[alwaysAtomic]
43 @Outcome(id = "true, 1, $set$", expect = Expect.ACCEPTABLE, desc = "Seeing the complete update.")
44 #else[alwaysAtomic]
45 @Outcome(id = "true, 1, .*", expect = Expect.ACCEPTABLE, desc = "Observing non-atomic write/read.")
46 #end[alwaysAtomic]
47 @State
48 public class $name$ {
49
50 static final $type$[] src;
51 static {
52 src = new $type$[1];
53 src[0] = $setLiteral$;
54 }
55
56 $modifier$$type$[] copy;
57
58 @Actor
59 public void actor1() {
60 copy = Arrays.copyOf(src, 1);
61 }
62
63 @Actor
64 public void actor2(ZI$T$_Result r) {
65 $type$[] t = copy;
66 if (t != null) {
67 r.r1 = (t.getClass() == $type$[].class);
68 r.r2 = t.length;
69 r.r3 = t[0];
70 } else {
71 r.r1 = true;
72 r.r2 = 1;
73 r.r3 = $setLiteral$;
74 }
75 }
76
77 }