src/java.base/share/classes/java/lang/invoke/VarHandle.java
author prappo
Wed, 30 Jan 2019 00:24:32 +0000
changeset 53563 a4b7ea85d668
parent 53284 a995647f4911
child 54206 003cc64366da
permissions -rw-r--r--
8218022: Repeated words typos in java.base Reviewed-by: alanb, lancea, mchung Contributed-by: Andrey Turbanov <turbanoff@gmail.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     1
/*
53284
a995647f4911 8215648: remove equals and hashCode implementations from j.l.i.VarHandle
vromero
parents: 53019
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     4
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    10
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    15
 * accompanied this code).
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    16
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    20
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    23
 * questions.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    24
 */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    25
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    26
package java.lang.invoke;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    27
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    28
import java.lang.constant.ClassDesc;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    29
import java.lang.constant.Constable;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    30
import java.lang.constant.ConstantDesc;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    31
import java.lang.constant.ConstantDescs;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    32
import java.lang.constant.DirectMethodHandleDesc;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    33
import java.lang.constant.DynamicConstantDesc;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    34
import java.util.HashMap;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    35
import java.util.List;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    36
import java.util.Map;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    37
import java.util.Objects;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    38
import java.util.Optional;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    39
import java.util.function.BiFunction;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    40
import java.util.function.Function;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
    41
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    42
import jdk.internal.HotSpotIntrinsicCandidate;
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 37345
diff changeset
    43
import jdk.internal.util.Preconditions;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    44
import jdk.internal.vm.annotation.ForceInline;
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
    45
