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