view jcstress-test-gen/src/main/resources/accessAtomic/X-VarHandleHeapByteBufferViewAtomicityTest.java.template @ 385:6d05ba34c4e9

Remove ACCEPTABLE_SPEC, fold it to ACCEPTABLE_INTERESTING.
author shade
date Mon, 06 Mar 2017 18:15:37 +0100
parents c80cab9599e4
children adba8ecf2dba
line wrap: on
line source
/*
 * Copyright (c) 2016, Oracle and/or its affiliates. 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.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.nio.ByteOrder;
import java.nio.ByteBuffer;

import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.*;

#warn

/**
 * Tests if fields experience non-atomic reads/writes.
 */
@JCStressTest
@Outcome(id = "$default$", expect = Expect.ACCEPTABLE, desc = "Default value for the field. Allowed to see this: data race.")
@Outcome(id = "$set$", expect = Expect.ACCEPTABLE, desc = "The value set by the actor thread. Observer sees the complete update.")
#if[alwaysAtomic]
@Outcome(expect = Expect.FORBIDDEN, desc = "Other values are forbidden: atomicity violation.")
#else[alwaysAtomic]
@Outcome(expect = Expect.ACCEPTABLE_INTERESTING, desc = "Non-atomic access detected, allowed by spec")
@Ref("http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.7")
#end[alwaysAtomic]
@State
public class $name$ {

    static final VarHandle VH = MethodHandles.byteBufferViewVarHandle($type$[].class, ByteOrder.$byteOrder$);

    ByteBuffer buf = ByteBuffer.allocate(16);
    int off = buf.alignmentOffset(0, 8);

    @Actor
    public void actor1() {
        VH.$setOp$(buf, off, $setLiteral$);
    }

    @Actor
    public void actor2($Type$Result1 r) {
        r.r1 = ($type$)VH.$getOp$(buf, off);
    }

}