author | prappo |
Wed, 30 Jan 2019 00:24:32 +0000 | |
changeset 53563 | a4b7ea85d668 |
parent 53284 | a995647f4911 |
child 54206 | 003cc64366da |
permissions | -rw-r--r-- |
36934 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package java.lang.invoke; |
|
27 |
||
52914 | 28 |
import java.lang.constant.ClassDesc; |
29 |
import java.lang.constant.Constable; |
|
30 |
import java.lang.constant.ConstantDesc; |
|
31 |
import java.lang.constant.ConstantDescs; |
|
32 |
import java.lang.constant.DirectMethodHandleDesc; |
|
33 |
import java.lang.constant.DynamicConstantDesc; |
|
34 |
import java.util.HashMap; |
|
35 |
import java.util.List; |
|
36 |
import java.util.Map; |
|
37 |
import java.util.Objects; |
|
38 |
import java.util.Optional; |
|
39 |
import java.util.function.BiFunction; |
|
40 |
import java.util.function.Function; |
|
41 |
||
36934 | 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 | 44 |
import jdk.internal.vm.annotation.ForceInline; |
37792 | 45 |
import jdk.internal.vm.annotation.Stable; |
36934 | 46 |
|
47 |
import static java.lang.invoke.MethodHandleStatics.UNSAFE; |
|
48 |
||
49 |
/** |
|
44860 | 50 |
* A VarHandle is a dynamically strongly typed reference to a variable, or to a |
36934 | 51 |
* parametrically-defined family of variables, including static fields, |
52 |
* non-static fields, array elements, or components of an off-heap data |
|
53 |
* structure. Access to such variables is supported under various |
|
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 | 56 |
* |
57 |
* <p>VarHandles are immutable and have no visible state. VarHandles cannot be |
|
58 |
* subclassed by the user. |
|
59 |
* |
|
60 |
* <p>A VarHandle has: |
|
61 |
* <ul> |
|
44860 | 62 |
* <li>a {@link #varType variable type} T, the type of every variable referenced |
63 |
* by this VarHandle; and |
|
64 |
* <li>a list of {@link #coordinateTypes coordinate types} |
|
65 |
* {@code CT1, CT2, ..., CTn}, the types of <em>coordinate expressions</em> that |
|
66 |
* jointly locate a variable referenced by this VarHandle. |
|
36934 | 67 |
* </ul> |
44860 | 68 |
* Variable and coordinate types may be primitive or reference, and are |
69 |
* represented by {@code Class} objects. The list of coordinate types may be |
|
70 |
* empty. |
|
36934 | 71 |
* |
72 |
* <p>Factory methods that produce or {@link java.lang.invoke.MethodHandles.Lookup |
|
44860 | 73 |
* lookup} VarHandle instances document the supported variable type and the list |
74 |
* of coordinate types. |
|
36934 | 75 |
* |
44860 | 76 |
* <p>Each access mode is associated with one <em>access mode method</em>, a |
77 |
* <a href="MethodHandle.html#sigpoly">signature polymorphic</a> method named |
|
78 |
* for the access mode. When an access mode method is invoked on a VarHandle |
|
79 |
* instance, the initial arguments to the invocation are coordinate expressions |
|
80 |
* that indicate in precisely which object the variable is to be accessed. |
|
81 |
* Trailing arguments to the invocation represent values of importance to the |
|
82 |
* access mode. For example, the various compare-and-set or compare-and-exchange |
|
83 |
* access modes require two trailing arguments for the variable's expected value |
|
84 |
* and new value. |
|
36934 | 85 |
* |
44860 | 86 |
* <p>The arity and types of arguments to the invocation of an access mode |
87 |
* method are not checked statically. Instead, each access mode method |
|
88 |
* specifies an {@link #accessModeType(AccessMode) access mode type}, |
|
89 |
* represented as an instance of {@link MethodType}, that serves as a kind of |
|
90 |
* method signature against which the arguments are checked dynamically. An |
|
91 |
* access mode type gives formal parameter types in terms of the coordinate |
|
92 |
* types of a VarHandle instance and the types for values of importance to the |
|
93 |
* access mode. An access mode type also gives a return type, often in terms of |
|
94 |
* the variable type of a VarHandle instance. When an access mode method is |
|
95 |
* invoked on a VarHandle instance, the symbolic type descriptor at the |
|
96 |
* call site, the run time types of arguments to the invocation, and the run |
|
97 |
* time type of the return value, must <a href="#invoke">match</a> the types |
|
98 |
* given in the access mode type. A runtime exception will be thrown if the |
|
99 |
* match fails. |
|
36934 | 100 |
* |
44860 | 101 |
* For example, the access mode method {@link #compareAndSet} specifies that if |
102 |
* its receiver is a VarHandle instance with coordinate types |
|
103 |
* {@code CT1, ..., CTn} and variable type {@code T}, then its access mode type |
|
104 |
* is {@code (CT1 c1, ..., CTn cn, T expectedValue, T newValue)boolean}. |
|
105 |
* Suppose that a VarHandle instance can access array elements, and that its |
|
106 |
* coordinate types are {@code String[]} and {@code int} while its variable type |
|
107 |
* is {@code String}. The access mode type for {@code compareAndSet} on this |
|
108 |
* VarHandle instance would be |
|
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 | 111 |
* {@link MethodHandles#arrayElementVarHandle(Class) array factory method} and |
112 |
* access array elements as follows: |
|
113 |
* <pre> {@code |
|
114 |
* String[] sa = ... |
|
115 |
* VarHandle avh = MethodHandles.arrayElementVarHandle(String[].class); |
|
116 |
* boolean r = avh.compareAndSet(sa, 10, "expected", "new"); |
|
117 |
* }</pre> |
|
36934 | 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 | 133 |
* <p>Access modes are grouped into the following categories: |
134 |
* <ul> |
|
135 |
* <li>read access modes that get the value of a variable under specified |
|
136 |
* memory ordering effects. |
|
137 |
* The set of corresponding access mode methods belonging to this group |
|
138 |
* consists of the methods |
|
139 |
* {@link #get get}, |
|
140 |
* {@link #getVolatile getVolatile}, |
|
141 |
* {@link #getAcquire getAcquire}, |
|
142 |
* {@link #getOpaque getOpaque}. |
|
143 |
* <li>write access modes that set the value of a variable under specified |
|
144 |
* memory ordering effects. |
|
145 |
* The set of corresponding access mode methods belonging to this group |
|
146 |
* consists of the methods |
|
147 |
* {@link #set set}, |
|
148 |
* {@link #setVolatile setVolatile}, |
|
149 |
* {@link #setRelease setRelease}, |
|
150 |
* {@link #setOpaque setOpaque}. |
|
151 |
* <li>atomic update access modes that, for example, atomically compare and set |
|
152 |
* the value of a variable under specified memory ordering effects. |
|
153 |
* The set of corresponding access mode methods belonging to this group |
|
154 |
* consists of the methods |
|
155 |
* {@link #compareAndSet compareAndSet}, |
|
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
156 |
* {@link #weakCompareAndSetPlain weakCompareAndSetPlain}, |
36934 | 157 |
* {@link #weakCompareAndSet weakCompareAndSet}, |
158 |
* {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire}, |
|
159 |
* {@link #weakCompareAndSetRelease weakCompareAndSetRelease}, |
|
160 |
* {@link #compareAndExchangeAcquire compareAndExchangeAcquire}, |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
38368
diff
changeset
|
161 |
* {@link #compareAndExchange compareAndExchange}, |
36934 | 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 | 166 |
* <li>numeric atomic update access modes that, for example, atomically get and |
167 |
* set with addition the value of a variable under specified memory ordering |
|
168 |
* effects. |
|
169 |
* The set of corresponding access mode methods belonging to this group |
|
170 |
* consists of the methods |
|
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 | 188 |
* </ul> |
189 |
* |
|
190 |
* <p>Factory methods that produce or {@link java.lang.invoke.MethodHandles.Lookup |
|
191 |
* lookup} VarHandle instances document the set of access modes that are |
|
192 |
* supported, which may also include documenting restrictions based on the |
|
193 |
* variable type and whether a variable is read-only. If an access mode is not |
|
44860 | 194 |
* supported then the corresponding access mode method will on invocation throw |
195 |
* an {@code UnsupportedOperationException}. Factory methods should document |
|
196 |
* any additional undeclared exceptions that may be thrown by access mode |
|
197 |
* methods. |
|
36934 | 198 |
* The {@link #get get} access mode is supported for all |
199 |
* VarHandle instances and the corresponding method never throws |
|
200 |
* {@code UnsupportedOperationException}. |
|
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 | 204 |
* {@code UnsupportedOperationException}. |
205 |
* Read/write access modes (if supported), with the exception of |
|
206 |
* {@code get} and {@code set}, provide atomic access for |
|
207 |
* reference types and all primitive types. |
|
208 |
* Unless stated otherwise in the documentation of a factory method, the access |
|
209 |
* modes {@code get} and {@code set} (if supported) provide atomic access for |
|
210 |
* reference types and all primitives types, with the exception of {@code long} |
|
37344 | 211 |
* and {@code double} on 32-bit platforms. |
36934 | 212 |
* |
213 |
* <p>Access modes will override any memory ordering effects specified at |
|
47478 | 214 |
* the declaration site of a variable. For example, a VarHandle accessing |
36934 | 215 |
* a field using the {@code get} access mode will access the field as |
216 |
* specified <em>by its access mode</em> even if that field is declared |
|
217 |
* {@code volatile}. When mixed access is performed extreme care should be |
|
218 |
* taken since the Java Memory Model may permit surprising results. |
|
219 |
* |
|
220 |
* <p>In addition to supporting access to variables under various access modes, |
|
221 |
* a set of static methods, referred to as memory fence methods, is also |
|
222 |
* provided for fine-grained control of memory ordering. |
|
223 |
* |
|
224 |
* The Java Language Specification permits other threads to observe operations |
|
225 |
* as if they were executed in orders different than are apparent in program |
|
226 |
* source code, subject to constraints arising, for example, from the use of |
|
227 |
* locks, {@code volatile} fields or VarHandles. The static methods, |
|
228 |
* {@link #fullFence fullFence}, {@link #acquireFence acquireFence}, |
|
229 |
* {@link #releaseFence releaseFence}, {@link #loadLoadFence loadLoadFence} and |
|
230 |
* {@link #storeStoreFence storeStoreFence}, can also be used to impose |
|
231 |
* constraints. Their specifications, as is the case for certain access modes, |
|
232 |
* are phrased in terms of the lack of "reorderings" -- observable ordering |
|
233 |
* effects that might otherwise occur if the fence was not present. More |
|
234 |
* precise phrasing of the specification of access mode methods and memory fence |
|
235 |
* methods may accompany future updates of the Java Language Specification. |
|
236 |
* |
|
44860 | 237 |
* <h1>Compiling invocation of access mode methods</h1> |
36934 | 238 |
* A Java method call expression naming an access mode method can invoke a |
239 |
* VarHandle from Java source code. From the viewpoint of source code, these |
|
240 |
* methods can take any arguments and their polymorphic result (if expressed) |
|
241 |
* can be cast to any return type. Formally this is accomplished by giving the |
|
242 |
* access mode methods variable arity {@code Object} arguments and |
|
243 |
* {@code Object} return types (if the return type is polymorphic), but they |
|
244 |
* have an additional quality called <em>signature polymorphism</em> which |
|
245 |
* connects this freedom of invocation directly to the JVM execution stack. |
|
246 |
* <p> |
|
247 |
* As is usual with virtual methods, source-level calls to access mode methods |
|
248 |
* compile to an {@code invokevirtual} instruction. More unusually, the |
|
249 |
* compiler must record the actual argument types, and may not perform method |
|
250 |
* invocation conversions on the arguments. Instead, it must generate |
|
251 |
* instructions to push them on the stack according to their own unconverted |
|
252 |
* types. The VarHandle object itself will be pushed on the stack before the |
|
253 |
* arguments. The compiler then generates an {@code invokevirtual} instruction |
|
254 |
* that invokes the access mode method with a symbolic type descriptor which |
|
255 |
* describes the argument and return types. |
|
256 |
* <p> |
|
257 |
* To issue a complete symbolic type descriptor, the compiler must also |
|
258 |
* determine the return type (if polymorphic). This is based on a cast on the |
|
259 |
* method invocation expression, if there is one, or else {@code Object} if the |
|
260 |
* invocation is an expression, or else {@code void} if the invocation is a |
|
261 |
* statement. The cast may be to a primitive type (but not {@code void}). |
|
262 |
* <p> |
|
263 |
* As a corner case, an uncasted {@code null} argument is given a symbolic type |
|
264 |
* descriptor of {@code java.lang.Void}. The ambiguity with the type |
|
265 |
* {@code Void} is harmless, since there are no references of type {@code Void} |
|
266 |
* except the null reference. |
|
267 |
* |
|
268 |
* |
|
44860 | 269 |
* <h1><a id="invoke">Performing invocation of access mode methods</a></h1> |
36934 | 270 |
* The first time an {@code invokevirtual} instruction is executed it is linked |
271 |
* by symbolically resolving the names in the instruction and verifying that |
|
272 |
* the method call is statically legal. This also holds for calls to access mode |
|
273 |
* methods. In this case, the symbolic type descriptor emitted by the compiler |
|
274 |
* is checked for correct syntax, and names it contains are resolved. Thus, an |
|
275 |
* {@code invokevirtual} instruction which invokes an access mode method will |
|
276 |
* always link, as long as the symbolic type descriptor is syntactically |
|
277 |
* well-formed and the types exist. |
|
278 |
* <p> |
|
279 |
* When the {@code invokevirtual} is executed after linking, the receiving |
|
280 |
* VarHandle's access mode type is first checked by the JVM to ensure that it |
|
281 |
* matches the symbolic type descriptor. If the type |
|
282 |
* match fails, it means that the access mode method which the caller is |
|
283 |
* invoking is not present on the individual VarHandle being invoked. |
|
284 |
* |
|
285 |
* <p> |
|
44860 | 286 |
* Invocation of an access mode method behaves as if an invocation of |
287 |
* {@link MethodHandle#invoke}, where the receiving method handle accepts the |
|
288 |
* VarHandle instance as the leading argument. More specifically, the |
|
289 |
* following, where {@code {access-mode}} corresponds to the access mode method |
|
290 |
* name: |
|
36934 | 291 |
* <pre> {@code |
292 |
* VarHandle vh = .. |
|
293 |
* R r = (R) vh.{access-mode}(p1, p2, ..., pN); |
|
294 |
* }</pre> |
|
44860 | 295 |
* behaves as if: |
36934 | 296 |
* <pre> {@code |
297 |
* VarHandle vh = .. |
|
44860 | 298 |
* VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}"); |
36934 | 299 |
* MethodHandle mh = MethodHandles.varHandleExactInvoker( |
44860 | 300 |
* am, |
301 |
* vh.accessModeType(am)); |
|
36934 | 302 |
* |
44860 | 303 |
* R r = (R) mh.invoke(vh, p1, p2, ..., pN) |
36934 | 304 |
* }</pre> |
44860 | 305 |
* (modulo access mode methods do not declare throwing of {@code Throwable}). |
306 |
* This is equivalent to: |
|
36934 | 307 |
* <pre> {@code |
308 |
* MethodHandle mh = MethodHandles.lookup().findVirtual( |
|
309 |
* VarHandle.class, |
|
44860 | 310 |
* "{access-mode}", |
36934 | 311 |
* MethodType.methodType(R, p1, p2, ..., pN)); |
312 |
* |
|
313 |
* R r = (R) mh.invokeExact(vh, p1, p2, ..., pN) |
|
314 |
* }</pre> |
|
315 |
* where the desired method type is the symbolic type descriptor and a |
|
316 |
* {@link MethodHandle#invokeExact} is performed, since before invocation of the |
|
317 |
* target, the handle will apply reference casts as necessary and box, unbox, or |
|
318 |
* widen primitive values, as if by {@link MethodHandle#asType asType} (see also |
|
319 |
* {@link MethodHandles#varHandleInvoker}). |
|
320 |
* |
|
44860 | 321 |
* More concisely, such behaviour is equivalent to: |
322 |
* <pre> {@code |
|
323 |
* VarHandle vh = .. |
|
324 |
* VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}"); |
|
325 |
* MethodHandle mh = vh.toMethodHandle(am); |
|
326 |
* |
|
327 |
* R r = (R) mh.invoke(p1, p2, ..., pN) |
|
328 |
* }</pre> |
|
329 |
* Where, in this case, the method handle is bound to the VarHandle instance. |
|
330 |
* |
|
331 |
* |
|
36934 | 332 |
* <h1>Invocation checking</h1> |
333 |
* In typical programs, VarHandle access mode type matching will usually |
|
334 |
* succeed. But if a match fails, the JVM will throw a |
|
335 |
* {@link WrongMethodTypeException}. |
|
336 |
* <p> |
|
337 |
* Thus, an access mode type mismatch which might show up as a linkage error |
|
338 |
* in a statically typed program can show up as a dynamic |
|
339 |
* {@code WrongMethodTypeException} in a program which uses VarHandles. |
|
340 |
* <p> |
|
341 |
* Because access mode types contain "live" {@code Class} objects, method type |
|
342 |
* matching takes into account both type names and class loaders. |
|
343 |
* Thus, even if a VarHandle {@code VH} is created in one class loader |
|
344 |
* {@code L1} and used in another {@code L2}, VarHandle access mode method |
|
345 |
* calls are type-safe, because the caller's symbolic type descriptor, as |
|
346 |
* resolved in {@code L2}, is matched against the original callee method's |
|
347 |
* symbolic type descriptor, as resolved in {@code L1}. The resolution in |
|
348 |
* {@code L1} happens when {@code VH} is created and its access mode types are |
|
349 |
* assigned, while the resolution in {@code L2} happens when the |
|
350 |
* {@code invokevirtual} instruction is linked. |
|
351 |
* <p> |
|
352 |
* Apart from type descriptor checks, a VarHandles's capability to |
|
353 |
* access it's variables is unrestricted. |
|
354 |
* If a VarHandle is formed on a non-public variable by a class that has access |
|
355 |
* to that variable, the resulting VarHandle can be used in any place by any |
|
356 |
* caller who receives a reference to it. |
|
357 |
* <p> |
|
358 |
* Unlike with the Core Reflection API, where access is checked every time a |
|
359 |
* reflective method is invoked, VarHandle access checking is performed |
|
360 |
* <a href="MethodHandles.Lookup.html#access">when the VarHandle is |
|
361 |
* created</a>. |
|
362 |
* Thus, VarHandles to non-public variables, or to variables in non-public |
|
363 |
* classes, should generally be kept secret. They should not be passed to |
|
364 |
* untrusted code unless their use from the untrusted code would be harmless. |
|
365 |
* |
|
366 |
* |
|
367 |
* <h1>VarHandle creation</h1> |
|
368 |
* Java code can create a VarHandle that directly accesses any field that is |
|
369 |
* accessible to that code. This is done via a reflective, capability-based |
|
370 |
* API called {@link java.lang.invoke.MethodHandles.Lookup |
|
371 |
* MethodHandles.Lookup}. |
|
372 |
* For example, a VarHandle for a non-static field can be obtained |
|
373 |
* from {@link java.lang.invoke.MethodHandles.Lookup#findVarHandle |
|
374 |
* Lookup.findVarHandle}. |
|
375 |
* There is also a conversion method from Core Reflection API objects, |
|
376 |
* {@link java.lang.invoke.MethodHandles.Lookup#unreflectVarHandle |
|
377 |
* Lookup.unreflectVarHandle}. |
|
378 |
* <p> |
|
379 |
* Access to protected field members is restricted to receivers only of the |
|
380 |
* accessing class, or one of its subclasses, and the accessing class must in |
|
381 |
* turn be a subclass (or package sibling) of the protected member's defining |
|
382 |
* class. If a VarHandle refers to a protected non-static field of a declaring |
|
383 |
* class outside the current package, the receiver argument will be narrowed to |
|
384 |
* the type of the accessing class. |
|
385 |
* |
|
386 |
* <h1>Interoperation between VarHandles and the Core Reflection API</h1> |
|
387 |
* Using factory methods in the {@link java.lang.invoke.MethodHandles.Lookup |
|
388 |
* Lookup} API, any field represented by a Core Reflection API object |
|
389 |
* can be converted to a behaviorally equivalent VarHandle. |
|
390 |
* For example, a reflective {@link java.lang.reflect.Field Field} can |
|
391 |
* be converted to a VarHandle using |
|
392 |
* {@link java.lang.invoke.MethodHandles.Lookup#unreflectVarHandle |
|
393 |
* Lookup.unreflectVarHandle}. |
|
394 |
* The resulting VarHandles generally provide more direct and efficient |
|
395 |
* access to the underlying fields. |
|
396 |
* <p> |
|
397 |
* As a special case, when the Core Reflection API is used to view the |
|
398 |
* signature polymorphic access mode methods in this class, they appear as |
|
399 |
* ordinary non-polymorphic methods. Their reflective appearance, as viewed by |
|
400 |
* {@link java.lang.Class#getDeclaredMethod Class.getDeclaredMethod}, |
|
401 |
* is unaffected by their special status in this API. |
|
402 |
* For example, {@link java.lang.reflect.Method#getModifiers |
|
403 |
* Method.getModifiers} |
|
404 |
* will report exactly those modifier bits required for any similarly |
|
405 |
* declared method, including in this case {@code native} and {@code varargs} |
|
406 |
* bits. |
|
407 |
* <p> |
|
408 |
* As with any reflected method, these methods (when reflected) may be invoked |
|
409 |
* directly via {@link java.lang.reflect.Method#invoke java.lang.reflect.Method.invoke}, |
|
410 |
* via JNI, or indirectly via |
|
411 |
* {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}. |
|
412 |
* However, such reflective calls do not result in access mode method |
|
413 |
* invocations. Such a call, if passed the required argument (a single one, of |
|
414 |
* type {@code Object[]}), will ignore the argument and will throw an |
|
415 |
* {@code UnsupportedOperationException}. |
|
416 |
* <p> |
|
417 |
* Since {@code invokevirtual} instructions can natively invoke VarHandle |
|
418 |
* access mode methods under any symbolic type descriptor, this reflective view |
|
419 |
* conflicts with the normal presentation of these methods via bytecodes. |
|
420 |
* Thus, these native methods, when reflectively viewed by |
|
421 |
* {@code Class.getDeclaredMethod}, may be regarded as placeholders only. |
|
422 |
* <p> |
|
423 |
* In order to obtain an invoker method for a particular access mode type, |
|
424 |
* use {@link java.lang.invoke.MethodHandles#varHandleExactInvoker} or |
|
425 |
* {@link java.lang.invoke.MethodHandles#varHandleInvoker}. The |
|
426 |
* {@link java.lang.invoke.MethodHandles.Lookup#findVirtual Lookup.findVirtual} |
|
427 |
* API is also able to return a method handle to call an access mode method for |
|
428 |
* any specified access mode type and is equivalent in behaviour to |
|
429 |
* {@link java.lang.invoke.MethodHandles#varHandleInvoker}. |
|
430 |
* |
|
431 |
* <h1>Interoperation between VarHandles and Java generics</h1> |
|
47478 | 432 |
* A VarHandle can be obtained for a variable, such as a field, which is |
36934 | 433 |
* declared with Java generic types. As with the Core Reflection API, the |
434 |
* VarHandle's variable type will be constructed from the erasure of the |
|
435 |
* source-level type. When a VarHandle access mode method is invoked, the |
|
436 |
* types |
|
437 |
* of its arguments or the return value cast type may be generic types or type |
|
438 |
* instances. If this occurs, the compiler will replace those types by their |
|
439 |
* erasures when it constructs the symbolic type descriptor for the |
|
440 |
* {@code invokevirtual} instruction. |
|
441 |
* |
|
442 |
* @see MethodHandle |
|
443 |
* @see MethodHandles |
|
444 |
* @see MethodType |
|
445 |
* @since 9 |
|
446 |
*/ |
|
52914 | 447 |
public abstract class VarHandle implements Constable { |
36934 | 448 |
final VarForm vform; |
449 |
||
37792 | 450 |
VarHandle(VarForm vform) { |
36934 | 451 |
this.vform = vform; |
452 |
} |
|
453 |
||
454 |
RuntimeException unsupported() { |
|
455 |
return new UnsupportedOperationException(); |
|
456 |
} |
|
457 |
||
458 |
// Plain accessors |
|
459 |
||
460 |
/** |
|
461 |
* Returns the value of a variable, with memory semantics of reading as |
|
462 |
* if the variable was declared non-{@code volatile}. Commonly referred to |
|
463 |
* as plain read access. |
|
464 |
* |
|
44860 | 465 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. |
36934 | 466 |
* |
467 |
* <p>The symbolic type descriptor at the call site of {@code get} |
|
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 | 470 |
* |
471 |
* <p>This access mode is supported by all VarHandle instances and never |
|
472 |
* throws {@code UnsupportedOperationException}. |
|
473 |
* |
|
474 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 475 |
* {@code (CT1 ct1, ..., CTn)} |
36934 | 476 |
* , statically represented using varargs. |
477 |
* @return the signature-polymorphic result that is the value of the |
|
478 |
* variable |
|
479 |
* , statically represented using {@code Object}. |
|
44860 | 480 |
* @throws WrongMethodTypeException if the access mode type does not |
481 |
* match the caller's symbolic type descriptor. |
|
482 |
* @throws ClassCastException if the access mode type matches the caller's |
|
483 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 484 |
*/ |
485 |
public final native |
|
486 |
@MethodHandle.PolymorphicSignature |
|
487 |
@HotSpotIntrinsicCandidate |
|
488 |
Object get(Object... args); |
|
489 |
||
490 |
/** |
|
491 |
* Sets the value of a variable to the {@code newValue}, with memory |
|
492 |
* semantics of setting as if the variable was declared non-{@code volatile} |
|
493 |
* and non-{@code final}. Commonly referred to as plain write access. |
|
494 |
* |
|
44860 | 495 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void} |
36934 | 496 |
* |
497 |
* <p>The symbolic type descriptor at the call site of {@code set} |
|
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 | 500 |
* |
501 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 502 |
* {@code (CT1 ct1, ..., CTn ctn, T newValue)} |
36934 | 503 |
* , statically represented using varargs. |
504 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
505 |
* for this VarHandle. |
|
44860 | 506 |
* @throws WrongMethodTypeException if the access mode type does not |
507 |
* match the caller's symbolic type descriptor. |
|
508 |
* @throws ClassCastException if the access mode type matches the caller's |
|
509 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 510 |
*/ |
511 |
public final native |
|
512 |
@MethodHandle.PolymorphicSignature |
|
513 |
@HotSpotIntrinsicCandidate |
|
514 |
void set(Object... args); |
|
515 |
||
516 |
||
517 |
// Volatile accessors |
|
518 |
||
519 |
/** |
|
520 |
* Returns the value of a variable, with memory semantics of reading as if |
|
521 |
* the variable was declared {@code volatile}. |
|
522 |
* |
|
44860 | 523 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. |
36934 | 524 |
* |
525 |
* <p>The symbolic type descriptor at the call site of {@code getVolatile} |
|
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 | 529 |
* |
530 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 531 |
* {@code (CT1 ct1, ..., CTn ctn)} |
36934 | 532 |
* , statically represented using varargs. |
533 |
* @return the signature-polymorphic result that is the value of the |
|
534 |
* variable |
|
535 |
* , statically represented using {@code Object}. |
|
536 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
537 |
* for this VarHandle. |
|
44860 | 538 |
* @throws WrongMethodTypeException if the access mode type does not |
539 |
* match the caller's symbolic type descriptor. |
|
540 |
* @throws ClassCastException if the access mode type matches the caller's |
|
541 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 542 |
*/ |
543 |
public final native |
|
544 |
@MethodHandle.PolymorphicSignature |
|
545 |
@HotSpotIntrinsicCandidate |
|
546 |
Object getVolatile(Object... args); |
|
547 |
||
548 |
/** |
|
549 |
* Sets the value of a variable to the {@code newValue}, with memory |
|
550 |
* semantics of setting as if the variable was declared {@code volatile}. |
|
551 |
* |
|
44860 | 552 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}. |
36934 | 553 |
* |
554 |
* <p>The symbolic type descriptor at the call site of {@code setVolatile} |
|
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 | 558 |
* |
37344 | 559 |
* @apiNote |
560 |
* Ignoring the many semantic differences from C and C++, this method has |
|
561 |
* memory ordering effects compatible with {@code memory_order_seq_cst}. |
|
562 |
* |
|
36934 | 563 |
* @param args the signature-polymorphic parameter list of the form |
44860 | 564 |
* {@code (CT1 ct1, ..., CTn ctn, T newValue)} |
36934 | 565 |
* , statically represented using varargs. |
566 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
567 |
* for this VarHandle. |
|
44860 | 568 |
* @throws WrongMethodTypeException if the access mode type does not |
569 |
* match the caller's symbolic type descriptor. |
|
570 |
* @throws ClassCastException if the access mode type matches the caller's |
|
571 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 572 |
*/ |
573 |
public final native |
|
574 |
@MethodHandle.PolymorphicSignature |
|
575 |
@HotSpotIntrinsicCandidate |
|
576 |
void setVolatile(Object... args); |
|
577 |
||
578 |
||
579 |
/** |
|
580 |
* Returns the value of a variable, accessed in program order, but with no |
|
581 |
* assurance of memory ordering effects with respect to other threads. |
|
582 |
* |
|
44860 | 583 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. |
36934 | 584 |
* |
585 |
* <p>The symbolic type descriptor at the call site of {@code getOpaque} |
|
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 | 589 |
* |
590 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 591 |
* {@code (CT1 ct1, ..., CTn ctn)} |
36934 | 592 |
* , statically represented using varargs. |
593 |
* @return the signature-polymorphic result that is the value of the |
|
594 |
* variable |
|
595 |
* , statically represented using {@code Object}. |
|
596 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
597 |
* for this VarHandle. |
|
44860 | 598 |
* @throws WrongMethodTypeException if the access mode type does not |
599 |
* match the caller's symbolic type descriptor. |
|
600 |
* @throws ClassCastException if the access mode type matches the caller's |
|
601 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 602 |
*/ |
603 |
public final native |
|
604 |
@MethodHandle.PolymorphicSignature |
|
605 |
@HotSpotIntrinsicCandidate |
|
606 |
Object getOpaque(Object... args); |
|
607 |
||
608 |
/** |
|
609 |
* Sets the value of a variable to the {@code newValue}, in program order, |
|
610 |
* but with no assurance of memory ordering effects with respect to other |
|
611 |
* threads. |
|
612 |
* |
|
44860 | 613 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}. |
36934 | 614 |
* |
615 |
* <p>The symbolic type descriptor at the call site of {@code setOpaque} |
|
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 | 619 |
* |
620 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 621 |
* {@code (CT1 ct1, ..., CTn ctn, T newValue)} |
36934 | 622 |
* , statically represented using varargs. |
623 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
624 |
* for this VarHandle. |
|
44860 | 625 |
* @throws WrongMethodTypeException if the access mode type does not |
626 |
* match the caller's symbolic type descriptor. |
|
627 |
* @throws ClassCastException if the access mode type matches the caller's |
|
628 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 629 |
*/ |
630 |
public final native |
|
631 |
@MethodHandle.PolymorphicSignature |
|
632 |
@HotSpotIntrinsicCandidate |
|
633 |
void setOpaque(Object... args); |
|
634 |
||
635 |
||
636 |
// Lazy accessors |
|
637 |
||
638 |
/** |
|
639 |
* Returns the value of a variable, and ensures that subsequent loads and |
|
640 |
* stores are not reordered before this access. |
|
641 |
* |
|
44860 | 642 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. |
36934 | 643 |
* |
644 |
* <p>The symbolic type descriptor at the call site of {@code getAcquire} |
|
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 | 648 |
* |
37344 | 649 |
* @apiNote |
650 |
* Ignoring the many semantic differences from C and C++, this method has |
|
651 |
* memory ordering effects compatible with {@code memory_order_acquire} |
|
652 |
* ordering. |
|
653 |
* |
|
36934 | 654 |
* @param args the signature-polymorphic parameter list of the form |
44860 | 655 |
* {@code (CT1 ct1, ..., CTn ctn)} |
36934 | 656 |
* , statically represented using varargs. |
657 |
* @return the signature-polymorphic result that is the value of the |
|
658 |
* variable |
|
659 |
* , statically represented using {@code Object}. |
|
660 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
661 |
* for this VarHandle. |
|
44860 | 662 |
* @throws WrongMethodTypeException if the access mode type does not |
663 |
* match the caller's symbolic type descriptor. |
|
664 |
* @throws ClassCastException if the access mode type matches the caller's |
|
665 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 666 |
*/ |
667 |
public final native |
|
668 |
@MethodHandle.PolymorphicSignature |
|
669 |
@HotSpotIntrinsicCandidate |
|
670 |
Object getAcquire(Object... args); |
|
671 |
||
672 |
/** |
|
673 |
* Sets the value of a variable to the {@code newValue}, and ensures that |
|
674 |
* prior loads and stores are not reordered after this access. |
|
675 |
* |
|
44860 | 676 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}. |
36934 | 677 |
* |
678 |
* <p>The symbolic type descriptor at the call site of {@code setRelease} |
|
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 | 682 |
* |
37344 | 683 |
* @apiNote |
684 |
* Ignoring the many semantic differences from C and C++, this method has |
|
685 |
* memory ordering effects compatible with {@code memory_order_release} |
|
686 |
* ordering. |
|
687 |
* |
|
36934 | 688 |
* @param args the signature-polymorphic parameter list of the form |
44860 | 689 |
* {@code (CT1 ct1, ..., CTn ctn, T newValue)} |
36934 | 690 |
* , statically represented using varargs. |
691 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
692 |
* for this VarHandle. |
|
44860 | 693 |
* @throws WrongMethodTypeException if the access mode type does not |
694 |
* match the caller's symbolic type descriptor. |
|
695 |
* @throws ClassCastException if the access mode type matches the caller's |
|
696 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 697 |
*/ |
698 |
public final native |
|
699 |
@MethodHandle.PolymorphicSignature |
|
700 |
@HotSpotIntrinsicCandidate |
|
701 |
void setRelease(Object... args); |
|
702 |
||
703 |
||
704 |
// Compare and set accessors |
|
705 |
||
706 |
/** |
|
707 |
* Atomically sets the value of a variable to the {@code newValue} with the |
|
708 |
* memory semantics of {@link #setVolatile} if the variable's current value, |
|
709 |
* referred to as the <em>witness value</em>, {@code ==} the |
|
710 |
* {@code expectedValue}, as accessed with the memory semantics of |
|
711 |
* {@link #getVolatile}. |
|
712 |
* |
|
44860 | 713 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. |
36934 | 714 |
* |
715 |
* <p>The symbolic type descriptor at the call site of {@code |
|
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 | 718 |
* this VarHandle. |
719 |
* |
|
720 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 721 |
* {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} |
36934 | 722 |
* , statically represented using varargs. |
723 |
* @return {@code true} if successful, otherwise {@code false} if the |
|
724 |
* witness value was not the same as the {@code expectedValue}. |
|
725 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
726 |
* for this VarHandle. |
|
44860 | 727 |
* @throws WrongMethodTypeException if the access mode type does not |
728 |
* match the caller's symbolic type descriptor. |
|
729 |
* @throws ClassCastException if the access mode type matches the caller's |
|
730 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 731 |
* @see #setVolatile(Object...) |
732 |
* @see #getVolatile(Object...) |
|
733 |
*/ |
|
734 |
public final native |
|
735 |
@MethodHandle.PolymorphicSignature |
|
736 |
@HotSpotIntrinsicCandidate |
|
737 |
boolean compareAndSet(Object... args); |
|
738 |
||
739 |
/** |
|
740 |
* Atomically sets the value of a variable to the {@code newValue} with the |
|
741 |
* memory semantics of {@link #setVolatile} if the variable's current value, |
|
742 |
* referred to as the <em>witness value</em>, {@code ==} the |
|
743 |
* {@code expectedValue}, as accessed with the memory semantics of |
|
744 |
* {@link #getVolatile}. |
|
745 |
* |
|
44860 | 746 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}. |
36934 | 747 |
* |
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 | 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 | 752 |
* on this VarHandle. |
753 |
* |
|
754 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 755 |
* {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} |
36934 | 756 |
* , statically represented using varargs. |
757 |
* @return the signature-polymorphic result that is the witness value, which |
|
758 |
* will be the same as the {@code expectedValue} if successful |
|
759 |
* , statically represented using {@code Object}. |
|
760 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
761 |
* for this VarHandle. |
|
762 |
* @throws WrongMethodTypeException if the access mode type is not |
|
763 |
* compatible with the caller's symbolic type descriptor. |
|
37344 | 764 |
* @throws ClassCastException if the access mode type is compatible with the |
765 |
* caller's symbolic type descriptor, but a reference cast fails. |
|
36934 | 766 |
* @see #setVolatile(Object...) |
767 |
* @see #getVolatile(Object...) |
|
768 |
*/ |
|
769 |
public final native |
|
770 |
@MethodHandle.PolymorphicSignature |
|
771 |
@HotSpotIntrinsicCandidate |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
38368
diff
changeset
|
772 |
Object compareAndExchange(Object... args); |
36934 | 773 |
|
774 |
/** |
|
775 |
* Atomically sets the value of a variable to the {@code newValue} with the |
|
776 |
* memory semantics of {@link #set} if the variable's current value, |
|
777 |
* referred to as the <em>witness value</em>, {@code ==} the |
|
778 |
* {@code expectedValue}, as accessed with the memory semantics of |
|
779 |
* {@link #getAcquire}. |
|
780 |
* |
|
44860 | 781 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}. |
36934 | 782 |
* |
783 |
* <p>The symbolic type descriptor at the call site of {@code |
|
784 |
* compareAndExchangeAcquire} |
|
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 | 787 |
* this VarHandle. |
788 |
* |
|
789 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 790 |
* {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} |
36934 | 791 |
* , statically represented using varargs. |
792 |
* @return the signature-polymorphic result that is the witness value, which |
|
793 |
* will be the same as the {@code expectedValue} if successful |
|
794 |
* , statically represented using {@code Object}. |
|
795 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
796 |
* for this VarHandle. |
|
44860 | 797 |
* @throws WrongMethodTypeException if the access mode type does not |
798 |
* match the caller's symbolic type descriptor. |
|
799 |
* @throws ClassCastException if the access mode type matches the caller's |
|
800 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 801 |
* @see #set(Object...) |
802 |
* @see #getAcquire(Object...) |
|
803 |
*/ |
|
804 |
public final native |
|
805 |
@MethodHandle.PolymorphicSignature |
|
806 |
@HotSpotIntrinsicCandidate |
|
807 |
Object compareAndExchangeAcquire(Object... args); |
|
808 |
||
809 |
/** |
|
810 |
* Atomically sets the value of a variable to the {@code newValue} with the |
|
811 |
* memory semantics of {@link #setRelease} if the variable's current value, |
|
812 |
* referred to as the <em>witness value</em>, {@code ==} the |
|
813 |
* {@code expectedValue}, as accessed with the memory semantics of |
|
814 |
* {@link #get}. |
|
815 |
* |
|
44860 | 816 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}. |
36934 | 817 |
* |
818 |
* <p>The symbolic type descriptor at the call site of {@code |
|
819 |
* compareAndExchangeRelease} |
|
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 | 823 |
* |
824 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 825 |
* {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} |
36934 | 826 |
* , statically represented using varargs. |
827 |
* @return the signature-polymorphic result that is the witness value, which |
|
828 |
* will be the same as the {@code expectedValue} if successful |
|
829 |
* , statically represented using {@code Object}. |
|
830 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
831 |
* for this VarHandle. |
|
44860 | 832 |
* @throws WrongMethodTypeException if the access mode type does not |
833 |
* match the caller's symbolic type descriptor. |
|
834 |
* @throws ClassCastException if the access mode type matches the caller's |
|
835 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 836 |
* @see #setRelease(Object...) |
837 |
* @see #get(Object...) |
|
838 |
*/ |
|
839 |
public final native |
|
840 |
@MethodHandle.PolymorphicSignature |
|
841 |
@HotSpotIntrinsicCandidate |
|
842 |
Object compareAndExchangeRelease(Object... args); |
|
843 |
||
844 |
// Weak (spurious failures allowed) |
|
845 |
||
846 |
/** |
|
847 |
* Possibly atomically sets the value of a variable to the {@code newValue} |
|
848 |
* with the semantics of {@link #set} if the variable's current value, |
|
849 |
* referred to as the <em>witness value</em>, {@code ==} the |
|
850 |
* {@code expectedValue}, as accessed with the memory semantics of |
|
851 |
* {@link #get}. |
|
852 |
* |
|
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 | 855 |
* |
44860 | 856 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. |
36934 | 857 |
* |
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 | 862 |
* |
863 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 864 |
* {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} |
36934 | 865 |
* , statically represented using varargs. |
866 |
* @return {@code true} if successful, otherwise {@code false} if the |
|
867 |
* witness value was not the same as the {@code expectedValue} or if this |
|
868 |
* operation spuriously failed. |
|
869 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
870 |
* for this VarHandle. |
|
44860 | 871 |
* @throws WrongMethodTypeException if the access mode type does not |
872 |
* match the caller's symbolic type descriptor. |
|
873 |
* @throws ClassCastException if the access mode type matches the caller's |
|
874 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 875 |
* @see #set(Object...) |
876 |
* @see #get(Object...) |
|
877 |
*/ |
|
878 |
public final native |
|
879 |
@MethodHandle.PolymorphicSignature |
|
880 |
@HotSpotIntrinsicCandidate |
|
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
881 |
boolean weakCompareAndSetPlain(Object... args); |
36934 | 882 |
|
883 |
/** |
|
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 | 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 | 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 | 908 |
* @throws WrongMethodTypeException if the access mode type does not |
909 |
* match the caller's symbolic type descriptor. |
|
910 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 922 |
* with the semantics of {@link #set} if the variable's current value, |
923 |
* referred to as the <em>witness value</em>, {@code ==} the |
|
924 |
* {@code expectedValue}, as accessed with the memory semantics of |
|
925 |
* {@link #getAcquire}. |
|
926 |
* |
|
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 | 929 |
* |
44860 | 930 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. |
36934 | 931 |
* |
932 |
* <p>The symbolic type descriptor at the call site of {@code |
|
933 |
* weakCompareAndSetAcquire} |
|
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 | 937 |
* |
938 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 939 |
* {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} |
36934 | 940 |
* , statically represented using varargs. |
941 |
* @return {@code true} if successful, otherwise {@code false} if the |
|
942 |
* witness value was not the same as the {@code expectedValue} or if this |
|
943 |
* operation spuriously failed. |
|
944 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
945 |
* for this VarHandle. |
|
44860 | 946 |
* @throws WrongMethodTypeException if the access mode type does not |
947 |
* match the caller's symbolic type descriptor. |
|
948 |
* @throws ClassCastException if the access mode type matches the caller's |
|
949 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 950 |
* @see #set(Object...) |
951 |
* @see #getAcquire(Object...) |
|
952 |
*/ |
|
953 |
public final native |
|
954 |
@MethodHandle.PolymorphicSignature |
|
955 |
@HotSpotIntrinsicCandidate |
|
956 |
boolean weakCompareAndSetAcquire(Object... args); |
|
957 |
||
958 |
/** |
|
959 |
* Possibly atomically sets the value of a variable to the {@code newValue} |
|
960 |
* with the semantics of {@link #setRelease} if the variable's current |
|
961 |
* value, referred to as the <em>witness value</em>, {@code ==} the |
|
962 |
* {@code expectedValue}, as accessed with the memory semantics of |
|
963 |
* {@link #get}. |
|
964 |
* |
|
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 | 967 |
* |
44860 | 968 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. |
36934 | 969 |
* |
970 |
* <p>The symbolic type descriptor at the call site of {@code |
|
971 |
* weakCompareAndSetRelease} |
|
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 | 975 |
* |
976 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 977 |
* {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} |
36934 | 978 |
* , statically represented using varargs. |
979 |
* @return {@code true} if successful, otherwise {@code false} if the |
|
980 |
* witness value was not the same as the {@code expectedValue} or if this |
|
981 |
* operation spuriously failed. |
|
982 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
983 |
* for this VarHandle. |
|
44860 | 984 |
* @throws WrongMethodTypeException if the access mode type does not |
985 |
* match the caller's symbolic type descriptor. |
|
986 |
* @throws ClassCastException if the access mode type matches the caller's |
|
987 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 988 |
* @see #setRelease(Object...) |
989 |
* @see #get(Object...) |
|
990 |
*/ |
|
991 |
public final native |
|
992 |
@MethodHandle.PolymorphicSignature |
|
993 |
@HotSpotIntrinsicCandidate |
|
994 |
boolean weakCompareAndSetRelease(Object... args); |
|
995 |
||
996 |
/** |
|
997 |
* Atomically sets the value of a variable to the {@code newValue} with the |
|
998 |
* memory semantics of {@link #setVolatile} and returns the variable's |
|
999 |
* previous value, as accessed with the memory semantics of |
|
1000 |
* {@link #getVolatile}. |
|
1001 |
* |
|
44860 | 1002 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)T}. |
36934 | 1003 |
* |
1004 |
* <p>The symbolic type descriptor at the call site of {@code getAndSet} |
|
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 | 1008 |
* |
1009 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 1010 |
* {@code (CT1 ct1, ..., CTn ctn, T newValue)} |
36934 | 1011 |
* , statically represented using varargs. |
1012 |
* @return the signature-polymorphic result that is the previous value of |
|
1013 |
* the variable |
|
1014 |
* , statically represented using {@code Object}. |
|
1015 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
1016 |
* for this VarHandle. |
|
44860 | 1017 |
* @throws WrongMethodTypeException if the access mode type does not |
1018 |
* match the caller's symbolic type descriptor. |
|
1019 |
* @throws ClassCastException if the access mode type matches the caller's |
|
1020 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 1021 |
* @see #setVolatile(Object...) |
1022 |
* @see #getVolatile(Object...) |
|
1023 |
*/ |
|
1024 |
public final native |
|
1025 |
@MethodHandle.PolymorphicSignature |
|
1026 |
@HotSpotIntrinsicCandidate |
|
1027 |
Object getAndSet(Object... args); |
|
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 | 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 | 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 | 1050 |
* @throws WrongMethodTypeException if the access mode type does not |
1051 |
* match the caller's symbolic type descriptor. |
|
1052 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1083 |
* @throws WrongMethodTypeException if the access mode type does not |
1084 |
* match the caller's symbolic type descriptor. |
|
1085 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 1094 |
|
1095 |
// Primitive adders |
|
1096 |
// Throw UnsupportedOperationException for refs |
|
1097 |
||
1098 |
/** |
|
1099 |
* Atomically adds the {@code value} to the current value of a variable with |
|
1100 |
* the memory semantics of {@link #setVolatile}, and returns the variable's |
|
1101 |
* previous value, as accessed with the memory semantics of |
|
1102 |
* {@link #getVolatile}. |
|
1103 |
* |
|
44860 | 1104 |
* <p>The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T value)T}. |
36934 | 1105 |
* |
1106 |
* <p>The symbolic type descriptor at the call site of {@code getAndAdd} |
|
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 | 1110 |
* |
1111 |
* @param args the signature-polymorphic parameter list of the form |
|
44860 | 1112 |
* {@code (CT1 ct1, ..., CTn ctn, T value)} |
36934 | 1113 |
* , statically represented using varargs. |
1114 |
* @return the signature-polymorphic result that is the previous value of |
|
1115 |
* the variable |
|
1116 |
* , statically represented using {@code Object}. |
|
1117 |
* @throws UnsupportedOperationException if the access mode is unsupported |
|
1118 |
* for this VarHandle. |
|
44860 | 1119 |
* @throws WrongMethodTypeException if the access mode type does not |
1120 |
* match the caller's symbolic type descriptor. |
|
1121 |
* @throws ClassCastException if the access mode type matches the caller's |
|
1122 |
* symbolic type descriptor, but a reference cast fails. |
|
36934 | 1123 |
* @see #setVolatile(Object...) |
1124 |
* @see #getVolatile(Object...) |
|
1125 |
*/ |
|
1126 |
public final native |
|
1127 |
@MethodHandle.PolymorphicSignature |
|
1128 |
@HotSpotIntrinsicCandidate |
|
1129 |
Object getAndAdd(Object... args); |
|
1130 |
||
1131 |
/** |
|
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 | 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 | 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 | 1152 |
* @throws WrongMethodTypeException if the access mode type does not |
1153 |
* match the caller's symbolic type descriptor. |
|
1154 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1185 |
* @throws WrongMethodTypeException if the access mode type does not |
1186 |
* match the caller's symbolic type descriptor. |
|
1187 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1226 |
* @throws WrongMethodTypeException if the access mode type does not |
1227 |
* match the caller's symbolic type descriptor. |
|
1228 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1263 |
* @throws WrongMethodTypeException if the access mode type does not |
1264 |
* match the caller's symbolic type descriptor. |
|
1265 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1300 |
* @throws WrongMethodTypeException if the access mode type does not |
1301 |
* match the caller's symbolic type descriptor. |
|
1302 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1337 |
* @throws WrongMethodTypeException if the access mode type does not |
1338 |
* match the caller's symbolic type descriptor. |
|
1339 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1374 |
* @throws WrongMethodTypeException if the access mode type does not |
1375 |
* match the caller's symbolic type descriptor. |
|
1376 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1411 |
* @throws WrongMethodTypeException if the access mode type does not |
1412 |
* match the caller's symbolic type descriptor. |
|
1413 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1448 |
* @throws WrongMethodTypeException if the access mode type does not |
1449 |
* match the caller's symbolic type descriptor. |
|
1450 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1485 |
* @throws WrongMethodTypeException if the access mode type does not |
1486 |
* match the caller's symbolic type descriptor. |
|
1487 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 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 | 1522 |
* @throws WrongMethodTypeException if the access mode type does not |
1523 |
* match the caller's symbolic type descriptor. |
|
1524 |
* @throws ClassCastException if the access mode type matches the caller's |
|
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 | 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 | 1541 |
|
37792 | 1542 |
final Class<?> returnType; |
1543 |
final boolean isMonomorphicInReturnType; |
|
1544 |
||
1545 |
AccessType(Class<?> returnType) { |
|
1546 |
this.returnType = returnType; |
|
1547 |
isMonomorphicInReturnType = returnType != Object.class; |
|
36934 | 1548 |
} |
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 | 1585 |
|
1586 |
private static Class<?>[] allocateParameters(int values, |
|
1587 |
Class<?> receiver, Class<?>... intermediate) { |
|
1588 |
int size = ((receiver != null) ? 1 : 0) + intermediate.length + values; |
|
1589 |
return new Class<?>[size]; |
|
1590 |
} |
|
1591 |
||
1592 |
private static int fillParameters(Class<?>[] ps, |
|
1593 |
Class<?> receiver, Class<?>... intermediate) { |
|
1594 |
int i = 0; |
|
1595 |
if (receiver != null) |
|
1596 |
ps[i++] = receiver; |
|
1597 |
for (int j = 0; j < intermediate.length; j++) |
|
1598 |
ps[i++] = intermediate[j]; |
|
1599 |
return i; |
|
36934 | 1600 |
} |
1601 |
} |
|
1602 |
||
1603 |
/** |
|
1604 |
* The set of access modes that specify how a variable, referenced by a |
|
1605 |
* VarHandle, is accessed. |
|
1606 |
*/ |
|
1607 |
public enum AccessMode { |
|
1608 |
/** |
|
1609 |
* The access mode whose access is specified by the corresponding |
|
1610 |
* method |
|
1611 |
* {@link VarHandle#get VarHandle.get} |
|
1612 |
*/ |
|
37792 | 1613 |
GET("get", AccessType.GET), |
36934 | 1614 |
/** |
1615 |
* The access mode whose access is specified by the corresponding |
|
1616 |
* method |
|
1617 |
* {@link VarHandle#set VarHandle.set} |
|
1618 |
*/ |
|
37792 | 1619 |
SET("set", AccessType.SET), |
36934 | 1620 |
/** |
1621 |
* The access mode whose access is specified by the corresponding |
|
1622 |
* method |
|
1623 |
* {@link VarHandle#getVolatile VarHandle.getVolatile} |
|
1624 |
*/ |
|
37792 | 1625 |
GET_VOLATILE("getVolatile", AccessType.GET), |
36934 | 1626 |
/** |
1627 |
* The access mode whose access is specified by the corresponding |
|
1628 |
* method |
|
1629 |
* {@link VarHandle#setVolatile VarHandle.setVolatile} |
|
1630 |
*/ |
|
37792 | 1631 |
SET_VOLATILE("setVolatile", AccessType.SET), |
36934 | 1632 |
/** |
1633 |
* The access mode whose access is specified by the corresponding |
|
1634 |
* method |
|
1635 |
* {@link VarHandle#getAcquire VarHandle.getAcquire} |
|
1636 |
*/ |
|
37792 | 1637 |
GET_ACQUIRE("getAcquire", AccessType.GET), |
36934 | 1638 |
/** |
1639 |
* The access mode whose access is specified by the corresponding |
|
1640 |
* method |
|
1641 |
* {@link VarHandle#setRelease VarHandle.setRelease} |
|
1642 |
*/ |
|
37792 | 1643 |
SET_RELEASE("setRelease", AccessType.SET), |
36934 | 1644 |
/** |
1645 |
* The access mode whose access is specified by the corresponding |
|
1646 |
* method |
|
1647 |
* {@link VarHandle#getOpaque VarHandle.getOpaque} |
|
1648 |
*/ |
|
37792 | 1649 |
GET_OPAQUE("getOpaque", AccessType.GET), |
36934 | 1650 |
/** |
1651 |
* The access mode whose access is specified by the corresponding |
|
1652 |
* method |
|
1653 |
* {@link VarHandle#setOpaque VarHandle.setOpaque} |
|
1654 |
*/ |
|
37792 | 1655 |
SET_OPAQUE("setOpaque", AccessType.SET), |
36934 | 1656 |
/** |
1657 |
* The access mode whose access is specified by the corresponding |
|
1658 |
* method |
|
1659 |
* {@link VarHandle#compareAndSet VarHandle.compareAndSet} |
|
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 | 1662 |
/** |
1663 |
* The access mode whose access is specified by the corresponding |
|
1664 |
* method |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
38368
diff
changeset
|
1665 |
* {@link VarHandle#compareAndExchange VarHandle.compareAndExchange} |
36934 | 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 | 1668 |
/** |
1669 |
* The access mode whose access is specified by the corresponding |
|
1670 |
* method |
|
1671 |
* {@link VarHandle#compareAndExchangeAcquire VarHandle.compareAndExchangeAcquire} |
|
1672 |
*/ |
|
37792 | 1673 |
COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE), |
36934 | 1674 |
/** |
1675 |
* The access mode whose access is specified by the corresponding |
|
1676 |
* method |
|
1677 |
* {@link VarHandle#compareAndExchangeRelease VarHandle.compareAndExchangeRelease} |
|
1678 |
*/ |
|
37792 | 1679 |
COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE), |
36934 | 1680 |
/** |
1681 |
* The access mode whose access is specified by the corresponding |
|
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 | 1689 |
* {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet} |
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 | 1695 |
* {@link VarHandle#weakCompareAndSetAcquire VarHandle.weakCompareAndSetAcquire} |
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 | 1698 |
/** |
1699 |
* The access mode whose access is specified by the corresponding |
|
1700 |
* method |
|
1701 |
* {@link VarHandle#weakCompareAndSetRelease VarHandle.weakCompareAndSetRelease} |
|
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 | 1704 |
/** |
1705 |
* The access mode whose access is specified by the corresponding |
|
1706 |
* method |
|
1707 |
* {@link VarHandle#getAndSet VarHandle.getAndSet} |
|
1708 |
*/ |
|
37792 | 1709 |
GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE), |
36934 | 1710 |
/** |
1711 |
* The access mode whose access is specified by the corresponding |
|
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 | 1725 |
* {@link VarHandle#getAndAdd VarHandle.getAndAdd} |
1726 |
*/ |
|
37792 | 1727 |
GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE), |
36934 | 1728 |
/** |
1729 |
* The access mode whose access is specified by the corresponding |
|
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 | 1794 |
; |
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 | 1809 |
final AccessType at; |
1810 |
||
37792 | 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 | 1813 |
this.at = at; |
1814 |
} |
|
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 | 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 | 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 | 1845 |
@ForceInline |
1846 |
static MemberName getMemberName(int ordinal, VarForm vform) { |
|
37792 | 1847 |
return vform.memberName_table[ordinal]; |
36934 | 1848 |
} |
1849 |
} |
|
1850 |
||
1851 |
static final class AccessDescriptor { |
|
37792 | 1852 |
final MethodType symbolicMethodTypeErased; |
1853 |
final MethodType symbolicMethodTypeInvoker; |
|
1854 |
final Class<?> returnType; |
|
36934 | 1855 |
final int type; |
1856 |
final int mode; |
|
1857 |
||
1858 |
public AccessDescriptor(MethodType symbolicMethodType, int type, int mode) { |
|
37792 | 1859 |
this.symbolicMethodTypeErased = symbolicMethodType.erase(); |
1860 |
this.symbolicMethodTypeInvoker = symbolicMethodType.insertParameterTypes(0, VarHandle.class); |
|
1861 |
this.returnType = symbolicMethodType.returnType(); |
|
36934 | 1862 |
this.type = type; |
1863 |
this.mode = mode; |
|
1864 |
} |
|
1865 |
} |
|
1866 |
||
53019 | 1867 |
/** |
1868 |
* Returns a compact textual description of this {@linkplain VarHandle}, |
|
1869 |
* including the type of variable described, and a description of its coordinates. |
|
1870 |
* |
|
1871 |
* @return A compact textual description of this {@linkplain VarHandle} |
|
1872 |
*/ |
|
52914 | 1873 |
@Override |
1874 |
public final String toString() { |
|
1875 |
return String.format("VarHandle[varType=%s, coord=%s]", |
|
1876 |
varType().getName(), |
|
1877 |
coordinateTypes()); |
|
1878 |
} |
|
1879 |
||
36934 | 1880 |
/** |
1881 |
* Returns the variable type of variables referenced by this VarHandle. |
|
1882 |
* |
|
1883 |
* @return the variable type of variables referenced by this VarHandle |
|
1884 |
*/ |
|
1885 |
public final Class<?> varType() { |
|
37792 | 1886 |
MethodType typeSet = accessModeType(AccessMode.SET); |
36934 | 1887 |
return typeSet.parameterType(typeSet.parameterCount() - 1); |
1888 |
} |
|
1889 |
||
1890 |
/** |
|
1891 |
* Returns the coordinate types for this VarHandle. |
|
1892 |
* |
|
1893 |
* @return the coordinate types for this VarHandle. The returned |
|
1894 |
* list is unmodifiable |
|
1895 |
*/ |
|
1896 |
public final List<Class<?>> coordinateTypes() { |
|
37792 | 1897 |
MethodType typeGet = accessModeType(AccessMode.GET); |
36934 | 1898 |
return typeGet.parameterList(); |
1899 |
} |
|
1900 |
||
1901 |
/** |
|
44860 | 1902 |
* Obtains the access mode type for this VarHandle and a given access mode. |
36934 | 1903 |
* |
1904 |
* <p>The access mode type's parameter types will consist of a prefix that |
|
1905 |
* is the coordinate types of this VarHandle followed by further |
|
44860 | 1906 |
* types as defined by the access mode method. |
36934 | 1907 |
* The access mode type's return type is defined by the return type of the |
44860 | 1908 |
* access mode method. |
36934 | 1909 |
* |
1910 |
* @param accessMode the access mode, corresponding to the |
|
1911 |
* signature-polymorphic method of the same name |
|
1912 |
* @return the access mode type for the given access mode |
|
1913 |
*/ |
|
1914 |
public final MethodType accessModeType(AccessMode accessMode) { |
|
37792 | 1915 |
TypesAndInvokers tis = getTypesAndInvokers(); |
1916 |
MethodType mt = tis.methodType_table[accessMode.at.ordinal()]; |
|
1917 |
if (mt == null) { |
|
1918 |
mt = tis.methodType_table[accessMode.at.ordinal()] = |
|
1919 |
accessModeTypeUncached(accessMode); |
|
1920 |
} |
|
1921 |
return mt; |
|
36934 | 1922 |
} |
37792 | 1923 |
abstract MethodType accessModeTypeUncached(AccessMode accessMode); |
36934 | 1924 |
|
1925 |
/** |
|
1926 |
* Returns {@code true} if the given access mode is supported, otherwise |
|
1927 |
* {@code false}. |
|
1928 |
* |
|
1929 |
* <p>The return of a {@code false} value for a given access mode indicates |
|
1930 |
* that an {@code UnsupportedOperationException} is thrown on invocation |
|
44860 | 1931 |
* of the corresponding access mode method. |
36934 | 1932 |
* |
1933 |
* @param accessMode the access mode, corresponding to the |
|
1934 |
* signature-polymorphic method of the same name |
|
1935 |
* @return {@code true} if the given access mode is supported, otherwise |
|
1936 |
* {@code false}. |
|
1937 |
*/ |
|
1938 |
public final boolean isAccessModeSupported(AccessMode accessMode) { |
|
1939 |
return AccessMode.getMemberName(accessMode.ordinal(), vform) != null; |
|
1940 |
} |
|
1941 |
||
1942 |
/** |
|
1943 |
* Obtains a method handle bound to this VarHandle and the given access |
|
1944 |
* mode. |
|
1945 |
* |
|
1946 |
* @apiNote This method, for a VarHandle {@code vh} and access mode |
|
1947 |
* {@code {access-mode}}, returns a method handle that is equivalent to |
|
44860 | 1948 |
* method handle {@code bmh} in the following code (though it may be more |
36934 | 1949 |
* efficient): |
1950 |
* <pre>{@code |
|
1951 |
* MethodHandle mh = MethodHandles.varHandleExactInvoker( |
|
1952 |
* vh.accessModeType(VarHandle.AccessMode.{access-mode})); |
|
1953 |
* |
|
1954 |
* MethodHandle bmh = mh.bindTo(vh); |
|
1955 |
* }</pre> |
|
1956 |
* |
|
1957 |
* @param accessMode the access mode, corresponding to the |
|
1958 |
* signature-polymorphic method of the same name |
|
1959 |
* @return a method handle bound to this VarHandle and the given access mode |
|
1960 |
*/ |
|
1961 |
public final MethodHandle toMethodHandle(AccessMode accessMode) { |
|
1962 |
MemberName mn = AccessMode.getMemberName(accessMode.ordinal(), vform); |
|
1963 |
if (mn != null) { |
|
37792 | 1964 |
MethodHandle mh = getMethodHandle(accessMode.ordinal()); |
1965 |
return mh.bindTo(this); |
|
36934 | 1966 |
} |
1967 |
else { |
|
1968 |
// Ensure an UnsupportedOperationException is thrown |
|
1969 |
return MethodHandles.varHandleInvoker(accessMode, accessModeType(accessMode)). |
|
1970 |
bindTo(this); |
|
1971 |
} |
|
1972 |
} |
|
1973 |
||
52914 | 1974 |
/** |
1975 |
* Return a nominal descriptor for this instance, if one can be |
|
1976 |
* constructed, or an empty {@link Optional} if one cannot be. |
|
1977 |
* |
|
1978 |
* @return An {@link Optional} containing the resulting nominal descriptor, |
|
1979 |
* or an empty {@link Optional} if one cannot be constructed. |
|
1980 |
* @since 12 |
|
1981 |
*/ |
|
1982 |
@Override |
|
1983 |
public Optional<VarHandleDesc> describeConstable() { |
|
1984 |
// partial function for field and array only |
|
1985 |
return Optional.empty(); |
|
1986 |
} |
|
1987 |
||
37792 | 1988 |
@Stable |
1989 |
TypesAndInvokers typesAndInvokers; |
|
1990 |
||
1991 |
static class TypesAndInvokers { |
|
1992 |
final @Stable |
|
1993 |
MethodType[] methodType_table = |
|
1994 |
new MethodType[VarHandle.AccessType.values().length]; |
|
1995 |
||
1996 |
final @Stable |
|
1997 |
MethodHandle[] methodHandle_table = |
|
1998 |
new MethodHandle[AccessMode.values().length]; |
|
1999 |
} |
|
2000 |
||
2001 |
@ForceInline |
|
2002 |
private final TypesAndInvokers getTypesAndInvokers() { |
|
2003 |
TypesAndInvokers tis = typesAndInvokers; |
|
2004 |
if (tis == null) { |
|
2005 |
tis = typesAndInvokers = new TypesAndInvokers(); |
|
2006 |
} |
|
2007 |
return tis; |
|
2008 |
} |
|
2009 |
||
2010 |
@ForceInline |
|
2011 |
final MethodHandle getMethodHandle(int mode) { |
|
2012 |
TypesAndInvokers tis = getTypesAndInvokers(); |
|
2013 |
MethodHandle mh = tis.methodHandle_table[mode]; |
|
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 | 2016 |
} |
2017 |
return mh; |
|
2018 |
} |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37792
diff
changeset
|
2019 |
private final MethodHandle getMethodHandleUncached(int mode) { |
37792 | 2020 |
MethodType mt = accessModeType(AccessMode.values()[mode]). |
2021 |
insertParameterTypes(0, VarHandle.class); |
|
2022 |
MemberName mn = vform.getMemberName(mode); |
|
2023 |
DirectMethodHandle dmh = DirectMethodHandle.make(mn); |
|
2024 |
// Such a method handle must not be publically exposed directly |
|
2025 |
// otherwise it can be cracked, it must be transformed or rebound |
|
2026 |
// before exposure |
|
2027 |
MethodHandle mh = dmh.copyWith(mt, dmh.form); |
|
2028 |
assert mh.type().erase() == mn.getMethodType().erase(); |
|
2029 |
return mh; |
|
2030 |
} |
|
2031 |
||
2032 |
||
36934 | 2033 |
/*non-public*/ |
2034 |
final void updateVarForm(VarForm newVForm) { |
|
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 | 2037 |
UNSAFE.fullFence(); |
2038 |
} |
|
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 | 2048 |
|
2049 |
private static final long VFORM_OFFSET; |
|
2050 |
||
2051 |
static { |
|
46873
7ac2f551b0d6
8182487: Add Unsafe.objectFieldOffset(Class, String)
redestad
parents:
44860
diff
changeset
|
2052 |
VFORM_OFFSET = UNSAFE.objectFieldOffset(VarHandle.class, "vform"); |
37792 | 2053 |
|
2054 |
// The VarHandleGuards must be initialized to ensure correct |
|
2055 |
// compilation of the guard methods |
|
2056 |
UNSAFE.ensureClassInitialized(VarHandleGuards.class); |
|
36934 | 2057 |
} |
2058 |
||
2059 |
||
2060 |
// Fence methods |
|
2061 |
||
2062 |
/** |
|
2063 |
* Ensures that loads and stores before the fence will not be reordered |
|
2064 |
* with |
|
2065 |
* loads and stores after the fence. |
|
2066 |
* |
|
2067 |
* @apiNote Ignoring the many semantic differences from C and C++, this |
|
2068 |
* method has memory ordering effects compatible with |
|
2069 |
* {@code atomic_thread_fence(memory_order_seq_cst)} |
|
2070 |
*/ |
|
2071 |
@ForceInline |
|
2072 |
public static void fullFence() { |
|
2073 |
UNSAFE.fullFence(); |
|
2074 |
} |
|
2075 |
||
2076 |
/** |
|
2077 |
* Ensures that loads before the fence will not be reordered with loads and |
|
2078 |
* stores after the fence. |
|
2079 |
* |
|
2080 |
* @apiNote Ignoring the many semantic differences from C and C++, this |
|
2081 |
* method has memory ordering effects compatible with |
|
2082 |
* {@code atomic_thread_fence(memory_order_acquire)} |
|
2083 |
*/ |
|
2084 |
@ForceInline |
|
2085 |
public static void acquireFence() { |
|
2086 |
UNSAFE.loadFence(); |
|
2087 |
} |
|
2088 |
||
2089 |
/** |
|
2090 |
* Ensures that loads and stores before the fence will not be |
|
2091 |
* reordered with stores after the fence. |
|
2092 |
* |
|
2093 |
* @apiNote Ignoring the many semantic differences from C and C++, this |
|
2094 |
* method has memory ordering effects compatible with |
|
2095 |
* {@code atomic_thread_fence(memory_order_release)} |
|
2096 |
*/ |
|
2097 |
@ForceInline |
|
2098 |
public static void releaseFence() { |
|
2099 |
UNSAFE.storeFence(); |
|
2100 |
} |
|
2101 |
||
2102 |
/** |
|
2103 |
* Ensures that loads before the fence will not be reordered with |
|
2104 |
* loads after the fence. |
|
2105 |
*/ |
|
2106 |
@ForceInline |
|
2107 |
public static void loadLoadFence() { |
|
2108 |
UNSAFE.loadLoadFence(); |
|
2109 |
} |
|
2110 |
||
2111 |
/** |
|
2112 |
* Ensures that stores before the fence will not be reordered with |
|
2113 |
* stores after the fence. |
|
2114 |
*/ |
|
2115 |
@ForceInline |
|
2116 |
public static void storeStoreFence() { |
|
2117 |
UNSAFE.storeStoreFence(); |
|
2118 |
} |
|
52914 | 2119 |
|
2120 |
/** |
|
2121 |
* A <a href="package-summary.html#nominal">nominal descriptor</a> for a |
|
2122 |
* {@link VarHandle} constant. |
|
2123 |
* |
|
2124 |
* @since 12 |
|
2125 |
*/ |
|
2126 |
public static final class VarHandleDesc extends DynamicConstantDesc<VarHandle> { |
|
2127 |
||
2128 |
/** |
|
2129 |
* Kinds of variable handle descs |
|
2130 |
*/ |
|
2131 |
private enum Kind { |
|
2132 |
FIELD(ConstantDescs.BSM_VARHANDLE_FIELD), |
|
2133 |
STATIC_FIELD(ConstantDescs.BSM_VARHANDLE_STATIC_FIELD), |
|
2134 |
ARRAY(ConstantDescs.BSM_VARHANDLE_ARRAY); |
|
2135 |
||
2136 |
final DirectMethodHandleDesc bootstrapMethod; |
|
2137 |
||
2138 |
Kind(DirectMethodHandleDesc bootstrapMethod) { |
|
2139 |
this.bootstrapMethod = bootstrapMethod; |
|
2140 |
} |
|
2141 |
||
2142 |
ConstantDesc[] toBSMArgs(ClassDesc declaringClass, ClassDesc varType) { |
|
2143 |
switch (this) { |
|
2144 |
case FIELD: |
|
2145 |
case STATIC_FIELD: |
|
2146 |
return new ConstantDesc[] {declaringClass, varType }; |
|
2147 |
case ARRAY: |
|
2148 |
return new ConstantDesc[] {declaringClass }; |
|
2149 |
default: |
|
2150 |
throw new InternalError("Cannot reach here"); |
|
2151 |
} |
|
2152 |
} |
|
2153 |
} |
|
2154 |
||
2155 |
private final Kind kind; |
|
2156 |
private final ClassDesc declaringClass; |
|
2157 |
private final ClassDesc varType; |
|
2158 |
||
2159 |
/** |
|
2160 |
* Construct a {@linkplain VarHandleDesc} given a kind, name, and declaring |
|
2161 |
* class. |
|
2162 |
* |
|
53563 | 2163 |
* @param kind the kind of the var handle |
52914 | 2164 |
* @param name the unqualified name of the field, for field var handles; otherwise ignored |
2165 |
* @param declaringClass a {@link ClassDesc} describing the declaring class, |
|
2166 |
* for field var handles |
|
2167 |
* @param varType a {@link ClassDesc} describing the type of the variable |
|
2168 |
* @throws NullPointerException if any required argument is null |
|
2169 |
* @jvms 4.2.2 Unqualified Names |
|
2170 |
*/ |
|
2171 |
private VarHandleDesc(Kind kind, String name, ClassDesc declaringClass, ClassDesc varType) { |
|
2172 |
super(kind.bootstrapMethod, name, |
|
2173 |
ConstantDescs.CD_VarHandle, |
|
2174 |
kind.toBSMArgs(declaringClass, varType)); |
|
2175 |
this.kind = kind; |
|
2176 |
this.declaringClass = declaringClass; |
|
2177 |
this.varType = varType; |
|
2178 |
} |
|
2179 |
||
2180 |
/** |
|
2181 |
* Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle} |
|
2182 |
* for an instance field. |
|
2183 |
* |
|
2184 |
* @param name the unqualifed name of the field |
|
2185 |
* @param declaringClass a {@link ClassDesc} describing the declaring class, |
|
2186 |
* for field var handles |
|
2187 |
* @param fieldType a {@link ClassDesc} describing the type of the field |
|
2188 |
* @return the {@linkplain VarHandleDesc} |
|
2189 |
* @throws NullPointerException if any of the arguments are null |
|
2190 |
* @jvms 4.2.2 Unqualified Names |
|
2191 |
*/ |
|
2192 |
public static VarHandleDesc ofField(ClassDesc declaringClass, String name, ClassDesc fieldType) { |
|
2193 |
Objects.requireNonNull(declaringClass); |
|
2194 |
Objects.requireNonNull(name); |
|
2195 |
Objects.requireNonNull(fieldType); |
|
2196 |
return new VarHandleDesc(Kind.FIELD, name, declaringClass, fieldType); |
|
2197 |
} |
|
2198 |
||
2199 |
/** |
|
2200 |
* Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle} |
|
2201 |
* for a static field. |
|
2202 |
* |
|
2203 |
* @param name the unqualified name of the field |
|
2204 |
* @param declaringClass a {@link ClassDesc} describing the declaring class, |
|
2205 |
* for field var handles |
|
2206 |
* @param fieldType a {@link ClassDesc} describing the type of the field |
|
2207 |
* @return the {@linkplain VarHandleDesc} |
|
2208 |
* @throws NullPointerException if any of the arguments are null |
|
2209 |
* @jvms 4.2.2 Unqualified Names |
|
2210 |
*/ |
|
2211 |
public static VarHandleDesc ofStaticField(ClassDesc declaringClass, String name, ClassDesc fieldType) { |
|
2212 |
Objects.requireNonNull(declaringClass); |
|
2213 |
Objects.requireNonNull(name); |
|
2214 |
Objects.requireNonNull(fieldType); |
|
2215 |
return new VarHandleDesc(Kind.STATIC_FIELD, name, declaringClass, fieldType); |
|
2216 |
} |
|
2217 |
||
2218 |
/** |
|
2219 |
* Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle} |
|
53563 | 2220 |
* for an array type. |
52914 | 2221 |
* |
2222 |
* @param arrayClass a {@link ClassDesc} describing the type of the array |
|
2223 |
* @return the {@linkplain VarHandleDesc} |
|
2224 |
* @throws NullPointerException if any of the arguments are null |
|
2225 |
*/ |
|
2226 |
public static VarHandleDesc ofArray(ClassDesc arrayClass) { |
|
2227 |
Objects.requireNonNull(arrayClass); |
|
2228 |
if (!arrayClass.isArray()) |
|
2229 |
throw new IllegalArgumentException("Array class argument not an array: " + arrayClass); |
|
2230 |
return new VarHandleDesc(Kind.ARRAY, ConstantDescs.DEFAULT_NAME, arrayClass, arrayClass.componentType()); |
|
2231 |
} |
|
2232 |
||
2233 |
/** |
|
2234 |
* Returns a {@link ClassDesc} describing the type of the variable described |
|
2235 |
* by this descriptor. |
|
2236 |
* |
|
2237 |
* @return the variable type |
|
2238 |
*/ |
|
2239 |
public ClassDesc varType() { |
|
2240 |
return varType; |
|
2241 |
} |
|
2242 |
||
2243 |
@Override |
|
2244 |
public VarHandle resolveConstantDesc(MethodHandles.Lookup lookup) |
|
2245 |
throws ReflectiveOperationException { |
|
2246 |
switch (kind) { |
|
2247 |
case FIELD: |
|
2248 |
return lookup.findVarHandle((Class<?>) declaringClass.resolveConstantDesc(lookup), |
|
2249 |
constantName(), |
|
2250 |
(Class<?>) varType.resolveConstantDesc(lookup)); |
|
2251 |
case STATIC_FIELD: |
|
2252 |
return lookup.findStaticVarHandle((Class<?>) declaringClass.resolveConstantDesc(lookup), |
|
2253 |
constantName(), |
|
2254 |
(Class<?>) varType.resolveConstantDesc(lookup)); |
|
2255 |
case ARRAY: |
|
2256 |
return MethodHandles.arrayElementVarHandle((Class<?>) declaringClass.resolveConstantDesc(lookup)); |
|
2257 |
default: |
|
2258 |
throw new InternalError("Cannot reach here"); |
|
2259 |
} |
|
2260 |
} |
|
2261 |
||
53019 | 2262 |
/** |
2263 |
* Returns a compact textual description of this constant description. |
|
2264 |
* For a field {@linkplain VarHandle}, includes the owner, name, and type |
|
2265 |
* of the field, and whether it is static; for an array {@linkplain VarHandle}, |
|
2266 |
* the name of the component type. |
|
2267 |
* |
|
2268 |
* @return A compact textual description of this descriptor |
|
2269 |
*/ |
|
52914 | 2270 |
@Override |
2271 |
public String toString() { |
|
2272 |
switch (kind) { |
|
2273 |
case FIELD: |
|
2274 |
case STATIC_FIELD: |
|
2275 |
return String.format("VarHandleDesc[%s%s.%s:%s]", |
|
2276 |
(kind == Kind.STATIC_FIELD) ? "static " : "", |
|
2277 |
declaringClass.displayName(), constantName(), varType.displayName()); |
|
2278 |
case ARRAY: |
|
2279 |
return String.format("VarHandleDesc[%s[]]", declaringClass.displayName()); |
|
2280 |
default: |
|
2281 |
throw new InternalError("Cannot reach here"); |
|
2282 |
} |
|
2283 |
} |
|
2284 |
} |
|
2285 |
||
36934 | 2286 |
} |