import jdk.internal.vm.annotation.Stable;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    46
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    47
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    48
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    49
/**
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    50
 * A VarHandle is a dynamically strongly typed reference to a variable, or to a
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    51
 * parametrically-defined family of variables, including static fields,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    52
 * non-static fields, array elements, or components of an off-heap data
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    53
 * structure.  Access to such variables is supported under various
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    54
 * <em>access modes</em>, including plain read/write access, volatile
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
    55
 * read/write access, and compare-and-set.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    56
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    57
 * <p>VarHandles are immutable and have no visible state.  VarHandles cannot be
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    58
 * subclassed by the user.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    59
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    60
 * <p>A VarHandle has:
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    61
 * <ul>
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    62
 * <li>a {@link #varType variable type} T, the type of every variable referenced
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    63
 * by this VarHandle; and
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    64
 * <li>a list of {@link #coordinateTypes coordinate types}
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    65
 * {@code CT1, CT2, ..., CTn}, the types of <em>coordinate expressions</em> that
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    66
 * jointly locate a variable referenced by this VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    67
 * </ul>
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    68
 * Variable and coordinate types may be primitive or reference, and are
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    69
 * represented by {@code Class} objects.  The list of coordinate types may be
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    70
 * empty.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    71
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    72
 * <p>Factory methods that produce or {@link java.lang.invoke.MethodHandles.Lookup
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    73
 * lookup} VarHandle instances document the supported variable type and the list
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    74
 * of coordinate types.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    75
 *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    76
 * <p>Each access mode is associated with one <em>access mode method</em>, a
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    77
 * <a href="MethodHandle.html#sigpoly">signature polymorphic</a> method named
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    78
 * for the access mode.  When an access mode method is invoked on a VarHandle
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    79
 * instance, the initial arguments to the invocation are coordinate expressions
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    80
 * that indicate in precisely which object the variable is to be accessed.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    81
 * Trailing arguments to the invocation represent values of importance to the
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    82
 * access mode.  For example, the various compare-and-set or compare-and-exchange
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    83
 * access modes require two trailing arguments for the variable's expected value
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    84
 * and new value.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    85
 *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    86
 * <p>The arity and types of arguments to the invocation of an access mode
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    87
 * method are not checked statically.  Instead, each access mode method
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    88
 * specifies an {@link #accessModeType(AccessMode) access mode type},
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    89
 * represented as an instance of {@link MethodType}, that serves as a kind of
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    90
 * method signature against which the arguments are checked dynamically.  An
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    91
 * access mode type gives formal parameter types in terms of the coordinate
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    92
 * types of a VarHandle instance and the types for values of importance to the
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    93
 * access mode.  An access mode type also gives a return type, often in terms of
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    94
 * the variable type of a VarHandle instance.  When an access mode method is
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    95
 * invoked on a VarHandle instance, the symbolic type descriptor at the
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    96
 * call site, the run time types of arguments to the invocation, and the run
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    97
 * time type of the return value, must <a href="#invoke">match</a> the types
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    98
 * given in the access mode type.  A runtime exception will be thrown if the
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
    99
 * match fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   100
 *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   101
 * For example, the access mode method {@link #compareAndSet} specifies that if
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   102
 * its receiver is a VarHandle instance with coordinate types
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   103
 * {@code CT1, ..., CTn} and variable type {@code T}, then its access mode type
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   104
 * is {@code (CT1 c1, ..., CTn cn, T expectedValue, T newValue)boolean}.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   105
 * Suppose that a VarHandle instance can access array elements, and that its
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   106
 * coordinate types are {@code String[]} and {@code int} while its variable type
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   107
 * is {@code String}.  The access mode type for {@code compareAndSet} on this
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   108
 * VarHandle instance would be
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   109
 * {@code (String[] c1, int c2, String expectedValue, String newValue)boolean}.
51986
c1db377f6300 8200381: Typos in javadoc - missing verb "be" and alike
igerasim
parents: 49546
diff changeset
   110
 * Such a VarHandle instance may be produced by the
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   111
 * {@link MethodHandles#arrayElementVarHandle(Class) array factory method} and
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   112
 * access array elements as follows:
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   113
 * <pre> {@code
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   114
 * String[] sa = ...
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   115
 * VarHandle avh = MethodHandles.arrayElementVarHandle(String[].class);
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   116
 * boolean r = avh.compareAndSet(sa, 10, "expected", "new");
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   117
 * }</pre>
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   118
 *
45637
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   119
 * <p>Access modes control atomicity and consistency properties.
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   120
 * <em>Plain</em> read ({@code get}) and write ({@code set})
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   121
 * accesses are guaranteed to be bitwise atomic only for references
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   122
 * and for primitive values of at most 32 bits, and impose no observable
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   123
 * ordering constraints with respect to threads other than the
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   124
 * executing thread. <em>Opaque</em> operations are bitwise atomic and
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   125
 * coherently ordered with respect to accesses to the same variable.
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   126
 * In addition to obeying Opaque properties, <em>Acquire</em> mode
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   127
 * reads and their subsequent accesses are ordered after matching
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   128
 * <em>Release</em> mode writes and their previous accesses.  In
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   129
 * addition to obeying Acquire and Release properties, all
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   130
 * <em>Volatile</em> operations are totally ordered with respect to
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   131
 * each other.
9e0c80381e32 8181104: Fix specs for updateAndGet and related methods
dl
parents: 44860
diff changeset
   132
 *
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   133
 * <p>Access modes are grouped into the following categories:
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   134
 * <ul>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   135
 * <li>read access modes that get the value of a variable under specified
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   136
 * memory ordering effects.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   137
 * The set of corresponding access mode methods belonging to this group
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   138
 * consists of the methods
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   139
 * {@link #get get},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   140
 * {@link #getVolatile getVolatile},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   141
 * {@link #getAcquire getAcquire},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   142
 * {@link #getOpaque getOpaque}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   143
 * <li>write access modes that set the value of a variable under specified
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   144
 * memory ordering effects.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   145
 * The set of corresponding access mode methods belonging to this group
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   146
 * consists of the methods
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   147
 * {@link #set set},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   148
 * {@link #setVolatile setVolatile},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   149
 * {@link #setRelease setRelease},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   150
 * {@link #setOpaque setOpaque}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   151
 * <li>atomic update access modes that, for example, atomically compare and set
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   152
 * the value of a variable under specified memory ordering effects.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   153
 * The set of corresponding access mode methods belonging to this group
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   154
 * consists of the methods
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   155
 * {@link #compareAndSet compareAndSet},
40734
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
   156
 * {@link #weakCompareAndSetPlain weakCompareAndSetPlain},
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   157
 * {@link #weakCompareAndSet weakCompareAndSet},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   158
 * {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   159
 * {@link #weakCompareAndSetRelease weakCompareAndSetRelease},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   160
 * {@link #compareAndExchangeAcquire compareAndExchangeAcquire},
39472
6df82f4c63ac 8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents: 38368
diff changeset
   161
 * {@link #compareAndExchange compareAndExchange},
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   162
 * {@link #compareAndExchangeRelease compareAndExchangeRelease},
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   163
 * {@link #getAndSet getAndSet},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   164
 * {@link #getAndSetAcquire getAndSetAcquire},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   165
 * {@link #getAndSetRelease getAndSetRelease}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   166
 * <li>numeric atomic update access modes that, for example, atomically get and
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   167
 * set with addition the value of a variable under specified memory ordering
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   168
 * effects.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   169
 * The set of corresponding access mode methods belonging to this group
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   170
 * consists of the methods
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   171
 * {@link #getAndAdd getAndAdd},
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   172
 * {@link #getAndAddAcquire getAndAddAcquire},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   173
 * {@link #getAndAddRelease getAndAddRelease},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   174
 * <li>bitwise atomic update access modes that, for example, atomically get and
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   175
 * bitwise OR the value of a variable under specified memory ordering
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   176
 * effects.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   177
 * The set of corresponding access mode methods belonging to this group
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   178
 * consists of the methods
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   179
 * {@link #getAndBitwiseOr getAndBitwiseOr},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   180
 * {@link #getAndBitwiseOrAcquire getAndBitwiseOrAcquire},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   181
 * {@link #getAndBitwiseOrRelease getAndBitwiseOrRelease},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   182
 * {@link #getAndBitwiseAnd getAndBitwiseAnd},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   183
 * {@link #getAndBitwiseAndAcquire getAndBitwiseAndAcquire},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   184
 * {@link #getAndBitwiseAndRelease getAndBitwiseAndRelease},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   185
 * {@link #getAndBitwiseXor getAndBitwiseXor},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   186
 * {@link #getAndBitwiseXorAcquire getAndBitwiseXorAcquire},
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   187
 * {@link #getAndBitwiseXorRelease getAndBitwiseXorRelease}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   188
 * </ul>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   189
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   190
 * <p>Factory methods that produce or {@link java.lang.invoke.MethodHandles.Lookup
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   191
 * lookup} VarHandle instances document the set of access modes that are
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   192
 * supported, which may also include documenting restrictions based on the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   193
 * variable type and whether a variable is read-only.  If an access mode is not
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   194
 * supported then the corresponding access mode method will on invocation throw
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   195
 * an {@code UnsupportedOperationException}.  Factory methods should document
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   196
 * any additional undeclared exceptions that may be thrown by access mode
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   197
 * methods.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   198
 * The {@link #get get} access mode is supported for all
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   199
 * VarHandle instances and the corresponding method never throws
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   200
 * {@code UnsupportedOperationException}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   201
 * If a VarHandle references a read-only variable (for example a {@code final}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   202
 * field) then write, atomic update, numeric atomic update, and bitwise atomic
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
   203
 * update access modes are not supported and corresponding methods throw
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   204
 * {@code UnsupportedOperationException}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   205
 * Read/write access modes (if supported), with the exception of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   206
 * {@code get} and {@code set}, provide atomic access for
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   207
 * reference types and all primitive types.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   208
 * Unless stated otherwise in the documentation of a factory method, the access
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   209
 * modes {@code get} and {@code set} (if supported) provide atomic access for
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   210
 * reference types and all primitives types, with the exception of {@code long}
37344
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   211
 * and {@code double} on 32-bit platforms.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   212
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   213
 * <p>Access modes will override any memory ordering effects specified at
47478
438e0c9f2f17 8190382: fix small typographic errors in comments
smarks
parents: 47216
diff changeset
   214
 * the declaration site of a variable.  For example, a VarHandle accessing
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   215
 * a field using the {@code get} access mode will access the field as
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   216
 * specified <em>by its access mode</em> even if that field is declared
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   217
 * {@code volatile}.  When mixed access is performed extreme care should be
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   218
 * taken since the Java Memory Model may permit surprising results.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   219
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   220
 * <p>In addition to supporting access to variables under various access modes,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   221
 * a set of static methods, referred to as memory fence methods, is also
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   222
 * provided for fine-grained control of memory ordering.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   223
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   224
 * The Java Language Specification permits other threads to observe operations
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   225
 * as if they were executed in orders different than are apparent in program
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   226
 * source code, subject to constraints arising, for example, from the use of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   227
 * locks, {@code volatile} fields or VarHandles.  The static methods,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   228
 * {@link #fullFence fullFence}, {@link #acquireFence acquireFence},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   229
 * {@link #releaseFence releaseFence}, {@link #loadLoadFence loadLoadFence} and
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   230
 * {@link #storeStoreFence storeStoreFence}, can also be used to impose
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   231
 * constraints.  Their specifications, as is the case for certain access modes,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   232
 * are phrased in terms of the lack of "reorderings" -- observable ordering
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   233
 * effects that might otherwise occur if the fence was not present.  More
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   234
 * precise phrasing of the specification of access mode methods and memory fence
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   235
 * methods may accompany future updates of the Java Language Specification.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   236
 *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   237
 * <h1>Compiling invocation of access mode methods</h1>
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   238
 * A Java method call expression naming an access mode method can invoke a
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   239
 * VarHandle from Java source code.  From the viewpoint of source code, these
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   240
 * methods can take any arguments and their polymorphic result (if expressed)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   241
 * can be cast to any return type.  Formally this is accomplished by giving the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   242
 * access mode methods variable arity {@code Object} arguments and
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   243
 * {@code Object} return types (if the return type is polymorphic), but they
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   244
 * have an additional quality called <em>signature polymorphism</em> which
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   245
 * connects this freedom of invocation directly to the JVM execution stack.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   246
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   247
 * As is usual with virtual methods, source-level calls to access mode methods
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   248
 * compile to an {@code invokevirtual} instruction.  More unusually, the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   249
 * compiler must record the actual argument types, and may not perform method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   250
 * invocation conversions on the arguments.  Instead, it must generate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   251
 * instructions to push them on the stack according to their own unconverted
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   252
 * types.  The VarHandle object itself will be pushed on the stack before the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   253
 * arguments.  The compiler then generates an {@code invokevirtual} instruction
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   254
 * that invokes the access mode method with a symbolic type descriptor which
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   255
 * describes the argument and return types.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   256
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   257
 * To issue a complete symbolic type descriptor, the compiler must also
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   258
 * determine the return type (if polymorphic).  This is based on a cast on the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   259
 * method invocation expression, if there is one, or else {@code Object} if the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   260
 * invocation is an expression, or else {@code void} if the invocation is a
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   261
 * statement.  The cast may be to a primitive type (but not {@code void}).
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   262
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   263
 * As a corner case, an uncasted {@code null} argument is given a symbolic type
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   264
 * descriptor of {@code java.lang.Void}.  The ambiguity with the type
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   265
 * {@code Void} is harmless, since there are no references of type {@code Void}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   266
 * except the null reference.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   267
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   268
 *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   269
 * <h1><a id="invoke">Performing invocation of access mode methods</a></h1>
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   270
 * The first time an {@code invokevirtual} instruction is executed it is linked
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   271
 * by symbolically resolving the names in the instruction and verifying that
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   272
 * the method call is statically legal.  This also holds for calls to access mode
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   273
 * methods.  In this case, the symbolic type descriptor emitted by the compiler
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   274
 * is checked for correct syntax, and names it contains are resolved.  Thus, an
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   275
 * {@code invokevirtual} instruction which invokes an access mode method will
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   276
 * always link, as long as the symbolic type descriptor is syntactically
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   277
 * well-formed and the types exist.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   278
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   279
 * When the {@code invokevirtual} is executed after linking, the receiving
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   280
 * VarHandle's access mode type is first checked by the JVM to ensure that it
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   281
 * matches the symbolic type descriptor.  If the type
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   282
 * match fails, it means that the access mode method which the caller is
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   283
 * invoking is not present on the individual VarHandle being invoked.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   284
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   285
 * <p>
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   286
 * Invocation of an access mode method behaves as if an invocation of
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   287
 * {@link MethodHandle#invoke}, where the receiving method handle accepts the
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   288
 * VarHandle instance as the leading argument.  More specifically, the
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   289
 * following, where {@code {access-mode}} corresponds to the access mode method
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   290
 * name:
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   291
 * <pre> {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   292
 * VarHandle vh = ..
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   293
 * R r = (R) vh.{access-mode}(p1, p2, ..., pN);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   294
 * }</pre>
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   295
 * behaves as if:
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   296
 * <pre> {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   297
 * VarHandle vh = ..
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   298
 * VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}");
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   299
 * MethodHandle mh = MethodHandles.varHandleExactInvoker(
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   300
 *                       am,
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   301
 *                       vh.accessModeType(am));
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   302
 *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   303
 * R r = (R) mh.invoke(vh, p1, p2, ..., pN)
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   304
 * }</pre>
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   305
 * (modulo access mode methods do not declare throwing of {@code Throwable}).
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   306
 * This is equivalent to:
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   307
 * <pre> {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   308
 * MethodHandle mh = MethodHandles.lookup().findVirtual(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   309
 *                       VarHandle.class,
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   310
 *                       "{access-mode}",
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   311
 *                       MethodType.methodType(R, p1, p2, ..., pN));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   312
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   313
 * R r = (R) mh.invokeExact(vh, p1, p2, ..., pN)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   314
 * }</pre>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   315
 * where the desired method type is the symbolic type descriptor and a
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   316
 * {@link MethodHandle#invokeExact} is performed, since before invocation of the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   317
 * target, the handle will apply reference casts as necessary and box, unbox, or
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   318
 * widen primitive values, as if by {@link MethodHandle#asType asType} (see also
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   319
 * {@link MethodHandles#varHandleInvoker}).
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   320
 *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   321
 * More concisely, such behaviour is equivalent to:
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   322
 * <pre> {@code
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   323
 * VarHandle vh = ..
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   324
 * VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}");
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   325
 * MethodHandle mh = vh.toMethodHandle(am);
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   326
 *
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   327
 * R r = (R) mh.invoke(p1, p2, ..., pN)
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   328
 * }</pre>
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   329
 * Where, in this case, the method handle is bound to the VarHandle instance.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   330
 *
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   331
 *
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   332
 * <h1>Invocation checking</h1>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   333
 * In typical programs, VarHandle access mode type matching will usually
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   334
 * succeed.  But if a match fails, the JVM will throw a
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   335
 * {@link WrongMethodTypeException}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   336
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   337
 * Thus, an access mode type mismatch which might show up as a linkage error
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   338
 * in a statically typed program can show up as a dynamic
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   339
 * {@code WrongMethodTypeException} in a program which uses VarHandles.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   340
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   341
 * Because access mode types contain "live" {@code Class} objects, method type
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   342
 * matching takes into account both type names and class loaders.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   343
 * Thus, even if a VarHandle {@code VH} is created in one class loader
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   344
 * {@code L1} and used in another {@code L2}, VarHandle access mode method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   345
 * calls are type-safe, because the caller's symbolic type descriptor, as
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   346
 * resolved in {@code L2}, is matched against the original callee method's
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   347
 * symbolic type descriptor, as resolved in {@code L1}.  The resolution in
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   348
 * {@code L1} happens when {@code VH} is created and its access mode types are
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   349
 * assigned, while the resolution in {@code L2} happens when the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   350
 * {@code invokevirtual} instruction is linked.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   351
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   352
 * Apart from type descriptor checks, a VarHandles's capability to
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   353
 * access it's variables is unrestricted.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   354
 * If a VarHandle is formed on a non-public variable by a class that has access
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   355
 * to that variable, the resulting VarHandle can be used in any place by any
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   356
 * caller who receives a reference to it.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   357
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   358
 * Unlike with the Core Reflection API, where access is checked every time a
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   359
 * reflective method is invoked, VarHandle access checking is performed
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   360
 * <a href="MethodHandles.Lookup.html#access">when the VarHandle is
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   361
 * created</a>.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   362
 * Thus, VarHandles to non-public variables, or to variables in non-public
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   363
 * classes, should generally be kept secret.  They should not be passed to
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   364
 * untrusted code unless their use from the untrusted code would be harmless.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   365
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   366
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   367
 * <h1>VarHandle creation</h1>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   368
 * Java code can create a VarHandle that directly accesses any field that is
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   369
 * accessible to that code.  This is done via a reflective, capability-based
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   370
 * API called {@link java.lang.invoke.MethodHandles.Lookup
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   371
 * MethodHandles.Lookup}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   372
 * For example, a VarHandle for a non-static field can be obtained
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   373
 * from {@link java.lang.invoke.MethodHandles.Lookup#findVarHandle
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   374
 * Lookup.findVarHandle}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   375
 * There is also a conversion method from Core Reflection API objects,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   376
 * {@link java.lang.invoke.MethodHandles.Lookup#unreflectVarHandle
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   377
 * Lookup.unreflectVarHandle}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   378
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   379
 * Access to protected field members is restricted to receivers only of the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   380
 * accessing class, or one of its subclasses, and the accessing class must in
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   381
 * turn be a subclass (or package sibling) of the protected member's defining
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   382
 * class.  If a VarHandle refers to a protected non-static field of a declaring
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   383
 * class outside the current package, the receiver argument will be narrowed to
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   384
 * the type of the accessing class.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   385
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   386
 * <h1>Interoperation between VarHandles and the Core Reflection API</h1>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   387
 * Using factory methods in the {@link java.lang.invoke.MethodHandles.Lookup
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   388
 * Lookup} API, any field represented by a Core Reflection API object
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   389
 * can be converted to a behaviorally equivalent VarHandle.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   390
 * For example, a reflective {@link java.lang.reflect.Field Field} can
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   391
 * be converted to a VarHandle using
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   392
 * {@link java.lang.invoke.MethodHandles.Lookup#unreflectVarHandle
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   393
 * Lookup.unreflectVarHandle}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   394
 * The resulting VarHandles generally provide more direct and efficient
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   395
 * access to the underlying fields.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   396
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   397
 * As a special case, when the Core Reflection API is used to view the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   398
 * signature polymorphic access mode methods in this class, they appear as
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   399
 * ordinary non-polymorphic methods.  Their reflective appearance, as viewed by
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   400
 * {@link java.lang.Class#getDeclaredMethod Class.getDeclaredMethod},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   401
 * is unaffected by their special status in this API.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   402
 * For example, {@link java.lang.reflect.Method#getModifiers
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   403
 * Method.getModifiers}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   404
 * will report exactly those modifier bits required for any similarly
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   405
 * declared method, including in this case {@code native} and {@code varargs}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   406
 * bits.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   407
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   408
 * As with any reflected method, these methods (when reflected) may be invoked
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   409
 * directly via {@link java.lang.reflect.Method#invoke java.lang.reflect.Method.invoke},
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   410
 * via JNI, or indirectly via
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   411
 * {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   412
 * However, such reflective calls do not result in access mode method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   413
 * invocations.  Such a call, if passed the required argument (a single one, of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   414
 * type {@code Object[]}), will ignore the argument and will throw an
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   415
 * {@code UnsupportedOperationException}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   416
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   417
 * Since {@code invokevirtual} instructions can natively invoke VarHandle
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   418
 * access mode methods under any symbolic type descriptor, this reflective view
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   419
 * conflicts with the normal presentation of these methods via bytecodes.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   420
 * Thus, these native methods, when reflectively viewed by
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   421
 * {@code Class.getDeclaredMethod}, may be regarded as placeholders only.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   422
 * <p>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   423
 * In order to obtain an invoker method for a particular access mode type,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   424
 * use {@link java.lang.invoke.MethodHandles#varHandleExactInvoker} or
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   425
 * {@link java.lang.invoke.MethodHandles#varHandleInvoker}.  The
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   426
 * {@link java.lang.invoke.MethodHandles.Lookup#findVirtual Lookup.findVirtual}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   427
 * API is also able to return a method handle to call an access mode method for
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   428
 * any specified access mode type and is equivalent in behaviour to
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   429
 * {@link java.lang.invoke.MethodHandles#varHandleInvoker}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   430
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   431
 * <h1>Interoperation between VarHandles and Java generics</h1>
47478
438e0c9f2f17 8190382: fix small typographic errors in comments
smarks
parents: 47216
diff changeset
   432
 * A VarHandle can be obtained for a variable, such as a field, which is
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   433
 * declared with Java generic types.  As with the Core Reflection API, the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   434
 * VarHandle's variable type will be constructed from the erasure of the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   435
 * source-level type.  When a VarHandle access mode method is invoked, the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   436
 * types
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   437
 * of its arguments or the return value cast type may be generic types or type
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   438
 * instances.  If this occurs, the compiler will replace those types by their
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   439
 * erasures when it constructs the symbolic type descriptor for the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   440
 * {@code invokevirtual} instruction.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   441
 *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   442
 * @see MethodHandle
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   443
 * @see MethodHandles
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   444
 * @see MethodType
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   445
 * @since 9
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   446
 */
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
   447
