< prev index next >

src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template

Print this page

  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 

 423                 return Optional.empty();
 424 
 425             // Reflect on this VarHandle to extract the field name
 426             var staticField = VarHandles.getStaticFieldFromBaseAndOffset(
 427                 base, fieldOffset, {#if[Object]?fieldType:$type$.class});
 428             var receiverTypeRef = staticField.getDeclaringClass().describeConstable();
 429             if (!receiverTypeRef.isPresent())
 430                 return Optional.empty();
 431             return Optional.of(VarHandleDesc.ofStaticField(receiverTypeRef.get(), staticField.getName(), fieldTypeRef.get()));
 432         }
 433 
 434         @Override
 435         final MethodType accessModeTypeUncached(AccessType at) {
 436             return at.accessModeType(null, {#if[Object]?fieldType:$type$.class});
 437         }
 438 
 439         @ForceInline
 440         static $type$ get(VarHandle ob) {
 441             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 442             return UNSAFE.get$Type$(handle.base,
 443                                  handle.fieldOffset);
 444         }
 445 
 446         @ForceInline
 447         static $type$ getVolatile(VarHandle ob) {
 448             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 449             return UNSAFE.get$Type$Volatile(handle.base,
 450                                  handle.fieldOffset);
 451         }
 452 
 453         @ForceInline
 454         static $type$ getOpaque(VarHandle ob) {
 455             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 456             return UNSAFE.get$Type$Opaque(handle.base,
 457                                  handle.fieldOffset);
 458         }
 459 
 460         @ForceInline
 461         static $type$ getAcquire(VarHandle ob) {
 462             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 463             return UNSAFE.get$Type$Acquire(handle.base,
 464                                  handle.fieldOffset);
 465         }
 466 
 467         static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, $type$.class);
 468     }
 469 
 470     static final class FieldStaticReadWrite extends FieldStaticReadOnly {
 471 
 472         FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 473             this(base, fieldOffset{#if[Object]?, fieldType}, false);
 474         }
 475 
 476         private FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
 477                                      boolean exact) {
 478             super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM, exact);
 479         }
 480 
 481         @Override
 482         public FieldStaticReadWrite withInvokeExactBehavior() {
 483             return hasInvokeExactBehavior()
 484                 ? this
 485                 : new FieldStaticReadWrite(base, fieldOffset{#if[Object]?, fieldType}, true);
 486         }
 487 
 488         @Override
 489         public FieldStaticReadWrite withInvokeBehavior() {
 490             return !hasInvokeExactBehavior()
 491                 ? this
 492                 : new FieldStaticReadWrite(base, fieldOffset{#if[Object]?, fieldType}, false);
 493         }
 494 








 495         @ForceInline
 496         static void set(VarHandle ob, $type$ value) {
 497             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 498             UNSAFE.put$Type$(handle.base,
 499                              handle.fieldOffset,
 500                              {#if[Object]?handle.fieldType.cast(value):value});
 501         }
 502 
 503         @ForceInline
 504         static void setVolatile(VarHandle ob, $type$ value) {
 505             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 506             UNSAFE.put$Type$Volatile(handle.base,
 507                                      handle.fieldOffset,
 508                                      {#if[Object]?handle.fieldType.cast(value):value});
 509         }
 510 
 511         @ForceInline
 512         static void setOpaque(VarHandle ob, $type$ value) {
 513             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 514             UNSAFE.put$Type$Opaque(handle.base,
 515                                    handle.fieldOffset,
 516                                    {#if[Object]?handle.fieldType.cast(value):value});
 517         }
 518 
 519         @ForceInline
 520         static void setRelease(VarHandle ob, $type$ value) {
 521             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 522             UNSAFE.put$Type$Release(handle.base,
 523                                     handle.fieldOffset,
 524                                     {#if[Object]?handle.fieldType.cast(value):value});
 525         }
 526 #if[CAS]
 527 
 528         @ForceInline
 529         static boolean compareAndSet(VarHandle ob, $type$ expected, $type$ value) {
 530             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 531             return UNSAFE.compareAndSet$Type$(handle.base,
 532                                                handle.fieldOffset,
 533                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 534                                                {#if[Object]?handle.fieldType.cast(value):value});
 535         }
 536 
 537 
 538         @ForceInline
 539         static $type$ compareAndExchange(VarHandle ob, $type$ expected, $type$ value) {
 540             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 541             return UNSAFE.compareAndExchange$Type$(handle.base,
 542                                                handle.fieldOffset,
 543                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 544                                                {#if[Object]?handle.fieldType.cast(value):value});
 545         }
 546 
 547         @ForceInline
 548         static $type$ compareAndExchangeAcquire(VarHandle ob, $type$ expected, $type$ value) {
 549             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 550             return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
 551                                                handle.fieldOffset,
 552                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 553                                                {#if[Object]?handle.fieldType.cast(value):value});
 554         }
 555 
 556         @ForceInline
 557         static $type$ compareAndExchangeRelease(VarHandle ob, $type$ expected, $type$ value) {
 558             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 559             return UNSAFE.compareAndExchange$Type$Release(handle.base,
 560                                                handle.fieldOffset,
 561                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 562                                                {#if[Object]?handle.fieldType.cast(value):value});
 563         }
 564 
 565         @ForceInline
 566         static boolean weakCompareAndSetPlain(VarHandle ob, $type$ expected, $type$ value) {
 567             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 568             return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
 569                                                handle.fieldOffset,
 570                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 571                                                {#if[Object]?handle.fieldType.cast(value):value});
 572         }
 573 
 574         @ForceInline
 575         static boolean weakCompareAndSet(VarHandle ob, $type$ expected, $type$ value) {
 576             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 577             return UNSAFE.weakCompareAndSet$Type$(handle.base,
 578                                                handle.fieldOffset,
 579                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 580                                                {#if[Object]?handle.fieldType.cast(value):value});
 581         }
 582 
 583         @ForceInline
 584         static boolean weakCompareAndSetAcquire(VarHandle ob, $type$ expected, $type$ value) {
 585             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 586             return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
 587                                                handle.fieldOffset,
 588                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 589                                                {#if[Object]?handle.fieldType.cast(value):value});
 590         }
 591 
 592         @ForceInline
 593         static boolean weakCompareAndSetRelease(VarHandle ob, $type$ expected, $type$ value) {
 594             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 595             return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
 596                                                handle.fieldOffset,
 597                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 598                                                {#if[Object]?handle.fieldType.cast(value):value});
 599         }
 600 
 601         @ForceInline
 602         static $type$ getAndSet(VarHandle ob, $type$ value) {
 603             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 604             return UNSAFE.getAndSet$Type$(handle.base,
 605                                           handle.fieldOffset,
 606                                           {#if[Object]?handle.fieldType.cast(value):value});
 607         }
 608 
 609         @ForceInline
 610         static $type$ getAndSetAcquire(VarHandle ob, $type$ value) {
 611             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 612             return UNSAFE.getAndSet$Type$Acquire(handle.base,
 613                                           handle.fieldOffset,
 614                                           {#if[Object]?handle.fieldType.cast(value):value});
 615         }
 616 
 617         @ForceInline
 618         static $type$ getAndSetRelease(VarHandle ob, $type$ value) {
 619             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 620             return UNSAFE.getAndSet$Type$Release(handle.base,
 621                                           handle.fieldOffset,
 622                                           {#if[Object]?handle.fieldType.cast(value):value});
 623         }
 624 #end[CAS]
 625 #if[AtomicAdd]
 626 
 627         @ForceInline
 628         static $type$ getAndAdd(VarHandle ob, $type$ value) {
 629             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 630             return UNSAFE.getAndAdd$Type$(handle.base,
 631                                        handle.fieldOffset,
 632                                        value);
 633         }
 634 
 635         @ForceInline
 636         static $type$ getAndAddAcquire(VarHandle ob, $type$ value) {
 637             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 638             return UNSAFE.getAndAdd$Type$Acquire(handle.base,
 639                                        handle.fieldOffset,
 640                                        value);
 641         }
 642 

 709         @ForceInline
 710         static $type$ getAndBitwiseXorRelease(VarHandle ob, $type$ value) {
 711             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 712             return UNSAFE.getAndBitwiseXor$Type$Release(handle.base,
 713                                        handle.fieldOffset,
 714                                        value);
 715         }
 716 
 717         @ForceInline
 718         static $type$ getAndBitwiseXorAcquire(VarHandle ob, $type$ value) {
 719             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 720             return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base,
 721                                        handle.fieldOffset,
 722                                        value);
 723         }
 724 #end[Bitwise]
 725 
 726         static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class);
 727     }
 728 








 729 
 730     static final class Array extends VarHandle {
 731         final int abase;
 732         final int ashift;
 733 #if[Object]
 734         final Class<{#if[Object]??:$type$[]}> arrayType;
 735         final Class<?> componentType;
 736 #end[Object]
 737 
 738         Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) {
 739             this(abase, ashift{#if[Object]?, arrayType}, false);
 740         }
 741 
 742         private Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}, boolean exact) {
 743             super(Array.FORM, exact);
 744             this.abase = abase;
 745             this.ashift = ashift;
 746 #if[Object]
 747             this.arrayType = {#if[Object]?arrayType:$type$[].class};
 748             this.componentType = arrayType.getComponentType();

 763                 : new Array(abase, ashift{#if[Object]?, arrayType}, false);
 764         }
 765 
 766         @Override
 767         public Optional<VarHandleDesc> describeConstable() {
 768             var arrayTypeRef = {#if[Object]?arrayType:$type$[].class}.describeConstable();
 769             if (!arrayTypeRef.isPresent())
 770                 return Optional.empty();
 771 
 772             return Optional.of(VarHandleDesc.ofArray(arrayTypeRef.get()));
 773         }
 774 
 775         @Override
 776         final MethodType accessModeTypeUncached(AccessType at) {
 777             return at.accessModeType({#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
 778         }
 779 
 780 #if[Object]
 781         @ForceInline
 782         static Object runtimeTypeCheck(Array handle, Object[] oarray, Object value) {



 783             if (handle.arrayType == oarray.getClass()) {
 784                 // Fast path: static array type same as argument array type
 785                 return handle.componentType.cast(value);
 786             } else {
 787                 // Slow path: check value against argument array component type
 788                 return reflectiveTypeCheck(oarray, value);
 789             }
 790         }
 791 
 792         @ForceInline
 793         static Object reflectiveTypeCheck(Object[] oarray, Object value) {
 794             try {
 795                 return oarray.getClass().getComponentType().cast(value);
 796             } catch (ClassCastException e) {
 797                 throw new ArrayStoreException();
 798             }
 799         }
 800 #end[Object]
 801 
 802         @ForceInline
 803         static $type$ get(VarHandle ob, Object oarray, int index) {
 804             Array handle = (Array)ob;
 805 #if[Object]
 806             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 807 #else[Object]
 808             $type$[] array = ($type$[]) oarray;
 809 #end[Object]
 810             return array[index];
 811         }
 812 
 813         @ForceInline
 814         static void set(VarHandle ob, Object oarray, int index, $type$ value) {
 815             Array handle = (Array)ob;
 816 #if[Object]
 817             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 818 #else[Object]
 819             $type$[] array = ($type$[]) oarray;
 820 #end[Object]
 821             array[index] = {#if[Object]?handle.componentType.cast(value):value};








 822         }
 823 
 824         @ForceInline
 825         static $type$ getVolatile(VarHandle ob, Object oarray, int index) {
 826             Array handle = (Array)ob;
 827 #if[Object]
 828             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 829 #else[Object]
 830             $type$[] array = ($type$[]) oarray;
 831 #end[Object]







 832             return UNSAFE.get$Type$Volatile(array,
 833                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
 834         }
 835 
 836         @ForceInline
 837         static void setVolatile(VarHandle ob, Object oarray, int index, $type$ value) {
 838             Array handle = (Array)ob;
 839 #if[Object]
 840             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 841 #else[Object]
 842             $type$[] array = ($type$[]) oarray;
 843 #end[Object]








 844             UNSAFE.put$Type$Volatile(array,
 845                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 846                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 847         }
 848 
 849         @ForceInline
 850         static $type$ getOpaque(VarHandle ob, Object oarray, int index) {
 851             Array handle = (Array)ob;
 852 #if[Object]
 853             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 854 #else[Object]
 855             $type$[] array = ($type$[]) oarray;
 856 #end[Object]







 857             return UNSAFE.get$Type$Opaque(array,
 858                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
 859         }
 860 
 861         @ForceInline
 862         static void setOpaque(VarHandle ob, Object oarray, int index, $type$ value) {
 863             Array handle = (Array)ob;
 864 #if[Object]
 865             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 866 #else[Object]
 867             $type$[] array = ($type$[]) oarray;
 868 #end[Object]








 869             UNSAFE.put$Type$Opaque(array,
 870                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 871                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 872         }
 873 
 874         @ForceInline
 875         static $type$ getAcquire(VarHandle ob, Object oarray, int index) {
 876             Array handle = (Array)ob;
 877 #if[Object]
 878             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 879 #else[Object]
 880             $type$[] array = ($type$[]) oarray;
 881 #end[Object]







 882             return UNSAFE.get$Type$Acquire(array,
 883                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
 884         }
 885 
 886         @ForceInline
 887         static void setRelease(VarHandle ob, Object oarray, int index, $type$ value) {
 888             Array handle = (Array)ob;
 889 #if[Object]
 890             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 891 #else[Object]
 892             $type$[] array = ($type$[]) oarray;
 893 #end[Object]








 894             UNSAFE.put$Type$Release(array,
 895                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 896                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 897         }
 898 #if[CAS]
 899 
 900         @ForceInline
 901         static boolean compareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 902             Array handle = (Array)ob;
 903 #if[Object]
 904             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 905 #else[Object]
 906             $type$[] array = ($type$[]) oarray;
 907 #end[Object]







 908             return UNSAFE.compareAndSet$Type$(array,
 909                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 910                     {#if[Object]?handle.componentType.cast(expected):expected},
 911                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 912         }
 913 
 914         @ForceInline
 915         static $type$ compareAndExchange(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 916             Array handle = (Array)ob;
 917 #if[Object]
 918             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 919 #else[Object]
 920             $type$[] array = ($type$[]) oarray;
 921 #end[Object]







 922             return UNSAFE.compareAndExchange$Type$(array,
 923                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 924                     {#if[Object]?handle.componentType.cast(expected):expected},
 925                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 926         }
 927 
 928         @ForceInline
 929         static $type$ compareAndExchangeAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 930             Array handle = (Array)ob;
 931 #if[Object]
 932             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 933 #else[Object]
 934             $type$[] array = ($type$[]) oarray;
 935 #end[Object]







 936             return UNSAFE.compareAndExchange$Type$Acquire(array,
 937                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 938                     {#if[Object]?handle.componentType.cast(expected):expected},
 939                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 940         }
 941 
 942         @ForceInline
 943         static $type$ compareAndExchangeRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 944             Array handle = (Array)ob;
 945 #if[Object]
 946             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 947 #else[Object]
 948             $type$[] array = ($type$[]) oarray;
 949 #end[Object]







 950             return UNSAFE.compareAndExchange$Type$Release(array,
 951                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 952                     {#if[Object]?handle.componentType.cast(expected):expected},
 953                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 954         }
 955 
 956         @ForceInline
 957         static boolean weakCompareAndSetPlain(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 958             Array handle = (Array)ob;
 959 #if[Object]
 960             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 961 #else[Object]
 962             $type$[] array = ($type$[]) oarray;
 963 #end[Object]







 964             return UNSAFE.weakCompareAndSet$Type$Plain(array,
 965                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 966                     {#if[Object]?handle.componentType.cast(expected):expected},
 967                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 968         }
 969 
 970         @ForceInline
 971         static boolean weakCompareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 972             Array handle = (Array)ob;
 973 #if[Object]
 974             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 975 #else[Object]
 976             $type$[] array = ($type$[]) oarray;
 977 #end[Object]







 978             return UNSAFE.weakCompareAndSet$Type$(array,
 979                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 980                     {#if[Object]?handle.componentType.cast(expected):expected},
 981                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 982         }
 983 
 984         @ForceInline
 985         static boolean weakCompareAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 986             Array handle = (Array)ob;
 987 #if[Object]
 988             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 989 #else[Object]
 990             $type$[] array = ($type$[]) oarray;
 991 #end[Object]







 992             return UNSAFE.weakCompareAndSet$Type$Acquire(array,
 993                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
 994                     {#if[Object]?handle.componentType.cast(expected):expected},
 995                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 996         }
 997 
 998         @ForceInline
 999         static boolean weakCompareAndSetRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1000             Array handle = (Array)ob;
1001 #if[Object]
1002             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1003 #else[Object]
1004             $type$[] array = ($type$[]) oarray;
1005 #end[Object]







1006             return UNSAFE.weakCompareAndSet$Type$Release(array,
1007                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1008                     {#if[Object]?handle.componentType.cast(expected):expected},
1009                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1010         }
1011 
1012         @ForceInline
1013         static $type$ getAndSet(VarHandle ob, Object oarray, int index, $type$ value) {
1014             Array handle = (Array)ob;
1015 #if[Object]
1016             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1017 #else[Object]
1018             $type$[] array = ($type$[]) oarray;
1019 #end[Object]







1020             return UNSAFE.getAndSet$Type$(array,
1021                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1022                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1023         }
1024 
1025         @ForceInline
1026         static $type$ getAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1027             Array handle = (Array)ob;
1028 #if[Object]
1029             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1030 #else[Object]
1031             $type$[] array = ($type$[]) oarray;
1032 #end[Object]







1033             return UNSAFE.getAndSet$Type$Acquire(array,
1034                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1035                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1036         }
1037 
1038         @ForceInline
1039         static $type$ getAndSetRelease(VarHandle ob, Object oarray, int index, $type$ value) {
1040             Array handle = (Array)ob;
1041 #if[Object]
1042             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1043 #else[Object]
1044             $type$[] array = ($type$[]) oarray;
1045 #end[Object]







1046             return UNSAFE.getAndSet$Type$Release(array,
1047                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1048                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1049         }
1050 #end[CAS]
1051 #if[AtomicAdd]
1052 
1053         @ForceInline
1054         static $type$ getAndAdd(VarHandle ob, Object oarray, int index, $type$ value) {
1055             Array handle = (Array)ob;
1056             $type$[] array = ($type$[]) oarray;
1057             return UNSAFE.getAndAdd$Type$(array,
1058                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1059                     value);
1060         }
1061 
1062         @ForceInline
1063         static $type$ getAndAddAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1064             Array handle = (Array)ob;
1065             $type$[] array = ($type$[]) oarray;
1066             return UNSAFE.getAndAdd$Type$Acquire(array,
1067                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,

  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{#if[Value]?, handle.fieldType});
  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{#if[Value]?, handle.fieldType});
 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{#if[Value]?, handle.fieldType});
 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{#if[Value]?, handle.fieldType});
 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         FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 126             this(receiverType, fieldOffset{#if[Object]?, fieldType}, false);
 127         }
 128 
 129         private FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType},
 130                                        boolean exact) {
 131             super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.FORM, exact);
 132         }
 133 
 134         @Override
 135         public FieldInstanceReadWrite withInvokeExactBehavior() {
 136             return hasInvokeExactBehavior()
 137                 ? this
 138                 : new FieldInstanceReadWrite(receiverType, fieldOffset{#if[Object]?, fieldType}, true);
 139         }
 140 
 141         @Override
 142         public FieldInstanceReadWrite withInvokeBehavior() {
 143             return !hasInvokeExactBehavior()
 144                 ? this
 145                 : new FieldInstanceReadWrite(receiverType, fieldOffset{#if[Object]?, fieldType}, false);
 146         }
 147 
 148 #if[Object]
 149         @ForceInline
 150         static Object checkCast(FieldInstanceReadWrite handle, $type$ value) {
 151             if (handle.fieldType.isValueType())
 152                 Objects.requireNonNull(value);
 153             return handle.fieldType.cast(value);
 154         }
 155 #end[Object]
 156 
 157         @ForceInline
 158         static void set(VarHandle ob, Object holder, $type$ value) {
 159             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 160             UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 161                              handle.fieldOffset{#if[Value]?, handle.fieldType},
 162                              {#if[Object]?checkCast(handle, value):value});
 163         }
 164 
 165         @ForceInline
 166         static void setVolatile(VarHandle ob, Object holder, $type$ value) {
 167             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 168             UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
 169                                      handle.fieldOffset{#if[Value]?, handle.fieldType},
 170                                      {#if[Object]?checkCast(handle, value):value});
 171         }
 172 
 173         @ForceInline
 174         static void setOpaque(VarHandle ob, Object holder, $type$ value) {
 175             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 176             UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
 177                                    handle.fieldOffset{#if[Value]?, handle.fieldType},
 178                                    {#if[Object]?checkCast(handle, value):value});
 179         }
 180 
 181         @ForceInline
 182         static void setRelease(VarHandle ob, Object holder, $type$ value) {
 183             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 184             UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 185                                     handle.fieldOffset{#if[Value]?, handle.fieldType},
 186                                     {#if[Object]?checkCast(handle, value):value});
 187         }
 188 #if[CAS]
 189 
 190         @ForceInline
 191         static boolean compareAndSet(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 192             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 193             return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 194                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 195                                                {#if[Object]?checkCast(handle, expected):expected},
 196                                                {#if[Object]?checkCast(handle, value):value});
 197         }
 198 
 199         @ForceInline
 200         static $type$ compareAndExchange(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 201             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 202             return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 203                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 204                                                {#if[Object]?checkCast(handle, expected):expected},
 205                                                {#if[Object]?checkCast(handle, value):value});
 206         }
 207 
 208         @ForceInline
 209         static $type$ compareAndExchangeAcquire(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 210             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 211             return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 212                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 213                                                {#if[Object]?checkCast(handle, expected):expected},
 214                                                {#if[Object]?checkCast(handle, value):value});
 215         }
 216 
 217         @ForceInline
 218         static $type$ compareAndExchangeRelease(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 219             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 220             return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 221                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 222                                                {#if[Object]?checkCast(handle, expected):expected},
 223                                                {#if[Object]?checkCast(handle, value):value});
 224         }
 225 
 226         @ForceInline
 227         static boolean weakCompareAndSetPlain(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 228             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 229             return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)),
 230                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 231                                                {#if[Object]?checkCast(handle, expected):expected},
 232                                                {#if[Object]?checkCast(handle, value):value});
 233         }
 234 
 235         @ForceInline
 236         static boolean weakCompareAndSet(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 237             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 238             return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 239                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 240                                                {#if[Object]?checkCast(handle, expected):expected},
 241                                                {#if[Object]?checkCast(handle, value):value});
 242         }
 243 
 244         @ForceInline
 245         static boolean weakCompareAndSetAcquire(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 246             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 247             return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 248                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 249                                                {#if[Object]?checkCast(handle, expected):expected},
 250                                                {#if[Object]?checkCast(handle, value):value});
 251         }
 252 
 253         @ForceInline
 254         static boolean weakCompareAndSetRelease(VarHandle ob, Object holder, $type$ expected, $type$ value) {
 255             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 256             return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 257                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 258                                                {#if[Object]?checkCast(handle, expected):expected},
 259                                                {#if[Object]?checkCast(handle, value):value});
 260         }
 261 
 262         @ForceInline
 263         static $type$ getAndSet(VarHandle ob, Object holder, $type$ value) {
 264             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 265             return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 266                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 267                                           {#if[Object]?checkCast(handle, value):value});
 268         }
 269 
 270         @ForceInline
 271         static $type$ getAndSetAcquire(VarHandle ob, Object holder, $type$ value) {
 272             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 273             return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 274                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 275                                           {#if[Object]?checkCast(handle, value):value});
 276         }
 277 
 278         @ForceInline
 279         static $type$ getAndSetRelease(VarHandle ob, Object holder, $type$ value) {
 280             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 281             return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 282                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 283                                           {#if[Object]?checkCast(handle, value):value});
 284         }
 285 #end[CAS]
 286 #if[AtomicAdd]
 287 
 288         @ForceInline
 289         static $type$ getAndAdd(VarHandle ob, Object holder, $type$ value) {
 290             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 291             return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 292                                        handle.fieldOffset,
 293                                        value);
 294         }
 295 
 296         @ForceInline
 297         static $type$ getAndAddAcquire(VarHandle ob, Object holder, $type$ value) {
 298             FieldInstanceReadWrite handle = (FieldInstanceReadWrite)ob;
 299             return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 300                                        handle.fieldOffset,
 301                                        value);
 302         }
 303 

 431                 return Optional.empty();
 432 
 433             // Reflect on this VarHandle to extract the field name
 434             var staticField = VarHandles.getStaticFieldFromBaseAndOffset(
 435                 base, fieldOffset, {#if[Object]?fieldType:$type$.class});
 436             var receiverTypeRef = staticField.getDeclaringClass().describeConstable();
 437             if (!receiverTypeRef.isPresent())
 438                 return Optional.empty();
 439             return Optional.of(VarHandleDesc.ofStaticField(receiverTypeRef.get(), staticField.getName(), fieldTypeRef.get()));
 440         }
 441 
 442         @Override
 443         final MethodType accessModeTypeUncached(AccessType at) {
 444             return at.accessModeType(null, {#if[Object]?fieldType:$type$.class});
 445         }
 446 
 447         @ForceInline
 448         static $type$ get(VarHandle ob) {
 449             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 450             return UNSAFE.get$Type$(handle.base,
 451                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 452         }
 453 
 454         @ForceInline
 455         static $type$ getVolatile(VarHandle ob) {
 456             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 457             return UNSAFE.get$Type$Volatile(handle.base,
 458                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 459         }
 460 
 461         @ForceInline
 462         static $type$ getOpaque(VarHandle ob) {
 463             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 464             return UNSAFE.get$Type$Opaque(handle.base,
 465                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 466         }
 467 
 468         @ForceInline
 469         static $type$ getAcquire(VarHandle ob) {
 470             FieldStaticReadOnly handle = (FieldStaticReadOnly)ob;
 471             return UNSAFE.get$Type$Acquire(handle.base,
 472                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 473         }
 474 
 475         static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, $type$.class);
 476     }
 477 
 478     static final class FieldStaticReadWrite extends FieldStaticReadOnly {

 479         FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 480             this(base, fieldOffset{#if[Object]?, fieldType}, false);
 481         }
 482 
 483         private FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType},
 484                                      boolean exact) {
 485             super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM, exact);
 486         }
 487 
 488         @Override
 489         public FieldStaticReadWrite withInvokeExactBehavior() {
 490             return hasInvokeExactBehavior()
 491                 ? this
 492                 : new FieldStaticReadWrite(base, fieldOffset{#if[Object]?, fieldType}, true);
 493         }
 494 
 495         @Override
 496         public FieldStaticReadWrite withInvokeBehavior() {
 497             return !hasInvokeExactBehavior()
 498                 ? this
 499                 : new FieldStaticReadWrite(base, fieldOffset{#if[Object]?, fieldType}, false);
 500         }
 501 
 502 #if[Object]
 503         static Object checkCast(FieldStaticReadWrite handle, $type$ value) {
 504             if (handle.fieldType.isValueType())
 505                 Objects.requireNonNull(value);
 506             return handle.fieldType.cast(value);
 507         }
 508 #end[Object]
 509 
 510         @ForceInline
 511         static void set(VarHandle ob, $type$ value) {
 512             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 513             UNSAFE.put$Type$(handle.base,
 514                              handle.fieldOffset{#if[Value]?, handle.fieldType},
 515                              {#if[Object]?checkCast(handle, value):value});
 516         }
 517 
 518         @ForceInline
 519         static void setVolatile(VarHandle ob, $type$ value) {
 520             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 521             UNSAFE.put$Type$Volatile(handle.base,
 522                                      handle.fieldOffset{#if[Value]?, handle.fieldType},
 523                                      {#if[Object]?checkCast(handle, value):value});
 524         }
 525 
 526         @ForceInline
 527         static void setOpaque(VarHandle ob, $type$ value) {
 528             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 529             UNSAFE.put$Type$Opaque(handle.base,
 530                                    handle.fieldOffset{#if[Value]?, handle.fieldType},
 531                                    {#if[Object]?checkCast(handle, value):value});
 532         }
 533 
 534         @ForceInline
 535         static void setRelease(VarHandle ob, $type$ value) {
 536             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 537             UNSAFE.put$Type$Release(handle.base,
 538                                     handle.fieldOffset{#if[Value]?, handle.fieldType},
 539                                     {#if[Object]?checkCast(handle, value):value});
 540         }
 541 #if[CAS]
 542 
 543         @ForceInline
 544         static boolean compareAndSet(VarHandle ob, $type$ expected, $type$ value) {
 545             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 546             return UNSAFE.compareAndSet$Type$(handle.base,
 547                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 548                                                {#if[Object]?checkCast(handle, expected):expected},
 549                                                {#if[Object]?checkCast(handle, value):value});
 550         }
 551 
 552 
 553         @ForceInline
 554         static $type$ compareAndExchange(VarHandle ob, $type$ expected, $type$ value) {
 555             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 556             return UNSAFE.compareAndExchange$Type$(handle.base,
 557                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 558                                                {#if[Object]?checkCast(handle, expected):expected},
 559                                                {#if[Object]?checkCast(handle, value):value});
 560         }
 561 
 562         @ForceInline
 563         static $type$ compareAndExchangeAcquire(VarHandle ob, $type$ expected, $type$ value) {
 564             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 565             return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
 566                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 567                                                {#if[Object]?checkCast(handle, expected):expected},
 568                                                {#if[Object]?checkCast(handle, value):value});
 569         }
 570 
 571         @ForceInline
 572         static $type$ compareAndExchangeRelease(VarHandle ob, $type$ expected, $type$ value) {
 573             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 574             return UNSAFE.compareAndExchange$Type$Release(handle.base,
 575                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 576                                                {#if[Object]?checkCast(handle, expected):expected},
 577                                                {#if[Object]?checkCast(handle, value):value});
 578         }
 579 
 580         @ForceInline
 581         static boolean weakCompareAndSetPlain(VarHandle ob, $type$ expected, $type$ value) {
 582             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 583             return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
 584                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 585                                                {#if[Object]?checkCast(handle, expected):expected},
 586                                                {#if[Object]?checkCast(handle, value):value});
 587         }
 588 
 589         @ForceInline
 590         static boolean weakCompareAndSet(VarHandle ob, $type$ expected, $type$ value) {
 591             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 592             return UNSAFE.weakCompareAndSet$Type$(handle.base,
 593                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 594                                                {#if[Object]?checkCast(handle, expected):expected},
 595                                                {#if[Object]?checkCast(handle, value):value});
 596         }
 597 
 598         @ForceInline
 599         static boolean weakCompareAndSetAcquire(VarHandle ob, $type$ expected, $type$ value) {
 600             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 601             return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
 602                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 603                                                {#if[Object]?checkCast(handle, expected):expected},
 604                                                {#if[Object]?checkCast(handle, value):value});
 605         }
 606 
 607         @ForceInline
 608         static boolean weakCompareAndSetRelease(VarHandle ob, $type$ expected, $type$ value) {
 609             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 610             return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
 611                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 612                                                {#if[Object]?checkCast(handle, expected):expected},
 613                                                {#if[Object]?checkCast(handle, value):value});
 614         }
 615 
 616         @ForceInline
 617         static $type$ getAndSet(VarHandle ob, $type$ value) {
 618             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 619             return UNSAFE.getAndSet$Type$(handle.base,
 620                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 621                                           {#if[Object]?checkCast(handle, value):value});
 622         }
 623 
 624         @ForceInline
 625         static $type$ getAndSetAcquire(VarHandle ob, $type$ value) {
 626             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 627             return UNSAFE.getAndSet$Type$Acquire(handle.base,
 628                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 629                                           {#if[Object]?checkCast(handle, value):value});
 630         }
 631 
 632         @ForceInline
 633         static $type$ getAndSetRelease(VarHandle ob, $type$ value) {
 634             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 635             return UNSAFE.getAndSet$Type$Release(handle.base,
 636                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 637                                           {#if[Object]?checkCast(handle, value):value});
 638         }
 639 #end[CAS]
 640 #if[AtomicAdd]
 641 
 642         @ForceInline
 643         static $type$ getAndAdd(VarHandle ob, $type$ value) {
 644             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 645             return UNSAFE.getAndAdd$Type$(handle.base,
 646                                        handle.fieldOffset,
 647                                        value);
 648         }
 649 
 650         @ForceInline
 651         static $type$ getAndAddAcquire(VarHandle ob, $type$ value) {
 652             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 653             return UNSAFE.getAndAdd$Type$Acquire(handle.base,
 654                                        handle.fieldOffset,
 655                                        value);
 656         }
 657 

 724         @ForceInline
 725         static $type$ getAndBitwiseXorRelease(VarHandle ob, $type$ value) {
 726             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 727             return UNSAFE.getAndBitwiseXor$Type$Release(handle.base,
 728                                        handle.fieldOffset,
 729                                        value);
 730         }
 731 
 732         @ForceInline
 733         static $type$ getAndBitwiseXorAcquire(VarHandle ob, $type$ value) {
 734             FieldStaticReadWrite handle = (FieldStaticReadWrite)ob;
 735             return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base,
 736                                        handle.fieldOffset,
 737                                        value);
 738         }
 739 #end[Bitwise]
 740 
 741         static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class);
 742     }
 743 
 744 #if[Reference]
 745     static VarHandle makeVarHandleValuesArray(Class<?> arrayClass) {
 746         Class<?> componentType = arrayClass.getComponentType();
 747         assert componentType.isValueType() && UNSAFE.isFlattenedArray(arrayClass);
 748         // should cache these VarHandle for performance
 749         return VarHandles.makeArrayElementHandle(arrayClass);
 750     }
 751 #end[Reference]
 752 
 753     static final class Array extends VarHandle {
 754         final int abase;
 755         final int ashift;
 756 #if[Object]
 757         final Class<{#if[Object]??:$type$[]}> arrayType;
 758         final Class<?> componentType;
 759 #end[Object]
 760 
 761         Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) {
 762             this(abase, ashift{#if[Object]?, arrayType}, false);
 763         }
 764 
 765         private Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}, boolean exact) {
 766             super(Array.FORM, exact);
 767             this.abase = abase;
 768             this.ashift = ashift;
 769 #if[Object]
 770             this.arrayType = {#if[Object]?arrayType:$type$[].class};
 771             this.componentType = arrayType.getComponentType();

 786                 : new Array(abase, ashift{#if[Object]?, arrayType}, false);
 787         }
 788 
 789         @Override
 790         public Optional<VarHandleDesc> describeConstable() {
 791             var arrayTypeRef = {#if[Object]?arrayType:$type$[].class}.describeConstable();
 792             if (!arrayTypeRef.isPresent())
 793                 return Optional.empty();
 794 
 795             return Optional.of(VarHandleDesc.ofArray(arrayTypeRef.get()));
 796         }
 797 
 798         @Override
 799         final MethodType accessModeTypeUncached(AccessType at) {
 800             return at.accessModeType({#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
 801         }
 802 
 803 #if[Object]
 804         @ForceInline
 805         static Object runtimeTypeCheck(Array handle, Object[] oarray, Object value) {
 806             if (handle.componentType.isValueType())
 807                  Objects.requireNonNull(value);
 808 
 809             if (handle.arrayType == oarray.getClass()) {
 810                 // Fast path: static array type same as argument array type
 811                 return handle.componentType.cast(value);
 812             } else {
 813                 // Slow path: check value against argument array component type
 814                 return reflectiveTypeCheck(oarray, value);
 815             }
 816         }
 817 
 818         @ForceInline
 819         static Object reflectiveTypeCheck(Object[] oarray, Object value) {
 820             try {
 821                 return oarray.getClass().getComponentType().cast(value);
 822             } catch (ClassCastException e) {
 823                 throw new ArrayStoreException();
 824             }
 825         }
 826 #end[Object]
 827 
 828         @ForceInline
 829         static $type$ get(VarHandle ob, Object oarray, int index) {
 830             Array handle = (Array)ob;
 831 #if[Object]
 832             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 833 #else[Object]
 834             $type$[] array = ($type$[]) oarray;
 835 #end[Object]
 836             return array[index];
 837         }
 838 
 839         @ForceInline
 840         static void set(VarHandle ob, Object oarray, int index, $type$ value) {
 841             Array handle = (Array)ob;
 842 #if[Object]
 843             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 844 #else[Object]
 845             $type$[] array = ($type$[]) oarray;
 846 #end[Object]
 847 #if[Reference]
 848             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 849                 // for flattened array, delegate to VarHandle of the inline type array
 850                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 851                 vh.set(oarray, index, reflectiveTypeCheck(array, value));
 852                 return;
 853             }
 854 #end[Reference]
 855             array[index] = {#if[Object]?runtimeTypeCheck(handle, array, value):value};
 856         }
 857 
 858         @ForceInline
 859         static $type$ getVolatile(VarHandle ob, Object oarray, int index) {
 860             Array handle = (Array)ob;
 861 #if[Object]
 862             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 863 #else[Object]
 864             $type$[] array = ($type$[]) oarray;
 865 #end[Object]
 866 #if[Reference]
 867             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 868                 // for flattened array, delegate to VarHandle of the inline type array
 869                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 870                 return vh.getVolatile(oarray, index);
 871             }
 872 #end[Reference]
 873             return UNSAFE.get$Type$Volatile(array,
 874                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType});
 875         }
 876 
 877         @ForceInline
 878         static void setVolatile(VarHandle ob, Object oarray, int index, $type$ value) {
 879             Array handle = (Array)ob;
 880 #if[Object]
 881             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 882 #else[Object]
 883             $type$[] array = ($type$[]) oarray;
 884 #end[Object]
 885 #if[Reference]
 886             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 887                 // for flattened array, delegate to VarHandle of the inline type array
 888                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 889                 vh.setVolatile(oarray, index, reflectiveTypeCheck(array, value));
 890                 return;
 891             }
 892 #end[Reference]
 893             UNSAFE.put$Type$Volatile(array,
 894                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
 895                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 896         }
 897 
 898         @ForceInline
 899         static $type$ getOpaque(VarHandle ob, Object oarray, int index) {
 900             Array handle = (Array)ob;
 901 #if[Object]
 902             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 903 #else[Object]
 904             $type$[] array = ($type$[]) oarray;
 905 #end[Object]
 906 #if[Reference]
 907             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 908                 // for flattened array, delegate to VarHandle of the inline type array
 909                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 910                 return vh.getOpaque(oarray, index);
 911             }
 912 #end[Reference]
 913             return UNSAFE.get$Type$Opaque(array,
 914                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType});
 915         }
 916 
 917         @ForceInline
 918         static void setOpaque(VarHandle ob, Object oarray, int index, $type$ value) {
 919             Array handle = (Array)ob;
 920 #if[Object]
 921             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 922 #else[Object]
 923             $type$[] array = ($type$[]) oarray;
 924 #end[Object]
 925 #if[Reference]
 926             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 927                 // for flattened array, delegate to VarHandle of the inline type array
 928                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 929                 vh.setOpaque(oarray, index, reflectiveTypeCheck(array, value));
 930                 return;
 931             }
 932 #end[Reference]
 933             UNSAFE.put$Type$Opaque(array,
 934                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
 935                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 936         }
 937 
 938         @ForceInline
 939         static $type$ getAcquire(VarHandle ob, Object oarray, int index) {
 940             Array handle = (Array)ob;
 941 #if[Object]
 942             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 943 #else[Object]
 944             $type$[] array = ($type$[]) oarray;
 945 #end[Object]
 946 #if[Reference]
 947             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 948                 // for flattened array, delegate to VarHandle of the inline type array
 949                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 950                 return vh.getAcquire(oarray, index);
 951             }
 952 #end[Reference]
 953             return UNSAFE.get$Type$Acquire(array,
 954                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType});
 955         }
 956 
 957         @ForceInline
 958         static void setRelease(VarHandle ob, Object oarray, int index, $type$ value) {
 959             Array handle = (Array)ob;
 960 #if[Object]
 961             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 962 #else[Object]
 963             $type$[] array = ($type$[]) oarray;
 964 #end[Object]
 965 #if[Reference]
 966             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 967                 // for flattened array, delegate to VarHandle of the inline type array
 968                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 969                 vh.setRelease(oarray, index, reflectiveTypeCheck(array, value));
 970                 return;
 971             }
 972 #end[Reference]
 973             UNSAFE.put$Type$Release(array,
 974                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
 975                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 976         }
 977 #if[CAS]
 978 
 979         @ForceInline
 980         static boolean compareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
 981             Array handle = (Array)ob;
 982 #if[Object]
 983             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 984 #else[Object]
 985             $type$[] array = ($type$[]) oarray;
 986 #end[Object]
 987 #if[Reference]
 988             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 989                 // for flattened array, delegate to VarHandle of the inline type array
 990                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 991                 return vh.compareAndSet(oarray, index, expected, reflectiveTypeCheck(array, value));
 992             }
 993 #end[Reference]
 994             return UNSAFE.compareAndSet$Type$(array,
 995                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 996                     {#if[Object]?handle.componentType.cast(expected):expected},
 997                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 998         }
 999 
1000         @ForceInline
1001         static $type$ compareAndExchange(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 #if[Reference]
1009             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1010                 // for flattened array, delegate to VarHandle of the inline type array
1011                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1012                 return vh.compareAndExchange(oarray, index, expected, reflectiveTypeCheck(array, value));
1013             }
1014 #end[Reference]
1015             return UNSAFE.compareAndExchange$Type$(array,
1016                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
1017                     {#if[Object]?handle.componentType.cast(expected):expected},
1018                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1019         }
1020 
1021         @ForceInline
1022         static $type$ compareAndExchangeAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1023             Array handle = (Array)ob;
1024 #if[Object]
1025             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1026 #else[Object]
1027             $type$[] array = ($type$[]) oarray;
1028 #end[Object]
1029 #if[Reference]
1030             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1031                 // for flattened array, delegate to VarHandle of the inline type array
1032                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1033                 return vh.compareAndExchangeAcquire(oarray, index, expected, reflectiveTypeCheck(array, value));
1034             }
1035 #end[Reference]
1036             return UNSAFE.compareAndExchange$Type$Acquire(array,
1037                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
1038                     {#if[Object]?handle.componentType.cast(expected):expected},
1039                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1040         }
1041 
1042         @ForceInline
1043         static $type$ compareAndExchangeRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1044             Array handle = (Array)ob;
1045 #if[Object]
1046             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1047 #else[Object]
1048             $type$[] array = ($type$[]) oarray;
1049 #end[Object]
1050 #if[Reference]
1051             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1052                 // for flattened array, delegate to VarHandle of the inline type array
1053                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1054                 return vh.compareAndExchangeRelease(oarray, index, expected, reflectiveTypeCheck(array, value));
1055             }
1056 #end[Reference]
1057             return UNSAFE.compareAndExchange$Type$Release(array,
1058                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
1059                     {#if[Object]?handle.componentType.cast(expected):expected},
1060                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1061         }
1062 
1063         @ForceInline
1064         static boolean weakCompareAndSetPlain(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1065             Array handle = (Array)ob;
1066 #if[Object]
1067             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1068 #else[Object]
1069             $type$[] array = ($type$[]) oarray;
1070 #end[Object]
1071 #if[Reference]
1072             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1073                 // for flattened array, delegate to VarHandle of the inline type array
1074                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1075                 return vh.weakCompareAndSetPlain(oarray, index, expected, reflectiveTypeCheck(array, value));
1076             }
1077 #end[Reference]
1078             return UNSAFE.weakCompareAndSet$Type$Plain(array,
1079                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
1080                     {#if[Object]?handle.componentType.cast(expected):expected},
1081                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1082         }
1083 
1084         @ForceInline
1085         static boolean weakCompareAndSet(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1086             Array handle = (Array)ob;
1087 #if[Object]
1088             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1089 #else[Object]
1090             $type$[] array = ($type$[]) oarray;
1091 #end[Object]
1092 #if[Reference]
1093             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1094                 // for flattened array, delegate to VarHandle of the inline type array
1095                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1096                 return vh.weakCompareAndSet(oarray, index, expected, reflectiveTypeCheck(array, value));
1097             }
1098 #end[Reference]
1099             return UNSAFE.weakCompareAndSet$Type$(array,
1100                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
1101                     {#if[Object]?handle.componentType.cast(expected):expected},
1102                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1103         }
1104 
1105         @ForceInline
1106         static boolean weakCompareAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1107             Array handle = (Array)ob;
1108 #if[Object]
1109             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1110 #else[Object]
1111             $type$[] array = ($type$[]) oarray;
1112 #end[Object]
1113 #if[Reference]
1114             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1115                 // for flattened array, delegate to VarHandle of the inline type array
1116                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1117                 return vh.weakCompareAndSetAcquire(oarray, index, expected, reflectiveTypeCheck(array, value));
1118             }
1119 #end[Reference]
1120             return UNSAFE.weakCompareAndSet$Type$Acquire(array,
1121                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
1122                     {#if[Object]?handle.componentType.cast(expected):expected},
1123                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1124         }
1125 
1126         @ForceInline
1127         static boolean weakCompareAndSetRelease(VarHandle ob, Object oarray, int index, $type$ expected, $type$ value) {
1128             Array handle = (Array)ob;
1129 #if[Object]
1130             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1131 #else[Object]
1132             $type$[] array = ($type$[]) oarray;
1133 #end[Object]
1134 #if[Reference]
1135             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1136                 // for flattened array, delegate to VarHandle of the inline type array
1137                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1138                 return vh.weakCompareAndSetRelease(oarray, index, expected, reflectiveTypeCheck(array, value));
1139             }
1140 #end[Reference]
1141             return UNSAFE.weakCompareAndSet$Type$Release(array,
1142                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
1143                     {#if[Object]?handle.componentType.cast(expected):expected},
1144                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1145         }
1146 
1147         @ForceInline
1148         static $type$ getAndSet(VarHandle ob, Object oarray, int index, $type$ value) {
1149             Array handle = (Array)ob;
1150 #if[Object]
1151             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1152 #else[Object]
1153             $type$[] array = ($type$[]) oarray;
1154 #end[Object]
1155 #if[Reference]
1156             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1157                 // for flattened array, delegate to VarHandle of the inline type array
1158                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1159                 return vh.getAndSet(oarray, index, reflectiveTypeCheck(array, value));
1160             }
1161 #end[Reference]
1162             return UNSAFE.getAndSet$Type$(array,
1163                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
1164                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1165         }
1166 
1167         @ForceInline
1168         static $type$ getAndSetAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1169             Array handle = (Array)ob;
1170 #if[Object]
1171             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1172 #else[Object]
1173             $type$[] array = ($type$[]) oarray;
1174 #end[Object]
1175 #if[Reference]
1176             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1177                 // for flattened array, delegate to VarHandle of the inline type array
1178                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1179                 return vh.getAndSetAcquire(oarray, index, reflectiveTypeCheck(array, value));
1180             }
1181 #end[Reference]
1182             return UNSAFE.getAndSet$Type$Acquire(array,
1183                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
1184                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1185         }
1186 
1187         @ForceInline
1188         static $type$ getAndSetRelease(VarHandle ob, Object oarray, int index, $type$ value) {
1189             Array handle = (Array)ob;
1190 #if[Object]
1191             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1192 #else[Object]
1193             $type$[] array = ($type$[]) oarray;
1194 #end[Object]
1195 #if[Reference]
1196             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1197                 // for flattened array, delegate to VarHandle of the inline type array
1198                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1199                 return vh.getAndSetRelease(oarray, index, reflectiveTypeCheck(array, value));
1200             }
1201 #end[Reference]
1202             return UNSAFE.getAndSet$Type$Release(array,
1203                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
1204                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1205         }
1206 #end[CAS]
1207 #if[AtomicAdd]
1208 
1209         @ForceInline
1210         static $type$ getAndAdd(VarHandle ob, Object oarray, int index, $type$ value) {
1211             Array handle = (Array)ob;
1212             $type$[] array = ($type$[]) oarray;
1213             return UNSAFE.getAndAdd$Type$(array,
1214                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
1215                     value);
1216         }
1217 
1218         @ForceInline
1219         static $type$ getAndAddAcquire(VarHandle ob, Object oarray, int index, $type$ value) {
1220             Array handle = (Array)ob;
1221             $type$[] array = ($type$[]) oarray;
1222             return UNSAFE.getAndAdd$Type$Acquire(array,
1223                     (((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
< prev index next >