< 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();

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

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

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

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

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