public abstract class VarHandle implements Constable {
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   448
    final VarForm vform;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   449
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
   450
    VarHandle(VarForm vform) {
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   451
        this.vform = vform;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   452
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   453
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   454
    RuntimeException unsupported() {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   455
        return new UnsupportedOperationException();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   456
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   457
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   458
    // Plain accessors
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   459
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   460
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   461
     * Returns the value of a variable, with memory semantics of reading as
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   462
     * if the variable was declared non-{@code volatile}.  Commonly referred to
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   463
     * as plain read access.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   464
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   465
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   466
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   467
     * <p>The symbolic type descriptor at the call site of {@code get}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   468
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   469
     * {@code accessModeType(VarHandle.AccessMode.GET)} on this VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   470
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   471
     * <p>This access mode is supported by all VarHandle instances and never
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   472
     * throws {@code UnsupportedOperationException}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   473
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   474
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   475
     * {@code (CT1 ct1, ..., CTn)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   476
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   477
     * @return the signature-polymorphic result that is the value of the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   478
     * variable
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   479
     * , statically represented using {@code Object}.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   480
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   481
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   482
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   483
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   484
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   485
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   486
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   487
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   488
    Object get(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   489
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   490
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   491
     * Sets the value of a variable to the {@code newValue}, with memory
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   492
     * semantics of setting as if the variable was declared non-{@code volatile}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   493
     * and non-{@code final}.  Commonly referred to as plain write access.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   494
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   495
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   496
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   497
     * <p>The symbolic type descriptor at the call site of {@code set}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   498
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   499
     * {@code accessModeType(VarHandle.AccessMode.SET)} on this VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   500
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   501
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   502
     * {@code (CT1 ct1, ..., CTn ctn, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   503
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   504
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   505
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   506
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   507
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   508
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   509
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   510
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   511
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   512
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   513
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   514
    void set(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   515
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   516
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   517
    // Volatile accessors
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   518
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   519
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   520
     * Returns the value of a variable, with memory semantics of reading as if
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   521
     * the variable was declared {@code volatile}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   522
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   523
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   524
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   525
     * <p>The symbolic type descriptor at the call site of {@code getVolatile}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   526
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   527
     * {@code accessModeType(VarHandle.AccessMode.GET_VOLATILE)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   528
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   529
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   530
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   531
     * {@code (CT1 ct1, ..., CTn ctn)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   532
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   533
     * @return the signature-polymorphic result that is the value of the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   534
     * variable
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   535
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   536
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   537
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   538
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   539
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   540
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   541
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   542
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   543
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   544
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   545
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   546
    Object getVolatile(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   547
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   548
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   549
     * Sets the value of a variable to the {@code newValue}, with memory
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   550
     * semantics of setting as if the variable was declared {@code volatile}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   551
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   552
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   553
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   554
     * <p>The symbolic type descriptor at the call site of {@code setVolatile}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   555
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   556
     * {@code accessModeType(VarHandle.AccessMode.SET_VOLATILE)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   557
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   558
     *
37344
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   559
     * @apiNote
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   560
     * Ignoring the many semantic differences from C and C++, this method has
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   561
     * memory ordering effects compatible with {@code memory_order_seq_cst}.
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   562
     *
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   563
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   564
     * {@code (CT1 ct1, ..., CTn ctn, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   565
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   566
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   567
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   568
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   569
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   570
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   571
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   572
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   573
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   574
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   575
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   576
    void setVolatile(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   577
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   578
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   579
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   580
     * Returns the value of a variable, accessed in program order, but with no
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   581
     * assurance of memory ordering effects with respect to other threads.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   582
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   583
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   584
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   585
     * <p>The symbolic type descriptor at the call site of {@code getOpaque}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   586
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   587
     * {@code accessModeType(VarHandle.AccessMode.GET_OPAQUE)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   588
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   589
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   590
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   591
     * {@code (CT1 ct1, ..., CTn ctn)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   592
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   593
     * @return the signature-polymorphic result that is the value of the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   594
     * variable
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   595
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   596
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   597
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   598
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   599
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   600
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   601
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   602
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   603
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   604
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   605
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   606
    Object getOpaque(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   607
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   608
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   609
     * Sets the value of a variable to the {@code newValue}, in program order,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   610
     * but with no assurance of memory ordering effects with respect to other
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   611
     * threads.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   612
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   613
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   614
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   615
     * <p>The symbolic type descriptor at the call site of {@code setOpaque}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   616
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   617
     * {@code accessModeType(VarHandle.AccessMode.SET_OPAQUE)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   618
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   619
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   620
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   621
     * {@code (CT1 ct1, ..., CTn ctn, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   622
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   623
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   624
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   625
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   626
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   627
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   628
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   629
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   630
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   631
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   632
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   633
    void setOpaque(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   634
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   635
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   636
    // Lazy accessors
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   637
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   638
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   639
     * Returns the value of a variable, and ensures that subsequent loads and
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   640
     * stores are not reordered before this access.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   641
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   642
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   643
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   644
     * <p>The symbolic type descriptor at the call site of {@code getAcquire}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   645
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   646
     * {@code accessModeType(VarHandle.AccessMode.GET_ACQUIRE)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   647
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   648
     *
37344
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   649
     * @apiNote
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   650
     * Ignoring the many semantic differences from C and C++, this method has
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   651
     * memory ordering effects compatible with {@code memory_order_acquire}
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   652
     * ordering.
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   653
     *
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   654
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   655
     * {@code (CT1 ct1, ..., CTn ctn)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   656
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   657
     * @return the signature-polymorphic result that is the value of the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   658
     * variable
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   659
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   660
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   661
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   662
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   663
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   664
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   665
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   666
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   667
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   668
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   669
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   670
    Object getAcquire(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   671
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   672
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   673
     * Sets the value of a variable to the {@code newValue}, and ensures that
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   674
     * prior loads and stores are not reordered after this access.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   675
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   676
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   677
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   678
     * <p>The symbolic type descriptor at the call site of {@code setRelease}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   679
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   680
     * {@code accessModeType(VarHandle.AccessMode.SET_RELEASE)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   681
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   682
     *
37344
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   683
     * @apiNote
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   684
     * Ignoring the many semantic differences from C and C++, this method has
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   685
     * memory ordering effects compatible with {@code memory_order_release}
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   686
     * ordering.
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   687
     *
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   688
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   689
     * {@code (CT1 ct1, ..., CTn ctn, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   690
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   691
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   692
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   693
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   694
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   695
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   696
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   697
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   698
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   699
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   700
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   701
    void setRelease(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   702
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   703
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   704
    // Compare and set accessors
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   705
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   706
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   707
     * Atomically sets the value of a variable to the {@code newValue} with the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   708
     * memory semantics of {@link #setVolatile} if the variable's current value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   709
     * referred to as the <em>witness value</em>, {@code ==} the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   710
     * {@code expectedValue}, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   711
     * {@link #getVolatile}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   712
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   713
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   714
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   715
     * <p>The symbolic type descriptor at the call site of {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   716
     * compareAndSet} must match the access mode type that is the result of
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   717
     * calling {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_SET)} on
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   718
     * this VarHandle.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   719
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   720
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   721
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   722
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   723
     * @return {@code true} if successful, otherwise {@code false} if the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   724
     * witness value was not the same as the {@code expectedValue}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   725
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   726
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   727
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   728
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   729
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   730
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   731
     * @see #setVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   732
     * @see #getVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   733
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   734
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   735
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   736
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   737
    boolean compareAndSet(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   738
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   739
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   740
     * Atomically sets the value of a variable to the {@code newValue} with the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   741
     * memory semantics of {@link #setVolatile} if the variable's current value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   742
     * referred to as the <em>witness value</em>, {@code ==} the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   743
     * {@code expectedValue}, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   744
     * {@link #getVolatile}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   745
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   746
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   747
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   748
     * <p>The symbolic type descriptor at the call site of {@code
39472
6df82f4c63ac 8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents: 38368
diff changeset
   749
     * compareAndExchange}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   750
     * must match the access mode type that is the result of calling
39472
6df82f4c63ac 8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents: 38368
diff changeset
   751
     * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   752
     * on this VarHandle.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   753
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   754
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   755
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   756
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   757
     * @return the signature-polymorphic result that is the witness value, which
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   758
     * will be the same as the {@code expectedValue} if successful
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   759
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   760
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   761
     * for this VarHandle.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   762
     * @throws WrongMethodTypeException if the access mode type is not
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   763
     * compatible with the caller's symbolic type descriptor.
37344
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   764
     * @throws ClassCastException if the access mode type is compatible with the
52d3d8517efc 8151198: VarHandle factory-specific exceptions
psandoz
parents: 37343
diff changeset
   765
     * caller's symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   766
     * @see #setVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   767
     * @see #getVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   768
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   769
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   770
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   771
    @HotSpotIntrinsicCandidate
39472
6df82f4c63ac 8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents: 38368
diff changeset
   772
    Object compareAndExchange(Object... args);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   773
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   774
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   775
     * Atomically sets the value of a variable to the {@code newValue} with the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   776
     * memory semantics of {@link #set} if the variable's current value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   777
     * referred to as the <em>witness value</em>, {@code ==} the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   778
     * {@code expectedValue}, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   779
     * {@link #getAcquire}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   780
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   781
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   782
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   783
     * <p>The symbolic type descriptor at the call site of {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   784
     * compareAndExchangeAcquire}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   785
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   786
     * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)} on
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   787
     * this VarHandle.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   788
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   789
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   790
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   791
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   792
     * @return the signature-polymorphic result that is the witness value, which
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   793
     * will be the same as the {@code expectedValue} if successful
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   794
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   795
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   796
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   797
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   798
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   799
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   800
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   801
     * @see #set(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   802
     * @see #getAcquire(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   803
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   804
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   805
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   806
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   807
    Object compareAndExchangeAcquire(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   808
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   809
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   810
     * Atomically sets the value of a variable to the {@code newValue} with the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   811
     * memory semantics of {@link #setRelease} if the variable's current value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   812
     * referred to as the <em>witness value</em>, {@code ==} the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   813
     * {@code expectedValue}, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   814
     * {@link #get}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   815
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   816
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   817
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   818
     * <p>The symbolic type descriptor at the call site of {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   819
     * compareAndExchangeRelease}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   820
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   821
     * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)}
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   822
     * on this VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   823
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   824
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   825
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   826
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   827
     * @return the signature-polymorphic result that is the witness value, which
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   828
     * will be the same as the {@code expectedValue} if successful
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   829
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   830
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   831
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   832
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   833
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   834
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   835
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   836
     * @see #setRelease(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   837
     * @see #get(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   838
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   839
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   840
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   841
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   842
    Object compareAndExchangeRelease(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   843
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   844
    // Weak (spurious failures allowed)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   845
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   846
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   847
     * Possibly atomically sets the value of a variable to the {@code newValue}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   848
     * with the semantics of {@link #set} if the variable's current value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   849
     * referred to as the <em>witness value</em>, {@code ==} the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   850
     * {@code expectedValue}, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   851
     * {@link #get}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   852
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   853
     * <p>This operation may fail spuriously (typically, due to memory
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   854
     * contention) even if the witness value does match the expected value.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   855
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   856
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   857
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   858
     * <p>The symbolic type descriptor at the call site of {@code
40734
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
   859
     * weakCompareAndSetPlain} must match the access mode type that is the result of
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
   860
     * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)}
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   861
     * on this VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   862
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   863
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   864
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   865
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   866
     * @return {@code true} if successful, otherwise {@code false} if the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   867
     * witness value was not the same as the {@code expectedValue} or if this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   868
     * operation spuriously failed.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   869
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   870
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   871
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   872
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   873
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   874
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   875
     * @see #set(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   876
     * @see #get(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   877
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   878
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   879
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   880
    @HotSpotIntrinsicCandidate
40734
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
   881
    boolean weakCompareAndSetPlain(Object... args);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   882
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   883
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   884
     * Possibly atomically sets the value of a variable to the {@code newValue}
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   885
     * with the memory semantics of {@link #setVolatile} if the variable's
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   886
     * current value, referred to as the <em>witness value</em>, {@code ==} the
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   887
     * {@code expectedValue}, as accessed with the memory semantics of
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   888
     * {@link #getVolatile}.
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   889
     *
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   890
     * <p>This operation may fail spuriously (typically, due to memory
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   891
     * contention) even if the witness value does match the expected value.
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   892
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   893
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}.
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   894
     *
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   895
     * <p>The symbolic type descriptor at the call site of {@code
40734
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
   896
     * weakCompareAndSet} must match the access mode type that is the
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
   897
     * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)}
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   898
     * on this VarHandle.
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   899
     *
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   900
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   901
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   902
     * , statically represented using varargs.
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   903
     * @return {@code true} if successful, otherwise {@code false} if the
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   904
     * witness value was not the same as the {@code expectedValue} or if this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   905
     * operation spuriously failed.
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   906
     * @throws UnsupportedOperationException if the access mode is unsupported
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   907
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   908
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   909
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   910
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   911
     * symbolic type descriptor, but a reference cast fails.
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   912
     * @see #setVolatile(Object...)
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   913
     * @see #getVolatile(Object...)
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   914
     */
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   915
    public final native
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   916
    @MethodHandle.PolymorphicSignature
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   917
    @HotSpotIntrinsicCandidate
40734
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
   918
    boolean weakCompareAndSet(Object... args);
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   919
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   920
    /**
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   921
     * Possibly atomically sets the value of a variable to the {@code newValue}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   922
     * with the semantics of {@link #set} if the variable's current value,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   923
     * referred to as the <em>witness value</em>, {@code ==} the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   924
     * {@code expectedValue}, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   925
     * {@link #getAcquire}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   926
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   927
     * <p>This operation may fail spuriously (typically, due to memory
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   928
     * contention) even if the witness value does match the expected value.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   929
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   930
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   931
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   932
     * <p>The symbolic type descriptor at the call site of {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   933
     * weakCompareAndSetAcquire}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   934
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   935
     * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)}
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   936
     * on this VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   937
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   938
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   939
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   940
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   941
     * @return {@code true} if successful, otherwise {@code false} if the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   942
     * witness value was not the same as the {@code expectedValue} or if this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   943
     * operation spuriously failed.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   944
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   945
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   946
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   947
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   948
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   949
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   950
     * @see #set(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   951
     * @see #getAcquire(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   952
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   953
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   954
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   955
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   956
    boolean weakCompareAndSetAcquire(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   957
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   958
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   959
     * Possibly atomically sets the value of a variable to the {@code newValue}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   960
     * with the semantics of {@link #setRelease} if the variable's current
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   961
     * value, referred to as the <em>witness value</em>, {@code ==} the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   962
     * {@code expectedValue}, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   963
     * {@link #get}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   964
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   965
     * <p>This operation may fail spuriously (typically, due to memory
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   966
     * contention) even if the witness value does match the expected value.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   967
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   968
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   969
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   970
     * <p>The symbolic type descriptor at the call site of {@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   971
     * weakCompareAndSetRelease}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   972
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   973
     * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)}
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
   974
     * on this VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   975
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   976
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   977
     * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   978
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   979
     * @return {@code true} if successful, otherwise {@code false} if the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   980
     * witness value was not the same as the {@code expectedValue} or if this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   981
     * operation spuriously failed.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   982
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   983
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   984
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   985
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   986
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
   987
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   988
     * @see #setRelease(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   989
     * @see #get(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   990
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   991
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   992
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   993
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   994
    boolean weakCompareAndSetRelease(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   995
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   996
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   997
     * Atomically sets the value of a variable to the {@code newValue} with the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   998
     * memory semantics of {@link #setVolatile} and returns the variable's
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   999
     * previous value, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1000
     * {@link #getVolatile}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1001
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1002
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1003
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1004
     * <p>The symbolic type descriptor at the call site of {@code getAndSet}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1005
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
  1006
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
  1007
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1008
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1009
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1010
     * {@code (CT1 ct1, ..., CTn ctn, T newValue)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1011
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1012
     * @return the signature-polymorphic result that is the previous value of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1013
     * the variable
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1014
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1015
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1016
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1017
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1018
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1019
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1020
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1021
     * @see #setVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1022
     * @see #getVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1023
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1024
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1025
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1026
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1027
    Object getAndSet(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1028
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1029
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1030
     * Atomically sets the value of a variable to the {@code newValue} with the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1031
     * memory semantics of {@link #set} and returns the variable's
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1032
     * previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1033
     * {@link #getAcquire}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1034
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1035
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1036
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1037
     * <p>The symbolic type descriptor at the call site of {@code getAndSetAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1038
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1039
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1040
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1041
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1042
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1043
     * {@code (CT1 ct1, ..., CTn ctn, T newValue)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1044
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1045
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1046
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1047
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1048
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1049
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1050
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1051
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1052
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1053
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1054
     * @see #setVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1055
     * @see #getVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1056
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1057
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1058
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1059
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1060
    Object getAndSetAcquire(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1061
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1062
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1063
     * Atomically sets the value of a variable to the {@code newValue} with the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1064
     * memory semantics of {@link #setRelease} and returns the variable's
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1065
     * previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1066
     * {@link #get}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1067
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1068
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1069
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1070
     * <p>The symbolic type descriptor at the call site of {@code getAndSetRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1071
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1072
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET_RELEASE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1073
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1074
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1075
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1076
     * {@code (CT1 ct1, ..., CTn ctn, T newValue)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1077
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1078
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1079
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1080
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1081
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1082
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1083
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1084
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1085
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1086
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1087
     * @see #setVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1088
     * @see #getVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1089
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1090
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1091
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1092
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1093
    Object getAndSetRelease(Object... args);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1094
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1095
    // Primitive adders
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1096
    // Throw UnsupportedOperationException for refs
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1097
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1098
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1099
     * Atomically adds the {@code value} to the current value of a variable with
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1100
     * the memory semantics of {@link #setVolatile}, and returns the variable's
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1101
     * previous value, as accessed with the memory semantics of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1102
     * {@link #getVolatile}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1103
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1104
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T value)T}.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1105
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1106
     * <p>The symbolic type descriptor at the call site of {@code getAndAdd}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1107
     * must match the access mode type that is the result of calling
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
  1108
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD)} on this
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
  1109
     * VarHandle.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1110
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1111
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1112
     * {@code (CT1 ct1, ..., CTn ctn, T value)}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1113
     * , statically represented using varargs.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1114
     * @return the signature-polymorphic result that is the previous value of
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1115
     * the variable
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1116
     * , statically represented using {@code Object}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1117
     * @throws UnsupportedOperationException if the access mode is unsupported
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1118
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1119
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1120
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1121
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1122
     * symbolic type descriptor, but a reference cast fails.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1123
     * @see #setVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1124
     * @see #getVolatile(Object...)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1125
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1126
    public final native
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1127
    @MethodHandle.PolymorphicSignature
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1128
    @HotSpotIntrinsicCandidate
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1129
    Object getAndAdd(Object... args);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1130
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1131
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1132
     * Atomically adds the {@code value} to the current value of a variable with
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1133
     * the memory semantics of {@link #set}, and returns the variable's
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1134
     * previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1135
     * {@link #getAcquire}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1136
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1137
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T value)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1138
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1139
     * <p>The symbolic type descriptor at the call site of {@code getAndAddAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1140
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1141
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1142
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1143
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1144
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1145
     * {@code (CT1 ct1, ..., CTn ctn, T value)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1146
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1147
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1148
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1149
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1150
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1151
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1152
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1153
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1154
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1155
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1156
     * @see #setVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1157
     * @see #getVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1158
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1159
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1160
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1161
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1162
    Object getAndAddAcquire(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1163
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1164
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1165
     * Atomically adds the {@code value} to the current value of a variable with
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1166
     * the memory semantics of {@link #setRelease}, and returns the variable's
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1167
     * previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1168
     * {@link #get}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1169
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1170
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T value)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1171
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1172
     * <p>The symbolic type descriptor at the call site of {@code getAndAddRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1173
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1174
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD_RELEASE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1175
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1176
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1177
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1178
     * {@code (CT1 ct1, ..., CTn ctn, T value)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1179
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1180
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1181
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1182
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1183
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1184
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1185
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1186
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1187
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1188
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1189
     * @see #setVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1190
     * @see #getVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1191
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1192
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1193
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1194
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1195
    Object getAndAddRelease(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1196
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1197
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1198
    // Bitwise operations
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1199
    // Throw UnsupportedOperationException for refs
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1200
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1201
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1202
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1203
     * bitwise OR between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1204
     * with the memory semantics of {@link #setVolatile} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1205
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1206
     * {@link #getVolatile}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1207
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1208
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1209
     * logical OR is performed instead of a bitwise OR.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1210
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1211
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1212
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1213
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseOr}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1214
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1215
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1216
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1217
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1218
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1219
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1220
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1221
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1222
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1223
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1224
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1225
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1226
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1227
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1228
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1229
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1230
     * @see #setVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1231
     * @see #getVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1232
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1233
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1234
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1235
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1236
    Object getAndBitwiseOr(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1237
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1238
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1239
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1240
     * bitwise OR between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1241
     * with the memory semantics of {@link #set} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1242
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1243
     * {@link #getAcquire}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1244
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1245
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1246
     * logical OR is performed instead of a bitwise OR.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1247
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1248
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1249
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1250
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseOrAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1251
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1252
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1253
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1254
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1255
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1256
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1257
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1258
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1259
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1260
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1261
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1262
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1263
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1264
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1265
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1266
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1267
     * @see #set(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1268
     * @see #getAcquire(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1269
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1270
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1271
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1272
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1273
    Object getAndBitwiseOrAcquire(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1274
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1275
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1276
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1277
     * bitwise OR between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1278
     * with the memory semantics of {@link #setRelease} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1279
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1280
     * {@link #get}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1281
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1282
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1283
     * logical OR is performed instead of a bitwise OR.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1284
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1285
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1286
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1287
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseOrRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1288
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1289
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1290
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1291
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1292
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1293
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1294
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1295
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1296
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1297
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1298
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1299
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1300
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1301
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1302
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1303
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1304
     * @see #setRelease(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1305
     * @see #get(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1306
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1307
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1308
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1309
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1310
    Object getAndBitwiseOrRelease(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1311
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1312
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1313
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1314
     * bitwise AND between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1315
     * with the memory semantics of {@link #setVolatile} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1316
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1317
     * {@link #getVolatile}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1318
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1319
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1320
     * logical AND is performed instead of a bitwise AND.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1321
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1322
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1323
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1324
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseAnd}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1325
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1326
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1327
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1328
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1329
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1330
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1331
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1332
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1333
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1334
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1335
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1336
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1337
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1338
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1339
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1340
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1341
     * @see #setVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1342
     * @see #getVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1343
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1344
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1345
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1346
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1347
    Object getAndBitwiseAnd(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1348
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1349
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1350
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1351
     * bitwise AND between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1352
     * with the memory semantics of {@link #set} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1353
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1354
     * {@link #getAcquire}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1355
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1356
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1357
     * logical AND is performed instead of a bitwise AND.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1358
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1359
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1360
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1361
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseAndAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1362
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1363
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1364
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1365
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1366
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1367
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1368
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1369
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1370
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1371
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1372
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1373
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1374
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1375
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1376
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1377
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1378
     * @see #set(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1379
     * @see #getAcquire(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1380
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1381
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1382
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1383
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1384
    Object getAndBitwiseAndAcquire(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1385
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1386
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1387
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1388
     * bitwise AND between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1389
     * with the memory semantics of {@link #setRelease} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1390
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1391
     * {@link #get}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1392
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1393
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1394
     * logical AND is performed instead of a bitwise AND.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1395
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1396
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1397
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1398
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseAndRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1399
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1400
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1401
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1402
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1403
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1404
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1405
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1406
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1407
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1408
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1409
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1410
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1411
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1412
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1413
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1414
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1415
     * @see #setRelease(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1416
     * @see #get(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1417
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1418
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1419
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1420
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1421
    Object getAndBitwiseAndRelease(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1422
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1423
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1424
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1425
     * bitwise XOR between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1426
     * with the memory semantics of {@link #setVolatile} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1427
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1428
     * {@link #getVolatile}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1429
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1430
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1431
     * logical XOR is performed instead of a bitwise XOR.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1432
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1433
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1434
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1435
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseXor}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1436
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1437
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1438
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1439
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1440
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1441
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1442
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1443
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1444
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1445
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1446
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1447
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1448
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1449
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1450
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1451
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1452
     * @see #setVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1453
     * @see #getVolatile(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1454
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1455
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1456
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1457
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1458
    Object getAndBitwiseXor(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1459
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1460
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1461
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1462
     * bitwise XOR between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1463
     * with the memory semantics of {@link #set} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1464
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1465
     * {@link #getAcquire}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1466
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1467
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1468
     * logical XOR is performed instead of a bitwise XOR.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1469
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1470
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1471
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1472
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseXorAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1473
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1474
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1475
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1476
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1477
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1478
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1479
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1480
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1481
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1482
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1483
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1484
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1485
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1486
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1487
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1488
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1489
     * @see #set(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1490
     * @see #getAcquire(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1491
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1492
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1493
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1494
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1495
    Object getAndBitwiseXorAcquire(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1496
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1497
    /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1498
     * Atomically sets the value of a variable to the result of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1499
     * bitwise XOR between the variable's current value and the {@code mask}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1500
     * with the memory semantics of {@link #setRelease} and returns the
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1501
     * variable's previous value, as accessed with the memory semantics of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1502
     * {@link #get}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1503
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1504
     * <p>If the variable type is the non-integral {@code boolean} type then a
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1505
     * logical XOR is performed instead of a bitwise XOR.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1506
     *
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1507
     * <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1508
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1509
     * <p>The symbolic type descriptor at the call site of {@code getAndBitwiseXorRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1510
     * must match the access mode type that is the result of calling
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1511
     * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)} on this
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1512
     * VarHandle.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1513
     *
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1514
     * @param args the signature-polymorphic parameter list of the form
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1515
     * {@code (CT1 ct1, ..., CTn ctn, T mask)}
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1516
     * , statically represented using varargs.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1517
     * @return the signature-polymorphic result that is the previous value of
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1518
     * the variable
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1519
     * , statically represented using {@code Object}.
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1520
     * @throws UnsupportedOperationException if the access mode is unsupported
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1521
     * for this VarHandle.
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1522
     * @throws WrongMethodTypeException if the access mode type does not
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1523
     * match the caller's symbolic type descriptor.
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1524
     * @throws ClassCastException if the access mode type matches the caller's
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1525
     * symbolic type descriptor, but a reference cast fails.
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1526
     * @see #setRelease(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1527
     * @see #get(Object...)
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1528
     */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1529
    public final native
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1530
    @MethodHandle.PolymorphicSignature
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1531
    @HotSpotIntrinsicCandidate
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1532
    Object getAndBitwiseXorRelease(Object... args);
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1533
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1534
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1535
    enum AccessType {
40256
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1536
        GET(Object.class),
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1537
        SET(void.class),
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
  1538
        COMPARE_AND_SET(boolean.class),
40256
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1539
        COMPARE_AND_EXCHANGE(Object.class),
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1540
        GET_AND_UPDATE(Object.class);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1541
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1542
        final Class<?> returnType;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1543
        final boolean isMonomorphicInReturnType;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1544
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1545
        AccessType(Class<?> returnType) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1546
            this.returnType = returnType;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1547
            isMonomorphicInReturnType = returnType != Object.class;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1548
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1549
40256
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1550
        MethodType accessModeType(Class<?> receiver, Class<?> value,
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1551
                                  Class<?>... intermediate) {
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1552
            Class<?>[] ps;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1553
            int i;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1554
            switch (this) {
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1555
                case GET:
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1556
                    ps = allocateParameters(0, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1557
                    fillParameters(ps, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1558
                    return MethodType.methodType(value, ps);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1559
                case SET:
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1560
                    ps = allocateParameters(1, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1561
                    i = fillParameters(ps, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1562
                    ps[i] = value;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1563
                    return MethodType.methodType(void.class, ps);
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
  1564
                case COMPARE_AND_SET:
40256
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1565
                    ps = allocateParameters(2, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1566
                    i = fillParameters(ps, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1567
                    ps[i++] = value;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1568
                    ps[i] = value;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1569
                    return MethodType.methodType(boolean.class, ps);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1570
                case COMPARE_AND_EXCHANGE:
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1571
                    ps = allocateParameters(2, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1572
                    i = fillParameters(ps, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1573
                    ps[i++] = value;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1574
                    ps[i] = value;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1575
                    return MethodType.methodType(value, ps);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1576
                case GET_AND_UPDATE:
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1577
                    ps = allocateParameters(1, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1578
                    i = fillParameters(ps, receiver, intermediate);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1579
                    ps[i] = value;
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1580
                    return MethodType.methodType(value, ps);
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1581
                default:
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1582
                    throw new InternalError("Unknown AccessType");
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1583
            }
c5e03eaf7ba2 8163370: Reduce number of classes loaded by common usage of java.lang.invoke
redestad
parents: 39474
diff changeset
  1584
        }
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1585
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1586
        private static Class<?>[] allocateParameters(int values,
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1587
                                                     Class<?> receiver, Class<?>... intermediate) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1588
            int size = ((receiver != null) ? 1 : 0) + intermediate.length + values;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1589
            return new Class<?>[size];
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1590
        }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1591
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1592
        private static int fillParameters(Class<?>[] ps,
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1593
                                          Class<?> receiver, Class<?>... intermediate) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1594
            int i = 0;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1595
            if (receiver != null)
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1596
                ps[i++] = receiver;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1597
            for (int j = 0; j < intermediate.length; j++)
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1598
                ps[i++] = intermediate[j];
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1599
            return i;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1600
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1601
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1602
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1603
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1604
     * The set of access modes that specify how a variable, referenced by a
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1605
     * VarHandle, is accessed.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1606
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1607
    public enum AccessMode {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1608
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1609
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1610
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1611
         * {@link VarHandle#get VarHandle.get}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1612
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1613
        GET("get", AccessType.GET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1614
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1615
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1616
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1617
         * {@link VarHandle#set VarHandle.set}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1618
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1619
        SET("set", AccessType.SET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1620
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1621
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1622
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1623
         * {@link VarHandle#getVolatile VarHandle.getVolatile}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1624
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1625
        GET_VOLATILE("getVolatile", AccessType.GET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1626
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1627
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1628
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1629
         * {@link VarHandle#setVolatile VarHandle.setVolatile}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1630
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1631
        SET_VOLATILE("setVolatile", AccessType.SET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1632
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1633
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1634
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1635
         * {@link VarHandle#getAcquire VarHandle.getAcquire}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1636
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1637
        GET_ACQUIRE("getAcquire", AccessType.GET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1638
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1639
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1640
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1641
         * {@link VarHandle#setRelease VarHandle.setRelease}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1642
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1643
        SET_RELEASE("setRelease", AccessType.SET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1644
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1645
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1646
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1647
         * {@link VarHandle#getOpaque VarHandle.getOpaque}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1648
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1649
        GET_OPAQUE("getOpaque", AccessType.GET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1650
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1651
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1652
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1653
         * {@link VarHandle#setOpaque VarHandle.setOpaque}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1654
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1655
        SET_OPAQUE("setOpaque", AccessType.SET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1656
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1657
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1658
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1659
         * {@link VarHandle#compareAndSet VarHandle.compareAndSet}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1660
         */
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
  1661
        COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1662
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1663
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1664
         * method
39472
6df82f4c63ac 8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents: 38368
diff changeset
  1665
         * {@link VarHandle#compareAndExchange VarHandle.compareAndExchange}
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1666
         */
39472
6df82f4c63ac 8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents: 38368
diff changeset
  1667
        COMPARE_AND_EXCHANGE("compareAndExchange", AccessType.COMPARE_AND_EXCHANGE),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1668
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1669
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1670
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1671
         * {@link VarHandle#compareAndExchangeAcquire VarHandle.compareAndExchangeAcquire}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1672
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1673
        COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1674
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1675
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1676
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1677
         * {@link VarHandle#compareAndExchangeRelease VarHandle.compareAndExchangeRelease}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1678
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1679
        COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1680
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1681
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1682
         * method
40734
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
  1683
         * {@link VarHandle#weakCompareAndSetPlain VarHandle.weakCompareAndSetPlain}
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
  1684
         */
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
  1685
        WEAK_COMPARE_AND_SET_PLAIN("weakCompareAndSetPlain", AccessType.COMPARE_AND_SET),
40734
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
  1686
        /**
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
  1687
         * The access mode whose access is specified by the corresponding
48879ea67e2a 8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents: 40733
diff changeset
  1688
         * method
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1689
         * {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1690
         */
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
  1691
        WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SET),
37719
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
  1692
        /**
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
  1693
         * The access mode whose access is specified by the corresponding
add11bc0e6e2 8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents: 37345
diff changeset
  1694
         * method
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1695
         * {@link VarHandle#weakCompareAndSetAcquire VarHandle.weakCompareAndSetAcquire}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1696
         */
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
  1697
        WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1698
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1699
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1700
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1701
         * {@link VarHandle#weakCompareAndSetRelease VarHandle.weakCompareAndSetRelease}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1702
         */
47859
065700a01c96 8180437: Remaining renames of CAS misnomer "swap" => "set"
psandoz
parents: 47478
diff changeset
  1703
        WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SET),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1704
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1705
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1706
         * method
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1707
         * {@link VarHandle#getAndSet VarHandle.getAndSet}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1708
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1709
        GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1710
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1711
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1712
         * method
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1713
         * {@link VarHandle#getAndSetAcquire VarHandle.getAndSetAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1714
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1715
        GET_AND_SET_ACQUIRE("getAndSetAcquire", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1716
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1717
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1718
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1719
         * {@link VarHandle#getAndSetRelease VarHandle.getAndSetRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1720
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1721
        GET_AND_SET_RELEASE("getAndSetRelease", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1722
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1723
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1724
         * method
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1725
         * {@link VarHandle#getAndAdd VarHandle.getAndAdd}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1726
         */
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1727
        GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1728
        /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1729
         * The access mode whose access is specified by the corresponding
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1730
         * method
40732
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1731
         * {@link VarHandle#getAndAddAcquire VarHandle.getAndAddAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1732
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1733
        GET_AND_ADD_ACQUIRE("getAndAddAcquire", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1734
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1735
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1736
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1737
         * {@link VarHandle#getAndAddRelease VarHandle.getAndAddRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1738
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1739
        GET_AND_ADD_RELEASE("getAndAddRelease", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1740
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1741
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1742
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1743
         * {@link VarHandle#getAndBitwiseOr VarHandle.getAndBitwiseOr}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1744
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1745
        GET_AND_BITWISE_OR("getAndBitwiseOr", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1746
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1747
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1748
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1749
         * {@link VarHandle#getAndBitwiseOrRelease VarHandle.getAndBitwiseOrRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1750
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1751
        GET_AND_BITWISE_OR_RELEASE("getAndBitwiseOrRelease", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1752
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1753
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1754
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1755
         * {@link VarHandle#getAndBitwiseOrAcquire VarHandle.getAndBitwiseOrAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1756
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1757
        GET_AND_BITWISE_OR_ACQUIRE("getAndBitwiseOrAcquire", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1758
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1759
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1760
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1761
         * {@link VarHandle#getAndBitwiseAnd VarHandle.getAndBitwiseAnd}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1762
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1763
        GET_AND_BITWISE_AND("getAndBitwiseAnd", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1764
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1765
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1766
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1767
         * {@link VarHandle#getAndBitwiseAndRelease VarHandle.getAndBitwiseAndRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1768
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1769
        GET_AND_BITWISE_AND_RELEASE("getAndBitwiseAndRelease", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1770
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1771
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1772
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1773
         * {@link VarHandle#getAndBitwiseAndAcquire VarHandle.getAndBitwiseAndAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1774
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1775
        GET_AND_BITWISE_AND_ACQUIRE("getAndBitwiseAndAcquire", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1776
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1777
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1778
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1779
         * {@link VarHandle#getAndBitwiseXor VarHandle.getAndBitwiseXor}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1780
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1781
        GET_AND_BITWISE_XOR("getAndBitwiseXor", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1782
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1783
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1784
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1785
         * {@link VarHandle#getAndBitwiseXorRelease VarHandle.getAndBitwiseXorRelease}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1786
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1787
        GET_AND_BITWISE_XOR_RELEASE("getAndBitwiseXorRelease", AccessType.GET_AND_UPDATE),
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1788
        /**
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1789
         * The access mode whose access is specified by the corresponding
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1790
         * method
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1791
         * {@link VarHandle#getAndBitwiseXorAcquire VarHandle.getAndBitwiseXorAcquire}
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1792
         */
2fd9cf42bb3c 8161444: VarHandles should provide access bitwise atomics
psandoz
parents: 40256
diff changeset
  1793
        GET_AND_BITWISE_XOR_ACQUIRE("getAndBitwiseXorAcquire", AccessType.GET_AND_UPDATE),
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1794
        ;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1795
37343
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1796
        static final Map<String, AccessMode> methodNameToAccessMode;
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1797
        static {
49546
05c1e4d50f9a 8200788: Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode
igerasim
parents: 47859
diff changeset
  1798
            AccessMode[] values = AccessMode.values();
05c1e4d50f9a 8200788: Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode
igerasim
parents: 47859
diff changeset
  1799
            // Initial capacity of # values divided by the load factor is sufficient
05c1e4d50f9a 8200788: Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode
igerasim
parents: 47859
diff changeset
  1800
            // to avoid resizes for the smallest table size (64)
05c1e4d50f9a 8200788: Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode
igerasim
parents: 47859
diff changeset
  1801
            int initialCapacity = (int)(values.length / 0.75f) + 1;
05c1e4d50f9a 8200788: Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode
igerasim
parents: 47859
diff changeset
  1802
            methodNameToAccessMode = new HashMap<>(initialCapacity);
05c1e4d50f9a 8200788: Optimal initial capacity of java.lang.VarHandle.AccessMode.methodNameToAccessMode
igerasim
parents: 47859
diff changeset
  1803
            for (AccessMode am : values) {
37343
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1804
                methodNameToAccessMode.put(am.methodName, am);
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1805
            }
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1806
        }
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1807
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1808
        final String methodName;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1809
        final AccessType at;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1810
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1811
        AccessMode(final String methodName, AccessType at) {
37343
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1812
            this.methodName = methodName;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1813
            this.at = at;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1814
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1815
37343
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1816
        /**
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1817
         * Returns the {@code VarHandle} signature-polymorphic method name
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1818
         * associated with this {@code AccessMode} value.
37343
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1819
         *
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1820
         * @return the signature-polymorphic method name
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1821
         * @see #valueFromMethodName
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1822
         */
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1823
        public String methodName() {
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1824
            return methodName;
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1825
        }
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1826
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1827
        /**
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1828
         * Returns the {@code AccessMode} value associated with the specified
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1829
         * {@code VarHandle} signature-polymorphic method name.
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1830
         *
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1831
         * @param methodName the signature-polymorphic method name
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1832
         * @return the {@code AccessMode} value
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1833
         * @throws IllegalArgumentException if there is no {@code AccessMode}
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1834
         *         value associated with method name (indicating the method
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1835
         *         name does not correspond to a {@code VarHandle}
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1836
         *         signature-polymorphic method name).
47004
b7e72fc752c9 8186684: Fix broken links in java.base API docs
jjg
parents: 46875
diff changeset
  1837
         * @see #methodName()
37343
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1838
         */
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1839
        public static AccessMode valueFromMethodName(String methodName) {
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1840
            AccessMode am = methodNameToAccessMode.get(methodName);
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1841
            if (am != null) return am;
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1842
            throw new IllegalArgumentException("No AccessMode value for method name " + methodName);
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1843
        }
35a2231828a7 8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents: 36973
diff changeset
  1844
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1845
        @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1846
        static MemberName getMemberName(int ordinal, VarForm vform) {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1847
            return vform.memberName_table[ordinal];
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1848
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1849
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1850
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1851
    static final class AccessDescriptor {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1852
        final MethodType symbolicMethodTypeErased;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1853
        final MethodType symbolicMethodTypeInvoker;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1854
        final Class<?> returnType;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1855
        final int type;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1856
        final int mode;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1857
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1858
        public AccessDescriptor(MethodType symbolicMethodType, int type, int mode) {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1859
            this.symbolicMethodTypeErased = symbolicMethodType.erase();
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1860
            this.symbolicMethodTypeInvoker = symbolicMethodType.insertParameterTypes(0, VarHandle.class);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1861
            this.returnType = symbolicMethodType.returnType();
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1862
            this.type = type;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1863
            this.mode = mode;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1864
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1865
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1866
53019
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  1867
    /**
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  1868
     * Returns a compact textual description of this {@linkplain VarHandle},
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  1869
     * including the type of variable described, and a description of its coordinates.
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  1870
     *
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  1871
     * @return A compact textual description of this {@linkplain VarHandle}
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  1872
     */
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1873
    @Override
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1874
    public final String toString() {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1875
        return String.format("VarHandle[varType=%s, coord=%s]",
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1876
                             varType().getName(),
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1877
                             coordinateTypes());
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1878
    }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1879
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1880
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1881
     * Returns the variable type of variables referenced by this VarHandle.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1882
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1883
     * @return the variable type of variables referenced by this VarHandle
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1884
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1885
    public final Class<?> varType() {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1886
        MethodType typeSet = accessModeType(AccessMode.SET);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1887
        return typeSet.parameterType(typeSet.parameterCount() - 1);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1888
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1889
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1890
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1891
     * Returns the coordinate types for this VarHandle.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1892
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1893
     * @return the coordinate types for this VarHandle. The returned
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1894
     * list is unmodifiable
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1895
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1896
    public final List<Class<?>> coordinateTypes() {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1897
        MethodType typeGet = accessModeType(AccessMode.GET);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1898
        return typeGet.parameterList();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1899
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1900
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1901
    /**
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1902
     * Obtains the access mode type for this VarHandle and a given access mode.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1903
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1904
     * <p>The access mode type's parameter types will consist of a prefix that
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1905
     * is the coordinate types of this VarHandle followed by further
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1906
     * types as defined by the access mode method.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1907
     * The access mode type's return type is defined by the return type of the
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1908
     * access mode method.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1909
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1910
     * @param accessMode the access mode, corresponding to the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1911
     * signature-polymorphic method of the same name
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1912
     * @return the access mode type for the given access mode
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1913
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1914
    public final MethodType accessModeType(AccessMode accessMode) {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1915
        TypesAndInvokers tis = getTypesAndInvokers();
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1916
        MethodType mt = tis.methodType_table[accessMode.at.ordinal()];
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1917
        if (mt == null) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1918
            mt = tis.methodType_table[accessMode.at.ordinal()] =
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1919
                    accessModeTypeUncached(accessMode);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1920
        }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1921
        return mt;
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1922
    }
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1923
    abstract MethodType accessModeTypeUncached(AccessMode accessMode);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1924
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1925
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1926
     * Returns {@code true} if the given access mode is supported, otherwise
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1927
     * {@code false}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1928
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1929
     * <p>The return of a {@code false} value for a given access mode indicates
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1930
     * that an {@code UnsupportedOperationException} is thrown on invocation
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1931
     * of the corresponding access mode method.
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1932
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1933
     * @param accessMode the access mode, corresponding to the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1934
     * signature-polymorphic method of the same name
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1935
     * @return {@code true} if the given access mode is supported, otherwise
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1936
     * {@code false}.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1937
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1938
    public final boolean isAccessModeSupported(AccessMode accessMode) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1939
        return AccessMode.getMemberName(accessMode.ordinal(), vform) != null;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1940
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1941
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1942
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1943
     * Obtains a method handle bound to this VarHandle and the given access
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1944
     * mode.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1945
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1946
     * @apiNote This method, for a VarHandle {@code vh} and access mode
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1947
     * {@code {access-mode}}, returns a method handle that is equivalent to
44860
a33107d3a388 8167229: Improve VarHandle documentation
psandoz
parents: 44844
diff changeset
  1948
     * method handle {@code bmh} in the following code (though it may be more
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1949
     * efficient):
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1950
     * <pre>{@code
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1951
     * MethodHandle mh = MethodHandles.varHandleExactInvoker(
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1952
     *                       vh.accessModeType(VarHandle.AccessMode.{access-mode}));
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1953
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1954
     * MethodHandle bmh = mh.bindTo(vh);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1955
     * }</pre>
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1956
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1957
     * @param accessMode the access mode, corresponding to the
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1958
     * signature-polymorphic method of the same name
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1959
     * @return a method handle bound to this VarHandle and the given access mode
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1960
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1961
    public final MethodHandle toMethodHandle(AccessMode accessMode) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1962
        MemberName mn = AccessMode.getMemberName(accessMode.ordinal(), vform);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1963
        if (mn != null) {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1964
            MethodHandle mh = getMethodHandle(accessMode.ordinal());
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1965
            return mh.bindTo(this);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1966
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1967
        else {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1968
            // Ensure an UnsupportedOperationException is thrown
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1969
            return MethodHandles.varHandleInvoker(accessMode, accessModeType(accessMode)).
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1970
                    bindTo(this);
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1971
        }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1972
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  1973
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1974
    /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1975
     * Return a nominal descriptor for this instance, if one can be
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1976
     * constructed, or an empty {@link Optional} if one cannot be.
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1977
     *
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1978
     * @return An {@link Optional} containing the resulting nominal descriptor,
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1979
     * or an empty {@link Optional} if one cannot be constructed.
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1980
     * @since 12
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1981
     */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1982
    @Override
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1983
    public Optional<VarHandleDesc> describeConstable() {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1984
        // partial function for field and array only
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1985
        return Optional.empty();
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1986
    }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  1987
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1988
    @Stable
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1989
    TypesAndInvokers typesAndInvokers;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1990
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1991
    static class TypesAndInvokers {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1992
        final @Stable
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1993
        MethodType[] methodType_table =
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1994
                new MethodType[VarHandle.AccessType.values().length];
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1995
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1996
        final @Stable
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1997
        MethodHandle[] methodHandle_table =
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1998
                new MethodHandle[AccessMode.values().length];
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  1999
    }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2000
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2001
    @ForceInline
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2002
    private final TypesAndInvokers getTypesAndInvokers() {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2003
        TypesAndInvokers tis = typesAndInvokers;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2004
        if (tis == null) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2005
            tis = typesAndInvokers = new TypesAndInvokers();
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2006
        }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2007
        return tis;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2008
    }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2009
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2010
    @ForceInline
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2011
    final MethodHandle getMethodHandle(int mode) {
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2012
        TypesAndInvokers tis = getTypesAndInvokers();
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2013
        MethodHandle mh = tis.methodHandle_table[mode];
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2014
        if (mh == null) {
38328
40435a469d25 8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents: 37792
diff changeset
  2015
            mh = tis.methodHandle_table[mode] = getMethodHandleUncached(mode);
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2016
        }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2017
        return mh;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2018
    }
38328
40435a469d25 8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents: 37792
diff changeset
  2019
    private final MethodHandle getMethodHandleUncached(int mode) {
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2020
        MethodType mt = accessModeType(AccessMode.values()[mode]).
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2021
                insertParameterTypes(0, VarHandle.class);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2022
        MemberName mn = vform.getMemberName(mode);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2023
        DirectMethodHandle dmh = DirectMethodHandle.make(mn);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2024
        // Such a method handle must not be publically exposed directly
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2025
        // otherwise it can be cracked, it must be transformed or rebound
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2026
        // before exposure
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2027
        MethodHandle mh = dmh.copyWith(mt, dmh.form);
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2028
        assert mh.type().erase() == mn.getMethodType().erase();
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2029
        return mh;
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2030
    }
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2031
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2032
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2033
    /*non-public*/
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2034
    final void updateVarForm(VarForm newVForm) {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2035
        if (vform == newVForm) return;
52220
9c260a6b6471 8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference
mchung
parents: 51986
diff changeset
  2036
        UNSAFE.putReference(this, VFORM_OFFSET, newVForm);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2037
        UNSAFE.fullFence();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2038
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2039
37345
9cb6e1141bdb 8146458: Improve exception reporting for Objects.checkIndex/checkFromToIndex/checkFromIndexSize
psandoz
parents: 37344
diff changeset
  2040
    static final BiFunction<String, List<Integer>, ArrayIndexOutOfBoundsException>
38356
1e4ecca97792 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents: 37345
diff changeset
  2041
            AIOOBE_SUPPLIER = Preconditions.outOfBoundsExceptionFormatter(
37345
9cb6e1141bdb 8146458: Improve exception reporting for Objects.checkIndex/checkFromToIndex/checkFromIndexSize
psandoz
parents: 37344
diff changeset
  2042
            new Function<String, ArrayIndexOutOfBoundsException>() {
9cb6e1141bdb 8146458: Improve exception reporting for Objects.checkIndex/checkFromToIndex/checkFromIndexSize
psandoz
parents: 37344
diff changeset
  2043
                @Override
9cb6e1141bdb 8146458: Improve exception reporting for Objects.checkIndex/checkFromToIndex/checkFromIndexSize
psandoz
parents: 37344
diff changeset
  2044
                public ArrayIndexOutOfBoundsException apply(String s) {
9cb6e1141bdb 8146458: Improve exception reporting for Objects.checkIndex/checkFromToIndex/checkFromIndexSize
psandoz
parents: 37344
diff changeset
  2045
                    return new ArrayIndexOutOfBoundsException(s);
9cb6e1141bdb 8146458: Improve exception reporting for Objects.checkIndex/checkFromToIndex/checkFromIndexSize
psandoz
parents: 37344
diff changeset
  2046
                }
9cb6e1141bdb 8146458: Improve exception reporting for Objects.checkIndex/checkFromToIndex/checkFromIndexSize
psandoz
parents: 37344
diff changeset
  2047
            });
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2048
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2049
    private static final long VFORM_OFFSET;
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2050
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2051
    static {
46873
7ac2f551b0d6 8182487: Add Unsafe.objectFieldOffset(Class, String)
redestad
parents: 44860
diff changeset
  2052
        VFORM_OFFSET = UNSAFE.objectFieldOffset(VarHandle.class, "vform");
37792
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2053
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2054
        // The VarHandleGuards must be initialized to ensure correct
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2055
        // compilation of the guard methods
dd626e6f5967 8155258: VarHandle implementation improvements
psandoz
parents: 37719
diff changeset
  2056
        UNSAFE.ensureClassInitialized(VarHandleGuards.class);
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2057
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2058
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2059
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2060
    // Fence methods
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2061
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2062
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2063
     * Ensures that loads and stores before the fence will not be reordered
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2064
     * with
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2065
     * loads and stores after the fence.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2066
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2067
     * @apiNote Ignoring the many semantic differences from C and C++, this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2068
     * method has memory ordering effects compatible with
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2069
     * {@code atomic_thread_fence(memory_order_seq_cst)}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2070
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2071
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2072
    public static void fullFence() {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2073
        UNSAFE.fullFence();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2074
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2075
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2076
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2077
     * Ensures that loads before the fence will not be reordered with loads and
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2078
     * stores after the fence.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2079
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2080
     * @apiNote Ignoring the many semantic differences from C and C++, this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2081
     * method has memory ordering effects compatible with
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2082
     * {@code atomic_thread_fence(memory_order_acquire)}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2083
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2084
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2085
    public static void acquireFence() {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2086
        UNSAFE.loadFence();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2087
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2088
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2089
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2090
     * Ensures that loads and stores before the fence will not be
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2091
     * reordered with stores after the fence.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2092
     *
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2093
     * @apiNote Ignoring the many semantic differences from C and C++, this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2094
     * method has memory ordering effects compatible with
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2095
     * {@code atomic_thread_fence(memory_order_release)}
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2096
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2097
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2098
    public static void releaseFence() {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2099
        UNSAFE.storeFence();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2100
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2101
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2102
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2103
     * Ensures that loads before the fence will not be reordered with
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2104
     * loads after the fence.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2105
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2106
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2107
    public static void loadLoadFence() {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2108
        UNSAFE.loadLoadFence();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2109
    }
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2110
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2111
    /**
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2112
     * Ensures that stores before the fence will not be reordered with
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2113
     * stores after the fence.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2114
     */
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2115
    @ForceInline
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2116
    public static void storeStoreFence() {
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2117
        UNSAFE.storeStoreFence();
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2118
    }
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2119
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2120
    /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2121
     * A <a href="package-summary.html#nominal">nominal descriptor</a> for a
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2122
     * {@link VarHandle} constant.
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2123
     *
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2124
     * @since 12
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2125
     */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2126
    public static final class VarHandleDesc extends DynamicConstantDesc<VarHandle> {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2127
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2128
        /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2129
         * Kinds of variable handle descs
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2130
         */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2131
        private enum Kind {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2132
            FIELD(ConstantDescs.BSM_VARHANDLE_FIELD),
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2133
            STATIC_FIELD(ConstantDescs.BSM_VARHANDLE_STATIC_FIELD),
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2134
            ARRAY(ConstantDescs.BSM_VARHANDLE_ARRAY);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2135
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2136
            final DirectMethodHandleDesc bootstrapMethod;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2137
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2138
            Kind(DirectMethodHandleDesc bootstrapMethod) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2139
                this.bootstrapMethod = bootstrapMethod;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2140
            }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2141
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2142
            ConstantDesc[] toBSMArgs(ClassDesc declaringClass, ClassDesc varType) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2143
                switch (this) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2144
                    case FIELD:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2145
                    case STATIC_FIELD:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2146
                        return new ConstantDesc[] {declaringClass, varType };
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2147
                    case ARRAY:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2148
                        return new ConstantDesc[] {declaringClass };
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2149
                    default:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2150
                        throw new InternalError("Cannot reach here");
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2151
                }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2152
            }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2153
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2154
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2155
        private final Kind kind;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2156
        private final ClassDesc declaringClass;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2157
        private final ClassDesc varType;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2158
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2159
        /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2160
         * Construct a {@linkplain VarHandleDesc} given a kind, name, and declaring
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2161
         * class.
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2162
         *
53563
a4b7ea85d668 8218022: Repeated words typos in java.base
prappo
parents: 53284
diff changeset
  2163
         * @param kind the kind of the var handle
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2164
         * @param name the unqualified name of the field, for field var handles; otherwise ignored
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2165
         * @param declaringClass a {@link ClassDesc} describing the declaring class,
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2166
         *                       for field var handles
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2167
         * @param varType a {@link ClassDesc} describing the type of the variable
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2168
         * @throws NullPointerException if any required argument is null
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2169
         * @jvms 4.2.2 Unqualified Names
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2170
         */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2171
        private VarHandleDesc(Kind kind, String name, ClassDesc declaringClass, ClassDesc varType) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2172
            super(kind.bootstrapMethod, name,
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2173
                  ConstantDescs.CD_VarHandle,
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2174
                  kind.toBSMArgs(declaringClass, varType));
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2175
            this.kind = kind;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2176
            this.declaringClass = declaringClass;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2177
            this.varType = varType;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2178
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2179
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2180
        /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2181
         * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2182
         * for an instance field.
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2183
         *
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2184
         * @param name the unqualifed name of the field
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2185
         * @param declaringClass a {@link ClassDesc} describing the declaring class,
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2186
         *                       for field var handles
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2187
         * @param fieldType a {@link ClassDesc} describing the type of the field
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2188
         * @return the {@linkplain VarHandleDesc}
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2189
         * @throws NullPointerException if any of the arguments are null
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2190
         * @jvms 4.2.2 Unqualified Names
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2191
         */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2192
        public static VarHandleDesc ofField(ClassDesc declaringClass, String name, ClassDesc fieldType) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2193
            Objects.requireNonNull(declaringClass);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2194
            Objects.requireNonNull(name);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2195
            Objects.requireNonNull(fieldType);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2196
            return new VarHandleDesc(Kind.FIELD, name, declaringClass, fieldType);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2197
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2198
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2199
        /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2200
         * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2201
         * for a static field.
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2202
         *
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2203
         * @param name the unqualified name of the field
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2204
         * @param declaringClass a {@link ClassDesc} describing the declaring class,
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2205
         *                       for field var handles
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2206
         * @param fieldType a {@link ClassDesc} describing the type of the field
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2207
         * @return the {@linkplain VarHandleDesc}
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2208
         * @throws NullPointerException if any of the arguments are null
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2209
         * @jvms 4.2.2 Unqualified Names
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2210
         */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2211
        public static VarHandleDesc ofStaticField(ClassDesc declaringClass, String name, ClassDesc fieldType) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2212
            Objects.requireNonNull(declaringClass);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2213
            Objects.requireNonNull(name);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2214
            Objects.requireNonNull(fieldType);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2215
            return new VarHandleDesc(Kind.STATIC_FIELD, name, declaringClass, fieldType);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2216
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2217
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2218
        /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2219
         * Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
53563
a4b7ea85d668 8218022: Repeated words typos in java.base
prappo
parents: 53284
diff changeset
  2220
         * for an array type.
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2221
         *
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2222
         * @param arrayClass a {@link ClassDesc} describing the type of the array
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2223
         * @return the {@linkplain VarHandleDesc}
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2224
         * @throws NullPointerException if any of the arguments are null
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2225
         */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2226
        public static VarHandleDesc ofArray(ClassDesc arrayClass) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2227
            Objects.requireNonNull(arrayClass);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2228
            if (!arrayClass.isArray())
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2229
                throw new IllegalArgumentException("Array class argument not an array: " + arrayClass);
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2230
            return new VarHandleDesc(Kind.ARRAY, ConstantDescs.DEFAULT_NAME, arrayClass, arrayClass.componentType());
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2231
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2232
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2233
        /**
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2234
         * Returns a {@link ClassDesc} describing the type of the variable described
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2235
         * by this descriptor.
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2236
         *
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2237
         * @return the variable type
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2238
         */
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2239
        public ClassDesc varType() {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2240
            return varType;
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2241
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2242
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2243
        @Override
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2244
        public VarHandle resolveConstantDesc(MethodHandles.Lookup lookup)
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2245
                throws ReflectiveOperationException {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2246
            switch (kind) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2247
                case FIELD:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2248
                    return lookup.findVarHandle((Class<?>) declaringClass.resolveConstantDesc(lookup),
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2249
                                                constantName(),
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2250
                                                (Class<?>) varType.resolveConstantDesc(lookup));
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2251
                case STATIC_FIELD:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2252
                    return lookup.findStaticVarHandle((Class<?>) declaringClass.resolveConstantDesc(lookup),
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2253
                                                      constantName(),
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2254
                                                      (Class<?>) varType.resolveConstantDesc(lookup));
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2255
                case ARRAY:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2256
                    return MethodHandles.arrayElementVarHandle((Class<?>) declaringClass.resolveConstantDesc(lookup));
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2257
                default:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2258
                    throw new InternalError("Cannot reach here");
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2259
            }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2260
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2261
53019
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2262
        /**
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2263
         * Returns a compact textual description of this constant description.
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2264
         * For a field {@linkplain VarHandle}, includes the owner, name, and type
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2265
         * of the field, and whether it is static; for an array {@linkplain VarHandle},
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2266
         * the name of the component type.
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2267
         *
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2268
         * @return A compact textual description of this descriptor
4ddd3c410a85 8215300: additional changes to constants API
vromero
parents: 52914
diff changeset
  2269
         */
52914
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2270
        @Override
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2271
        public String toString() {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2272
            switch (kind) {
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2273
                case FIELD:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2274
                case STATIC_FIELD:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2275
                    return String.format("VarHandleDesc[%s%s.%s:%s]",
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2276
                                         (kind == Kind.STATIC_FIELD) ? "static " : "",
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2277
                                         declaringClass.displayName(), constantName(), varType.displayName());
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2278
                case ARRAY:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2279
                    return String.format("VarHandleDesc[%s[]]", declaringClass.displayName());
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2280
                default:
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2281
                    throw new InternalError("Cannot reach here");
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2282
            }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2283
        }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2284
    }
4fa75d8ad418 8210031: implementation for JVM Constants API
vromero
parents: 52220
diff changeset
  2285
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
  2286
}