1 /*
   2  * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.lang.invoke;
  26 
  27 import jdk.internal.util.Preconditions;
  28 import jdk.internal.vm.annotation.ForceInline;
  29 
  30 import java.lang.invoke.VarHandle.VarHandleDesc;
  31 import java.util.Objects;
  32 import java.util.Optional;
  33 
  34 import static java.lang.invoke.MethodHandleStatics.UNSAFE;
  35 
  36 #warn
  37 
  38 final class VarHandle$Type$s {
  39 
  40     static sealed class FieldInstanceReadOnly extends VarHandle {
  41         final long fieldOffset;
  42         final Class<?> receiverType;
  43 #if[Object]
  44         final Class<?> fieldType;
  45 #end[Object]
  46 
  47         FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
  48             this(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadOnly.FORM, false);
  49         }
  50 
  51         protected FieldInstanceReadOnly(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType},
  52                                         VarForm form, boolean exact) {
  53             super(form, exact);
  54             this.fieldOffset = fieldOffset;
  55             this.receiverType = receiverType;
  56 #if[Object]
  57             this.fieldType = fieldType;
  58 #end[Object]
  59         }
  60 
  61         @Override
  62         public FieldInstanceReadOnly withInvokeExactBehavior() {
  63             return hasInvokeExactBehavior()
  64                 ? this
  65                 : new FieldInstanceReadOnly(receiverType, fieldOffset{#if[Object]?, fieldType}, vform, true);
  66         }
  67 
  68         @Override
  69         public FieldInstanceReadOnly withInvokeBehavior() {
  70             return !hasInvokeExactBehavior()
  71                 ? this
  72                 : new FieldInstanceReadOnly(receiverType, fieldOffset{#if[Object]?, fieldType}, vform, false);
  73         }
  74 
  75         @Override
  76         final MethodType accessModeTypeUncached(AccessType at) {
  77             return at.accessModeType(receiverType, {#if[Object]?fieldType:$type$.class});
  78         }
  79 
  80         @Override
  81         public Optional<VarHandleDesc> describeConstable() {
  82             var receiverTypeRef = receiverType.describeConstable();
  83             var fieldTypeRef = {#if[Object]?fieldType:$type$.class}.describeConstable();
  84             if (!receiverTypeRef.isPresent() || !fieldTypeRef.isPresent())
  85                 return Optional.empty();
  86 
  87             // Reflect on this VarHandle to extract the field name
  88             String name = VarHandles.getFieldFromReceiverAndOffset(
  89                 receiverType, fieldOffset, {#if[Object]?fieldType:$type$.class}).getName();
  90             return Optional.of(VarHandleDesc.ofField(receiverTypeRef.get(), name, fieldTypeRef.get()));
  91         }
  92 
  93         @ForceInline
  94         static $type$ get(VarHandle ob, Object holder) {
  95             FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
  96             return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
  97                                  handle.fieldOffset);
  98         }
  99 
 100         @ForceInline
 101         static $type$ getVolatile(VarHandle ob, Object holder) {
 102             FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
 103             return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
 104                                  handle.fieldOffset);
 105         }
 106 
 107         @ForceInline
 108         static $type$ getOpaque(VarHandle ob, Object holder) {
 109             FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
 110             return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
 111                                  handle.fieldOffset);
 112         }
 113 
 114         @ForceInline
 115         static $type$ getAcquire(VarHandle ob, Object holder) {
 116             FieldInstanceReadOnly handle = (FieldInstanceReadOnly)ob;
 117             return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 118                                  handle.fieldOffset);
 119         }
 120 
 121         static final VarForm FORM = new VarForm(FieldInstanceReadOnly.class, Object.class, $type$.class);
 122     }
 123 
 124     static final class FieldInstanceReadWrite extends FieldInstanceReadOnly {
 125 
 126         FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 127             this(receiverType, fieldOffset{#if[Object]?, fieldType}, false);
 128         }
 129 
 130         private FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType},
 131                                        boolean exact) {
 132             super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.FORM, exact);
 133         }
 134 
 135         @Override
 136         public FieldInstanceReadWrite withInvokeExactBehavior() {
 137             return hasInvokeExactBehavior()
 138                 ? this
 139                 : new FieldInstanceReadWrite(receiverType, fieldOffset{#if[Object]?, fieldType}, true);
 140         }
 141 
 142         @Override
 143         public FieldInstanceReadWrite withInvokeBehavior() {
 144             return !hasInvokeExactBehavior()
 145                 ? this
 146                 : new FieldInstanceReadWrite(receiverType, fieldOffset{#if[Object]?, fieldType}, false);
 147         }
 148 
 149         @ForceInline
 150         static void set(VarHandle ob, Object holder, $type$ value) {
 151             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 152             UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 153                              handle.fieldOffset,
 154                              {#if[Object]?handle.fieldType.cast(value):value});
 155         }
 156 
 157         @ForceInline
 158         static void setVolatile(VarHandle ob, Object holder, $type$ value) {
 159             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 160             UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
 161                                      handle.fieldOffset,
 162                                      {#if[Object]?handle.fieldType.cast(value):value});
 163         }
 164 
 165         @ForceInline
 166         static void setOpaque(VarHandle ob, Object holder, $type$ value) {
 167             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 168             UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
 169                                    handle.fieldOffset,
 170                                    {#if[Object]?handle.fieldType.cast(value):value});
 171         }
 172 
 173         @ForceInline
 174         static void setRelease(VarHandle ob, Object holder, $type$ value) {
 175             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 176             UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 177                                     handle.fieldOffset,
 178                                     {#if[Object]?handle.fieldType.cast(value):value});
 179         }
 180 #if[CAS]
 181 
 182         @ForceInline
 183         static boolean compareAndSet(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 184             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 185             return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 186                                                handle.fieldOffset,
 187                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 188                                                {#if[Object]?handle.fieldType.cast(value):value});
 189         }
 190 
 191         @ForceInline
 192         static $type$ compareAndExchange(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 193             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 194             return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 195                                                handle.fieldOffset,
 196                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 197                                                {#if[Object]?handle.fieldType.cast(value):value});
 198         }
 199 
 200         @ForceInline
 201         static $type$ compareAndExchangeAcquire(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 202             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 203             return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 204                                                handle.fieldOffset,
 205                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 206                                                {#if[Object]?handle.fieldType.cast(value):value});
 207         }
 208 
 209         @ForceInline
 210         static $type$ compareAndExchangeRelease(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 211             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 212             return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 213                                                handle.fieldOffset,
 214                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 215                                                {#if[Object]?handle.fieldType.cast(value):value});
 216         }
 217 
 218         @ForceInline
 219         static boolean weakCompareAndSetPlain(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 220             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 221             return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)),
 222                                                handle.fieldOffset,
 223                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 224                                                {#if[Object]?handle.fieldType.cast(value):value});
 225         }
 226 
 227         @ForceInline
 228         static boolean weakCompareAndSet(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 229             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 230             return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 231                                                handle.fieldOffset,
 232                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 233                                                {#if[Object]?handle.fieldType.cast(value):value});
 234         }
 235 
 236         @ForceInline
 237         static boolean weakCompareAndSetAcquire(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 238             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 239             return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 240                                                handle.fieldOffset,
 241                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 242                                                {#if[Object]?handle.fieldType.cast(value):value});
 243         }
 244 
 245         @ForceInline
 246         static boolean weakCompareAndSetRelease(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 247             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 248             return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 249                                                handle.fieldOffset,
 250                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 251                                                {#if[Object]?handle.fieldType.cast(value):value});
 252         }
 253 
 254         @ForceInline
 255         static $type$ getAndSet(VarHandle ob, Object holder, $type$ value) {
 256             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 257             return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 258                                           handle.fieldOffset,
 259                                           {#if[Object]?handle.fieldType.cast(value):value});
 260         }
 261 
 262         @ForceInline
 263         static $type$ getAndSetAcquire(VarHandle ob, Object holder, $type$ value) {
 264             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 265             return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 266                                           handle.fieldOffset,
 267                                           {#if[Object]?handle.fieldType.cast(value):value});
 268         }
 269 
 270         @ForceInline
 271         static $type$ getAndSetRelease(VarHandle ob, Object holder, $type$ value) {
 272             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 273             return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 274                                           handle.fieldOffset,
 275                                           {#if[Object]?handle.fieldType.cast(value):value});
 276         }
 277 #end[CAS]
 278 #if[AtomicAdd]
 279 
 280         @ForceInline
 281         static $type$ getAndAdd(VarHandle ob, Object holder, $type$ value) {
 282             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 283             return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 284                                        handle.fieldOffset,
 285                                        value);
 286         }
 287 
 288         @ForceInline
 289         static $type$ getAndAddAcquire(VarHandle ob, Object holder, $type$ value) {
 290             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 291             return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 292                                        handle.fieldOffset,
 293                                        value);
 294         }
 295 
 296         @ForceInline
 297         static $type$ getAndAddRelease(VarHandle ob, Object holder, $type$ value) {
 298             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 299             return UNSAFE.getAndAdd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 300                                        handle.fieldOffset,
 301                                        value);
 302         }
 303 
 304 #end[AtomicAdd]
 305 #if[Bitwise]
 306 
 307         @ForceInline
 308         static $type$ getAndBitwiseOr(VarHandle ob, Object holder, $type$ value) {
 309             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 310             return UNSAFE.getAndBitwiseOr$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 311                                        handle.fieldOffset,
 312                                        value);
 313         }
 314 
 315         @ForceInline
 316         static $type$ getAndBitwiseOrRelease(VarHandle ob, Object holder, $type$ value) {
 317             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 318             return UNSAFE.getAndBitwiseOr$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 319                                        handle.fieldOffset,
 320                                        value);
 321         }
 322 
 323         @ForceInline
 324         static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object holder, $type$ value) {
 325             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 326             return UNSAFE.getAndBitwiseOr$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 327                                        handle.fieldOffset,
 328                                        value);
 329         }
 330 
 331         @ForceInline
 332         static $type$ getAndBitwiseAnd(VarHandle ob, Object holder, $type$ value) {
 333             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 334             return UNSAFE.getAndBitwiseAnd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 335                                        handle.fieldOffset,
 336                                        value);
 337         }
 338 
 339         @ForceInline
 340         static $type$ getAndBitwiseAndRelease(VarHandle ob, Object holder, $type$ value) {
 341             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 342             return UNSAFE.getAndBitwiseAnd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 343                                        handle.fieldOffset,
 344                                        value);
 345         }
 346 
 347         @ForceInline
 348         static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object holder, $type$ value) {
 349             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 350             return UNSAFE.getAndBitwiseAnd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 351                                        handle.fieldOffset,
 352                                        value);
 353         }
 354 
 355         @ForceInline
 356         static $type$ getAndBitwiseXor(VarHandle ob, Object holder, $type$ value) {
 357             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 358             return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 359                                        handle.fieldOffset,
 360                                        value);
 361         }
 362 
 363         @ForceInline
 364         static $type$ getAndBitwiseXorRelease(VarHandle ob, Object holder, $type$ value) {
 365             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 366             return UNSAFE.getAndBitwiseXor$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 367                                        handle.fieldOffset,
 368                                        value);
 369         }
 370 
 371         @ForceInline
 372         static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object holder, $type$ value) {
 373             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 374             return UNSAFE.getAndBitwiseXor$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 375                                        handle.fieldOffset,
 376                                        value);
 377         }
 378 #end[Bitwise]
 379 
 380         static final VarForm FORM = new VarForm(FieldInstanceReadWrite.class, Object.class, $type$.class);
 381     }
 382 
 383 
 384     static sealed class FieldStaticReadOnly extends VarHandle {
 385         final Class<?> declaringClass;
 386         final Object base;
 387         final long fieldOffset;
 388 #if[Object]
 389         final Class<?> fieldType;
 390 #end[Object]
 391 
 392         FieldStaticReadOnly(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 393             this(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadOnly.FORM, false);
 394         }
 395 
 396         protected FieldStaticReadOnly(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
 397                                       VarForm form, boolean exact) {
 398             super(form, exact);
 399             this.declaringClass = declaringClass;
 400             this.base = base;
 401             this.fieldOffset = fieldOffset;
 402 #if[Object]
 403             this.fieldType = fieldType;
 404 #end[Object]
 405         }
 406 
 407         @Override
 408         public FieldStaticReadOnly withInvokeExactBehavior() {
 409             return hasInvokeExactBehavior()
 410                 ? this
 411                 : new FieldStaticReadOnly(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, vform, true);
 412         }
 413 
 414         @Override
 415         public FieldStaticReadOnly withInvokeBehavior() {
 416             return !hasInvokeExactBehavior()
 417                 ? this
 418                 : new FieldStaticReadOnly(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, vform, false);
 419         }
 420 
 421         @Override
 422         public Optional<VarHandleDesc> describeConstable() {
 423             var fieldTypeRef = {#if[Object]?fieldType:$type$.class}.describeConstable();
 424             if (!fieldTypeRef.isPresent())
 425                 return Optional.empty();
 426 
 427             // Reflect on this VarHandle to extract the field name
 428             var staticField = VarHandles.getStaticFieldFromBaseAndOffset(
 429                 declaringClass, fieldOffset, {#if[Object]?fieldType:$type$.class});
 430             var declaringTypeRef = declaringClass.describeConstable();
 431             if (!declaringTypeRef.isPresent())
 432                 return Optional.empty();
 433             return Optional.of(VarHandleDesc.ofStaticField(declaringTypeRef.get(), staticField.getName(), fieldTypeRef.get()));
 434         }
 435 
 436         @Override
 437         final MethodType accessModeTypeUncached(AccessType at) {
 438             return at.accessModeType(null, {#if[Object]?fieldType:$type$.class});
 439         }
 440 
 441         @ForceInline
 442         static $type$ get(VarHandle ob) {
 443             FieldStaticReadOnly handle = (FieldStaticReadOnly) ob.target();
 444             return UNSAFE.get$Type$(handle.base,
 445                                  handle.fieldOffset);
 446         }
 447 
 448         @ForceInline
 449         static $type$ getVolatile(VarHandle ob) {
 450             FieldStaticReadOnly handle = (FieldStaticReadOnly) ob.target();
 451             return UNSAFE.get$Type$Volatile(handle.base,
 452                                  handle.fieldOffset);
 453         }
 454 
 455         @ForceInline
 456         static $type$ getOpaque(VarHandle ob) {
 457             FieldStaticReadOnly handle = (FieldStaticReadOnly) ob.target();
 458             return UNSAFE.get$Type$Opaque(handle.base,
 459                                  handle.fieldOffset);
 460         }
 461 
 462         @ForceInline
 463         static $type$ getAcquire(VarHandle ob) {
 464             FieldStaticReadOnly handle = (FieldStaticReadOnly) ob.target();
 465             return UNSAFE.get$Type$Acquire(handle.base,
 466                                  handle.fieldOffset);
 467         }
 468 
 469         static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, $type$.class);
 470     }
 471 
 472     static final class FieldStaticReadWrite extends FieldStaticReadOnly {
 473 
 474         FieldStaticReadWrite(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 475             this(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, false);
 476         }
 477 
 478         private FieldStaticReadWrite(Class<?> declaringClass, Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
 479                                      boolean exact) {
 480             super(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM, exact);
 481         }
 482 
 483         @Override
 484         public FieldStaticReadWrite withInvokeExactBehavior() {
 485             return hasInvokeExactBehavior()
 486                 ? this
 487                 : new FieldStaticReadWrite(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, true);
 488         }
 489 
 490         @Override
 491         public FieldStaticReadWrite withInvokeBehavior() {
 492             return !hasInvokeExactBehavior()
 493                 ? this
 494                 : new FieldStaticReadWrite(declaringClass, base, fieldOffset{#if[Object]?, fieldType}, false);
 495         }
 496 
 497         @ForceInline
 498         static void set(VarHandle ob, $type$ value) {
 499             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 500             UNSAFE.put$Type$(handle.base,
 501                              handle.fieldOffset,
 502                              {#if[Object]?handle.fieldType.cast(value):value});
 503         }
 504 
 505         @ForceInline
 506         static void setVolatile(VarHandle ob, $type$ value) {
 507             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 508             UNSAFE.put$Type$Volatile(handle.base,
 509                                      handle.fieldOffset,
 510                                      {#if[Object]?handle.fieldType.cast(value):value});
 511         }
 512 
 513         @ForceInline
 514         static void setOpaque(VarHandle ob, $type$ value) {
 515             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 516             UNSAFE.put$Type$Opaque(handle.base,
 517                                    handle.fieldOffset,
 518                                    {#if[Object]?handle.fieldType.cast(value):value});
 519         }
 520 
 521         @ForceInline
 522         static void setRelease(VarHandle ob, $type$ value) {
 523             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 524             UNSAFE.put$Type$Release(handle.base,
 525                                     handle.fieldOffset,
 526                                     {#if[Object]?handle.fieldType.cast(value):value});
 527         }
 528 #if[CAS]
 529 
 530         @ForceInline
 531         static boolean compareAndSet(VarHandle ob, $type$ expected, $type$ value) {
 532             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 533             return UNSAFE.compareAndSet$Type$(handle.base,
 534                                                handle.fieldOffset,
 535                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 536                                                {#if[Object]?handle.fieldType.cast(value):value});
 537         }
 538 
 539 
 540         @ForceInline
 541         static $type$ compareAndExchange(VarHandle ob, $type$ expected, $type$ value) {
 542             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 543             return UNSAFE.compareAndExchange$Type$(handle.base,
 544                                                handle.fieldOffset,
 545                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 546                                                {#if[Object]?handle.fieldType.cast(value):value});
 547         }
 548 
 549         @ForceInline
 550         static $type$ compareAndExchangeAcquire(VarHandle ob, $type$ expected, $type$ value) {
 551             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 552             return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
 553                                                handle.fieldOffset,
 554                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 555                                                {#if[Object]?handle.fieldType.cast(value):value});
 556         }
 557 
 558         @ForceInline
 559         static $type$ compareAndExchangeRelease(VarHandle ob, $type$ expected, $type$ value) {
 560             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 561             return UNSAFE.compareAndExchange$Type$Release(handle.base,
 562                                                handle.fieldOffset,
 563                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 564                                                {#if[Object]?handle.fieldType.cast(value):value});
 565         }
 566 
 567         @ForceInline
 568         static boolean weakCompareAndSetPlain(VarHandle ob, $type$ expected, $type$ value) {
 569             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 570             return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
 571                                                handle.fieldOffset,
 572                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 573                                                {#if[Object]?handle.fieldType.cast(value):value});
 574         }
 575 
 576         @ForceInline
 577         static boolean weakCompareAndSet(VarHandle ob, $type$ expected, $type$ value) {
 578             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 579             return UNSAFE.weakCompareAndSet$Type$(handle.base,
 580                                                handle.fieldOffset,
 581                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 582                                                {#if[Object]?handle.fieldType.cast(value):value});
 583         }
 584 
 585         @ForceInline
 586         static boolean weakCompareAndSetAcquire(VarHandle ob, $type$ expected, $type$ value) {
 587             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 588             return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
 589                                                handle.fieldOffset,
 590                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 591                                                {#if[Object]?handle.fieldType.cast(value):value});
 592         }
 593 
 594         @ForceInline
 595         static boolean weakCompareAndSetRelease(VarHandle ob, $type$ expected, $type$ value) {
 596             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 597             return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
 598                                                handle.fieldOffset,
 599                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 600                                                {#if[Object]?handle.fieldType.cast(value):value});
 601         }
 602 
 603         @ForceInline
 604         static $type$ getAndSet(VarHandle ob, $type$ value) {
 605             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 606             return UNSAFE.getAndSet$Type$(handle.base,
 607                                           handle.fieldOffset,
 608                                           {#if[Object]?handle.fieldType.cast(value):value});
 609         }
 610 
 611         @ForceInline
 612         static $type$ getAndSetAcquire(VarHandle ob, $type$ value) {
 613             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 614             return UNSAFE.getAndSet$Type$Acquire(handle.base,
 615                                           handle.fieldOffset,
 616                                           {#if[Object]?handle.fieldType.cast(value):value});
 617         }
 618 
 619         @ForceInline
 620         static $type$ getAndSetRelease(VarHandle ob, $type$ value) {
 621             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 622             return UNSAFE.getAndSet$Type$Release(handle.base,
 623                                           handle.fieldOffset,
 624                                           {#if[Object]?handle.fieldType.cast(value):value});
 625         }
 626 #end[CAS]
 627 #if[AtomicAdd]
 628 
 629         @ForceInline
 630         static $type$ getAndAdd(VarHandle ob, $type$ value) {
 631             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 632             return UNSAFE.getAndAdd$Type$(handle.base,
 633                                        handle.fieldOffset,
 634                                        value);
 635         }
 636 
 637         @ForceInline
 638         static $type$ getAndAddAcquire(VarHandle ob, $type$ value) {
 639             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 640             return UNSAFE.getAndAdd$Type$Acquire(handle.base,
 641                                        handle.fieldOffset,
 642                                        value);
 643         }
 644 
 645         @ForceInline
 646         static $type$ getAndAddRelease(VarHandle ob, $type$ value) {
 647             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 648             return UNSAFE.getAndAdd$Type$Release(handle.base,
 649                                        handle.fieldOffset,
 650                                        value);
 651         }
 652 #end[AtomicAdd]
 653 #if[Bitwise]
 654 
 655         @ForceInline
 656         static $type$ getAndBitwiseOr(VarHandle ob, $type$ value) {
 657             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 658             return UNSAFE.getAndBitwiseOr$Type$(handle.base,
 659                                        handle.fieldOffset,
 660                                        value);
 661         }
 662 
 663         @ForceInline
 664         static $type$ getAndBitwiseOrRelease(VarHandle ob, $type$ value) {
 665             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 666             return UNSAFE.getAndBitwiseOr$Type$Release(handle.base,
 667                                        handle.fieldOffset,
 668                                        value);
 669         }
 670 
 671         @ForceInline
 672         static $type$ getAndBitwiseOrAcquire(VarHandle ob, $type$ value) {
 673             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 674             return UNSAFE.getAndBitwiseOr$Type$Acquire(handle.base,
 675                                        handle.fieldOffset,
 676                                        value);
 677         }
 678 
 679         @ForceInline
 680         static $type$ getAndBitwiseAnd(VarHandle ob, $type$ value) {
 681             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 682             return UNSAFE.getAndBitwiseAnd$Type$(handle.base,
 683                                        handle.fieldOffset,
 684                                        value);
 685         }
 686 
 687         @ForceInline
 688         static $type$ getAndBitwiseAndRelease(VarHandle ob, $type$ value) {
 689             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 690             return UNSAFE.getAndBitwiseAnd$Type$Release(handle.base,
 691                                        handle.fieldOffset,
 692                                        value);
 693         }
 694 
 695         @ForceInline
 696         static $type$ getAndBitwiseAndAcquire(VarHandle ob, $type$ value) {
 697             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 698             return UNSAFE.getAndBitwiseAnd$Type$Acquire(handle.base,
 699                                        handle.fieldOffset,
 700                                        value);
 701         }
 702 
 703         @ForceInline
 704         static $type$ getAndBitwiseXor(VarHandle ob, $type$ value) {
 705             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 706             return UNSAFE.getAndBitwiseXor$Type$(handle.base,
 707                                        handle.fieldOffset,
 708                                        value);
 709         }
 710 
 711         @ForceInline
 712         static $type$ getAndBitwiseXorRelease(VarHandle ob, $type$ value) {
 713             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 714             return UNSAFE.getAndBitwiseXor$Type$Release(handle.base,
 715                                        handle.fieldOffset,
 716                                        value);
 717         }
 718 
 719         @ForceInline
 720         static $type$ getAndBitwiseXorAcquire(VarHandle ob, $type$ value) {
 721             FieldStaticReadWrite handle = (FieldStaticReadWrite) ob.target();
 722             return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base,
 723                                        handle.fieldOffset,
 724                                        value);
 725         }
 726 #end[Bitwise]
 727 
 728         static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class);
 729     }
 730 
 731 
 732     static final class Array extends VarHandle {
 733         final int abase;
 734         final int ashift;
 735 #if[Object]
 736         final Class<{#if[Object]??:$type$[]}> arrayType;
 737         final Class<?> componentType;
 738 #end[Object]
 739 
 740         Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) {
 741             this(abase, ashift{#if[Object]?, arrayType}, false);
 742         }
 743 
 744         private Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}, boolean exact) {
 745             super(Array.FORM, exact);
 746             this.abase = abase;
 747             this.ashift = ashift;
 748 #if[Object]
 749             this.arrayType = {#if[Object]?arrayType:$type$[].class};
 750             this.componentType = arrayType.getComponentType();
 751 #end[Object]
 752         }
 753 
 754         @Override
 755         public Array withInvokeExactBehavior() {
 756             return hasInvokeExactBehavior()
 757                 ? this
 758                 : new Array(abase, ashift{#if[Object]?, arrayType}, true);
 759         }
 760 
 761         @Override
 762         public Array withInvokeBehavior() {
 763             return !hasInvokeExactBehavior()
 764                 ? this
 765                 : new Array(abase, ashift{#if[Object]?, arrayType}, false);
 766         }
 767 
 768         @Override
 769         public Optional<VarHandleDesc> describeConstable() {
 770             var arrayTypeRef = {#if[Object]?arrayType:$type$[].class}.describeConstable();
 771             if (!arrayTypeRef.isPresent())
 772                 return Optional.empty();
 773 
 774             return Optional.of(VarHandleDesc.ofArray(arrayTypeRef.get()));
 775         }
 776 
 777         @Override
 778         final MethodType accessModeTypeUncached(AccessType at) {
 779             return at.accessModeType({#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
 780         }
 781 
 782 #if[Object]
 783         @ForceInline
 784         static Object runtimeTypeCheck(Array handle, Object[] oarray, Object value) {
 785             if (handle.arrayType == oarray.getClass()) {
 786                 // Fast path: static array type same as argument array type
 787                 return handle.componentType.cast(value);
 788             } else {
 789                 // Slow path: check value against argument array component type
 790                 return reflectiveTypeCheck(oarray, value);
 791             }
 792         }
 793 
 794         @ForceInline
 795         static Object reflectiveTypeCheck(Object[] oarray, Object value) {
 796             try {
 797                 return oarray.getClass().getComponentType().cast(value);
 798             } catch (ClassCastException e) {
 799                 throw new ArrayStoreException();
 800             }
 801         }
 802 #end[Object]
 803 
 804         @ForceInline
 805         static $type$ get(VarHandle ob, Object oarray, int index) {
 806             Array handle = (Array)ob;
 807 #if[Object]
 808             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 809 #else[Object]
 810             $type$[] array = ($type$[]) oarray;
 811 #end[Object]
 812             return array[index];
 813         }
 814 
 815         @ForceInline
 816         static void set(VarHandle ob, Object oarray, int index, $type$ value) {
 817             Array handle = (Array)ob;
 818 #if[Object]
 819             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 820 #else[Object]
 821             $type$[] array = ($type$[]) oarray;
 822 #end[Object]
 823             array[index] = {#if[Object]?handle.componentType.cast(value):value};
 824         }
 825 
 826         @ForceInline
 827         static $type$ getVolatile(VarHandle ob, Object oarray, int index) {
 828             Array handle = (Array)ob;
 829 #if[Object]
 830             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 831 #else[Object]
 832             $type$[] array = ($type$[]) oarray;
 833 #end[Object]
 834             return UNSAFE.get$Type$Volatile(array,
 835                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
 836         }
 837 
 838         @ForceInline
 839         static void setVolatile(VarHandle ob, Object oarray, int index, $type$ value) {
 840             Array handle = (Array)ob;
 841 #if[Object]
 842             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 843 #else[Object]
 844             $type$[] array = ($type$[]) oarray;
 845 #end[Object]
 846             UNSAFE.put$Type$Volatile(array,
 847                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 848                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 849         }
 850 
 851         @ForceInline
 852         static $type$ getOpaque(VarHandle ob, Object oarray, int index) {
 853             Array handle = (Array)ob;
 854 #if[Object]
 855             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 856 #else[Object]
 857             $type$[] array = ($type$[]) oarray;
 858 #end[Object]
 859             return UNSAFE.get$Type$Opaque(array,
 860                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
 861         }
 862 
 863         @ForceInline
 864         static void setOpaque(VarHandle ob, Object oarray, int index, $type$ value) {
 865             Array handle = (Array)ob;
 866 #if[Object]
 867             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 868 #else[Object]
 869             $type$[] array = ($type$[]) oarray;
 870 #end[Object]
 871             UNSAFE.put$Type$Opaque(array,
 872                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 873                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 874         }
 875 
 876         @ForceInline
 877         static $type$ getAcquire(VarHandle ob, Object oarray, int index) {
 878             Array handle = (Array)ob;
 879 #if[Object]
 880             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 881 #else[Object]
 882             $type$[] array = ($type$[]) oarray;
 883 #end[Object]
 884             return UNSAFE.get$Type$Acquire(array,
 885                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
 886         }
 887 
 888         @ForceInline
 889         static void setRelease(VarHandle ob, Object oarray, int index, $type$ value) {
 890             Array handle = (Array)ob;
 891 #if[Object]
 892             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 893 #else[Object]
 894             $type$[] array = ($type$[]) oarray;
 895 #end[Object]
 896             UNSAFE.put$Type$Release(array,
 897                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 898                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 899         }
 900 #if[CAS]
 901 
 902         @ForceInline
 903         static boolean compareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 904             Array handle = (Array)ob;
 905 #if[Object]
 906             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 907 #else[Object]
 908             $type$[] array = ($type$[]) oarray;
 909 #end[Object]
 910             return UNSAFE.compareAndSet$Type$(array,
 911                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 912                     {#if[Object]?handle.componentType.cast(expected):expected},
 913                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 914         }
 915 
 916         @ForceInline
 917         static $type$ compareAndExchange(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 918             Array handle = (Array)ob;
 919 #if[Object]
 920             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 921 #else[Object]
 922             $type$[] array = ($type$[]) oarray;
 923 #end[Object]
 924             return UNSAFE.compareAndExchange$Type$(array,
 925                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 926                     {#if[Object]?handle.componentType.cast(expected):expected},
 927                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 928         }
 929 
 930         @ForceInline
 931         static $type$ compareAndExchangeAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 932             Array handle = (Array)ob;
 933 #if[Object]
 934             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 935 #else[Object]
 936             $type$[] array = ($type$[]) oarray;
 937 #end[Object]
 938             return UNSAFE.compareAndExchange$Type$Acquire(array,
 939                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 940                     {#if[Object]?handle.componentType.cast(expected):expected},
 941                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 942         }
 943 
 944         @ForceInline
 945         static $type$ compareAndExchangeRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 946             Array handle = (Array)ob;
 947 #if[Object]
 948             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 949 #else[Object]
 950             $type$[] array = ($type$[]) oarray;
 951 #end[Object]
 952             return UNSAFE.compareAndExchange$Type$Release(array,
 953                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 954                     {#if[Object]?handle.componentType.cast(expected):expected},
 955                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 956         }
 957 
 958         @ForceInline
 959         static boolean weakCompareAndSetPlain(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 960             Array handle = (Array)ob;
 961 #if[Object]
 962             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 963 #else[Object]
 964             $type$[] array = ($type$[]) oarray;
 965 #end[Object]
 966             return UNSAFE.weakCompareAndSet$Type$Plain(array,
 967                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 968                     {#if[Object]?handle.componentType.cast(expected):expected},
 969                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 970         }
 971 
 972         @ForceInline
 973         static boolean weakCompareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 974             Array handle = (Array)ob;
 975 #if[Object]
 976             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 977 #else[Object]
 978             $type$[] array = ($type$[]) oarray;
 979 #end[Object]
 980             return UNSAFE.weakCompareAndSet$Type$(array,
 981                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 982                     {#if[Object]?handle.componentType.cast(expected):expected},
 983                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 984         }
 985 
 986         @ForceInline
 987         static boolean weakCompareAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 988             Array handle = (Array)ob;
 989 #if[Object]
 990             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 991 #else[Object]
 992             $type$[] array = ($type$[]) oarray;
 993 #end[Object]
 994             return UNSAFE.weakCompareAndSet$Type$Acquire(array,
 995                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 996                     {#if[Object]?handle.componentType.cast(expected):expected},
 997                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 998         }
 999 
1000         @ForceInline
1001         static boolean weakCompareAndSetRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1002             Array handle = (Array)ob;
1003 #if[Object]
1004             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1005 #else[Object]
1006             $type$[] array = ($type$[]) oarray;
1007 #end[Object]
1008             return UNSAFE.weakCompareAndSet$Type$Release(array,
1009                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1010                     {#if[Object]?handle.componentType.cast(expected):expected},
1011                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1012         }
1013 
1014         @ForceInline
1015         static $type$ getAndSet(VarHandle ob, Object oarray, int index, $type$ value) {
1016             Array handle = (Array)ob;
1017 #if[Object]
1018             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1019 #else[Object]
1020             $type$[] array = ($type$[]) oarray;
1021 #end[Object]
1022             return UNSAFE.getAndSet$Type$(array,
1023                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1024                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1025         }
1026 
1027         @ForceInline
1028         static $type$ getAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1029             Array handle = (Array)ob;
1030 #if[Object]
1031             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1032 #else[Object]
1033             $type$[] array = ($type$[]) oarray;
1034 #end[Object]
1035             return UNSAFE.getAndSet$Type$Acquire(array,
1036                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1037                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1038         }
1039 
1040         @ForceInline
1041         static $type$ getAndSetRelease(VarHandle ob, Object oarray, int index, $type$ value) {
1042             Array handle = (Array)ob;
1043 #if[Object]
1044             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1045 #else[Object]
1046             $type$[] array = ($type$[]) oarray;
1047 #end[Object]
1048             return UNSAFE.getAndSet$Type$Release(array,
1049                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1050                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1051         }
1052 #end[CAS]
1053 #if[AtomicAdd]
1054 
1055         @ForceInline
1056         static $type$ getAndAdd(VarHandle ob, Object oarray, int index, $type$ value) {
1057             Array handle = (Array)ob;
1058             $type$[] array = ($type$[]) oarray;
1059             return UNSAFE.getAndAdd$Type$(array,
1060                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1061                     value);
1062         }
1063 
1064         @ForceInline
1065         static $type$ getAndAddAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1066             Array handle = (Array)ob;
1067             $type$[] array = ($type$[]) oarray;
1068             return UNSAFE.getAndAdd$Type$Acquire(array,
1069                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1070                     value);
1071         }
1072 
1073         @ForceInline
1074         static $type$ getAndAddRelease(VarHandle ob, Object oarray, int index, $type$ value) {
1075             Array handle = (Array)ob;
1076             $type$[] array = ($type$[]) oarray;
1077             return UNSAFE.getAndAdd$Type$Release(array,
1078                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1079                     value);
1080         }
1081 #end[AtomicAdd]
1082 #if[Bitwise]
1083 
1084         @ForceInline
1085         static $type$ getAndBitwiseOr(VarHandle ob, Object oarray, int index, $type$ value) {
1086             Array handle = (Array)ob;
1087             $type$[] array = ($type$[]) oarray;
1088             return UNSAFE.getAndBitwiseOr$Type$(array,
1089                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1090                                        value);
1091         }
1092 
1093         @ForceInline
1094         static $type$ getAndBitwiseOrRelease(VarHandle ob, Object oarray, int index, $type$ value) {
1095             Array handle = (Array)ob;
1096             $type$[] array = ($type$[]) oarray;
1097             return UNSAFE.getAndBitwiseOr$Type$Release(array,
1098                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1099                                        value);
1100         }
1101 
1102         @ForceInline
1103         static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1104             Array handle = (Array)ob;
1105             $type$[] array = ($type$[]) oarray;
1106             return UNSAFE.getAndBitwiseOr$Type$Acquire(array,
1107                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1108                                        value);
1109         }
1110 
1111         @ForceInline
1112         static $type$ getAndBitwiseAnd(VarHandle ob, Object oarray, int index, $type$ value) {
1113             Array handle = (Array)ob;
1114             $type$[] array = ($type$[]) oarray;
1115             return UNSAFE.getAndBitwiseAnd$Type$(array,
1116                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1117                                        value);
1118         }
1119 
1120         @ForceInline
1121         static $type$ getAndBitwiseAndRelease(VarHandle ob, Object oarray, int index, $type$ value) {
1122             Array handle = (Array)ob;
1123             $type$[] array = ($type$[]) oarray;
1124             return UNSAFE.getAndBitwiseAnd$Type$Release(array,
1125                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1126                                        value);
1127         }
1128 
1129         @ForceInline
1130         static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1131             Array handle = (Array)ob;
1132             $type$[] array = ($type$[]) oarray;
1133             return UNSAFE.getAndBitwiseAnd$Type$Acquire(array,
1134                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1135                                        value);
1136         }
1137 
1138         @ForceInline
1139         static $type$ getAndBitwiseXor(VarHandle ob, Object oarray, int index, $type$ value) {
1140             Array handle = (Array)ob;
1141             $type$[] array = ($type$[]) oarray;
1142             return UNSAFE.getAndBitwiseXor$Type$(array,
1143                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1144                                        value);
1145         }
1146 
1147         @ForceInline
1148         static $type$ getAndBitwiseXorRelease(VarHandle ob, Object oarray, int index, $type$ value) {
1149             Array handle = (Array)ob;
1150             $type$[] array = ($type$[]) oarray;
1151             return UNSAFE.getAndBitwiseXor$Type$Release(array,
1152                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1153                                        value);
1154         }
1155 
1156         @ForceInline
1157         static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1158             Array handle = (Array)ob;
1159             $type$[] array = ($type$[]) oarray;
1160             return UNSAFE.getAndBitwiseXor$Type$Acquire(array,
1161                                        (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1162                                        value);
1163         }
1164 #end[Bitwise]
1165 
1166         static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class);
1167     }
1168 }