< prev index next >

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

Print this page




  62         final MethodType accessModeTypeUncached(AccessMode accessMode) {
  63             return accessMode.at.accessModeType(receiverType, {#if[Object]?fieldType:$type$.class});
  64         }
  65 
  66         @Override
  67         public Optional<VarHandleDesc> describeConstable() {
  68             var receiverTypeRef = receiverType.describeConstable();
  69             var fieldTypeRef = {#if[Object]?fieldType:$type$.class}.describeConstable();
  70             if (!receiverTypeRef.isPresent() || !fieldTypeRef.isPresent())
  71                 return Optional.empty();
  72 
  73             // Reflect on this VarHandle to extract the field name
  74             String name = VarHandles.getFieldFromReceiverAndOffset(
  75                 receiverType, fieldOffset, {#if[Object]?fieldType:$type$.class}).getName();
  76             return Optional.of(VarHandleDesc.ofField(receiverTypeRef.get(), name, fieldTypeRef.get()));
  77         }
  78 
  79         @ForceInline
  80         static $type$ get(FieldInstanceReadOnly handle, Object holder) {
  81             return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
  82                                  handle.fieldOffset);
  83         }
  84 
  85         @ForceInline
  86         static $type$ getVolatile(FieldInstanceReadOnly handle, Object holder) {
  87             return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
  88                                  handle.fieldOffset);
  89         }
  90 
  91         @ForceInline
  92         static $type$ getOpaque(FieldInstanceReadOnly handle, Object holder) {
  93             return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
  94                                  handle.fieldOffset);
  95         }
  96 
  97         @ForceInline
  98         static $type$ getAcquire(FieldInstanceReadOnly handle, Object holder) {
  99             return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 100                                  handle.fieldOffset);
 101         }
 102 
 103         static final VarForm FORM = new VarForm(FieldInstanceReadOnly.class, Object.class, $type$.class);
 104     }
 105 
 106     static final class FieldInstanceReadWrite extends FieldInstanceReadOnly {
 107 
 108         FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 109             super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.FORM);
 110         }
 111 









 112         @ForceInline
 113         static void set(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 114             UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 115                              handle.fieldOffset,
 116                              {#if[Object]?handle.fieldType.cast(value):value});
 117         }
 118 
 119         @ForceInline
 120         static void setVolatile(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 121             UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
 122                                      handle.fieldOffset,
 123                                      {#if[Object]?handle.fieldType.cast(value):value});
 124         }
 125 
 126         @ForceInline
 127         static void setOpaque(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 128             UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
 129                                    handle.fieldOffset,
 130                                    {#if[Object]?handle.fieldType.cast(value):value});
 131         }
 132 
 133         @ForceInline
 134         static void setRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 135             UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 136                                     handle.fieldOffset,
 137                                     {#if[Object]?handle.fieldType.cast(value):value});
 138         }
 139 #if[CAS]
 140 
 141         @ForceInline
 142         static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 143             return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 144                                                handle.fieldOffset,
 145                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 146                                                {#if[Object]?handle.fieldType.cast(value):value});
 147         }
 148 
 149         @ForceInline
 150         static $type$ compareAndExchange(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 151             return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 152                                                handle.fieldOffset,
 153                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 154                                                {#if[Object]?handle.fieldType.cast(value):value});
 155         }
 156 
 157         @ForceInline
 158         static $type$ compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 159             return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 160                                                handle.fieldOffset,
 161                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 162                                                {#if[Object]?handle.fieldType.cast(value):value});
 163         }
 164 
 165         @ForceInline
 166         static $type$ compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 167             return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 168                                                handle.fieldOffset,
 169                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 170                                                {#if[Object]?handle.fieldType.cast(value):value});
 171         }
 172 
 173         @ForceInline
 174         static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 175             return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)),
 176                                                handle.fieldOffset,
 177                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 178                                                {#if[Object]?handle.fieldType.cast(value):value});
 179         }
 180 
 181         @ForceInline
 182         static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 183             return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 184                                                handle.fieldOffset,
 185                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 186                                                {#if[Object]?handle.fieldType.cast(value):value});
 187         }
 188 
 189         @ForceInline
 190         static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 191             return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 192                                                handle.fieldOffset,
 193                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 194                                                {#if[Object]?handle.fieldType.cast(value):value});
 195         }
 196 
 197         @ForceInline
 198         static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 199             return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 200                                                handle.fieldOffset,
 201                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 202                                                {#if[Object]?handle.fieldType.cast(value):value});
 203         }
 204 
 205         @ForceInline
 206         static $type$ getAndSet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 207             return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 208                                           handle.fieldOffset,
 209                                           {#if[Object]?handle.fieldType.cast(value):value});
 210         }
 211 
 212         @ForceInline
 213         static $type$ getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 214             return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 215                                           handle.fieldOffset,
 216                                           {#if[Object]?handle.fieldType.cast(value):value});
 217         }
 218 
 219         @ForceInline
 220         static $type$ getAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 221             return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 222                                           handle.fieldOffset,
 223                                           {#if[Object]?handle.fieldType.cast(value):value});
 224         }
 225 #end[CAS]
 226 #if[AtomicAdd]
 227 
 228         @ForceInline
 229         static $type$ getAndAdd(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 230             return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 231                                        handle.fieldOffset,
 232                                        value);
 233         }
 234 
 235         @ForceInline
 236         static $type$ getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 237             return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 238                                        handle.fieldOffset,
 239                                        value);
 240         }
 241 
 242         @ForceInline
 243         static $type$ getAndAddRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {


 344             if (!fieldTypeRef.isPresent())
 345                 return Optional.empty();
 346 
 347             // Reflect on this VarHandle to extract the field name
 348             var staticField = VarHandles.getStaticFieldFromBaseAndOffset(
 349                 base, fieldOffset, {#if[Object]?fieldType:$type$.class});
 350             var receiverTypeRef = staticField.getDeclaringClass().describeConstable();
 351             if (!receiverTypeRef.isPresent())
 352                 return Optional.empty();
 353             return Optional.of(VarHandleDesc.ofStaticField(receiverTypeRef.get(), staticField.getName(), fieldTypeRef.get()));
 354         }
 355 
 356         @Override
 357         final MethodType accessModeTypeUncached(AccessMode accessMode) {
 358             return accessMode.at.accessModeType(null, {#if[Object]?fieldType:$type$.class});
 359         }
 360 
 361         @ForceInline
 362         static $type$ get(FieldStaticReadOnly handle) {
 363             return UNSAFE.get$Type$(handle.base,
 364                                  handle.fieldOffset);
 365         }
 366 
 367         @ForceInline
 368         static $type$ getVolatile(FieldStaticReadOnly handle) {
 369             return UNSAFE.get$Type$Volatile(handle.base,
 370                                  handle.fieldOffset);
 371         }
 372 
 373         @ForceInline
 374         static $type$ getOpaque(FieldStaticReadOnly handle) {
 375             return UNSAFE.get$Type$Opaque(handle.base,
 376                                  handle.fieldOffset);
 377         }
 378 
 379         @ForceInline
 380         static $type$ getAcquire(FieldStaticReadOnly handle) {
 381             return UNSAFE.get$Type$Acquire(handle.base,
 382                                  handle.fieldOffset);
 383         }
 384 
 385         static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, $type$.class);
 386     }
 387 
 388     static final class FieldStaticReadWrite extends FieldStaticReadOnly {
 389 
 390         FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 391             super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM);
 392         }
 393 








 394         @ForceInline
 395         static void set(FieldStaticReadWrite handle, $type$ value) {
 396             UNSAFE.put$Type$(handle.base,
 397                              handle.fieldOffset,
 398                              {#if[Object]?handle.fieldType.cast(value):value});
 399         }
 400 
 401         @ForceInline
 402         static void setVolatile(FieldStaticReadWrite handle, $type$ value) {
 403             UNSAFE.put$Type$Volatile(handle.base,
 404                                      handle.fieldOffset,
 405                                      {#if[Object]?handle.fieldType.cast(value):value});
 406         }
 407 
 408         @ForceInline
 409         static void setOpaque(FieldStaticReadWrite handle, $type$ value) {
 410             UNSAFE.put$Type$Opaque(handle.base,
 411                                    handle.fieldOffset,
 412                                    {#if[Object]?handle.fieldType.cast(value):value});
 413         }
 414 
 415         @ForceInline
 416         static void setRelease(FieldStaticReadWrite handle, $type$ value) {
 417             UNSAFE.put$Type$Release(handle.base,
 418                                     handle.fieldOffset,
 419                                     {#if[Object]?handle.fieldType.cast(value):value});
 420         }
 421 #if[CAS]
 422 
 423         @ForceInline
 424         static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 425             return UNSAFE.compareAndSet$Type$(handle.base,
 426                                                handle.fieldOffset,
 427                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 428                                                {#if[Object]?handle.fieldType.cast(value):value});
 429         }
 430 
 431 
 432         @ForceInline
 433         static $type$ compareAndExchange(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 434             return UNSAFE.compareAndExchange$Type$(handle.base,
 435                                                handle.fieldOffset,
 436                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 437                                                {#if[Object]?handle.fieldType.cast(value):value});
 438         }
 439 
 440         @ForceInline
 441         static $type$ compareAndExchangeAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 442             return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
 443                                                handle.fieldOffset,
 444                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 445                                                {#if[Object]?handle.fieldType.cast(value):value});
 446         }
 447 
 448         @ForceInline
 449         static $type$ compareAndExchangeRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 450             return UNSAFE.compareAndExchange$Type$Release(handle.base,
 451                                                handle.fieldOffset,
 452                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 453                                                {#if[Object]?handle.fieldType.cast(value):value});
 454         }
 455 
 456         @ForceInline
 457         static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 458             return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
 459                                                handle.fieldOffset,
 460                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 461                                                {#if[Object]?handle.fieldType.cast(value):value});
 462         }
 463 
 464         @ForceInline
 465         static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 466             return UNSAFE.weakCompareAndSet$Type$(handle.base,
 467                                                handle.fieldOffset,
 468                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 469                                                {#if[Object]?handle.fieldType.cast(value):value});
 470         }
 471 
 472         @ForceInline
 473         static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 474             return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
 475                                                handle.fieldOffset,
 476                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 477                                                {#if[Object]?handle.fieldType.cast(value):value});
 478         }
 479 
 480         @ForceInline
 481         static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 482             return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
 483                                                handle.fieldOffset,
 484                                                {#if[Object]?handle.fieldType.cast(expected):expected},
 485                                                {#if[Object]?handle.fieldType.cast(value):value});
 486         }
 487 
 488         @ForceInline
 489         static $type$ getAndSet(FieldStaticReadWrite handle, $type$ value) {
 490             return UNSAFE.getAndSet$Type$(handle.base,
 491                                           handle.fieldOffset,
 492                                           {#if[Object]?handle.fieldType.cast(value):value});
 493         }
 494 
 495         @ForceInline
 496         static $type$ getAndSetAcquire(FieldStaticReadWrite handle, $type$ value) {
 497             return UNSAFE.getAndSet$Type$Acquire(handle.base,
 498                                           handle.fieldOffset,
 499                                           {#if[Object]?handle.fieldType.cast(value):value});
 500         }
 501 
 502         @ForceInline
 503         static $type$ getAndSetRelease(FieldStaticReadWrite handle, $type$ value) {
 504             return UNSAFE.getAndSet$Type$Release(handle.base,
 505                                           handle.fieldOffset,
 506                                           {#if[Object]?handle.fieldType.cast(value):value});
 507         }
 508 #end[CAS]
 509 #if[AtomicAdd]
 510 
 511         @ForceInline
 512         static $type$ getAndAdd(FieldStaticReadWrite handle, $type$ value) {
 513             return UNSAFE.getAndAdd$Type$(handle.base,
 514                                        handle.fieldOffset,
 515                                        value);
 516         }
 517 
 518         @ForceInline
 519         static $type$ getAndAddAcquire(FieldStaticReadWrite handle, $type$ value) {
 520             return UNSAFE.getAndAdd$Type$Acquire(handle.base,
 521                                        handle.fieldOffset,
 522                                        value);
 523         }
 524 
 525         @ForceInline
 526         static $type$ getAndAddRelease(FieldStaticReadWrite handle, $type$ value) {


 581         }
 582 
 583         @ForceInline
 584         static $type$ getAndBitwiseXorRelease(FieldStaticReadWrite handle, $type$ value) {
 585             return UNSAFE.getAndBitwiseXor$Type$Release(handle.base,
 586                                        handle.fieldOffset,
 587                                        value);
 588         }
 589 
 590         @ForceInline
 591         static $type$ getAndBitwiseXorAcquire(FieldStaticReadWrite handle, $type$ value) {
 592             return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base,
 593                                        handle.fieldOffset,
 594                                        value);
 595         }
 596 #end[Bitwise]
 597 
 598         static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class);
 599     }
 600 








 601 
 602     static final class Array extends VarHandle {
 603         final int abase;
 604         final int ashift;
 605 #if[Object]
 606         final Class<{#if[Object]??:$type$[]}> arrayType;
 607         final Class<?> componentType;
 608 #end[Object]
 609 
 610         Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) {
 611             super(Array.FORM);
 612             this.abase = abase;
 613             this.ashift = ashift;
 614 #if[Object]
 615             this.arrayType = {#if[Object]?arrayType:$type$[].class};
 616             this.componentType = arrayType.getComponentType();
 617 #end[Object]
 618         }
 619 
 620         @Override
 621         public Optional<VarHandleDesc> describeConstable() {
 622             var arrayTypeRef = {#if[Object]?arrayType:$type$[].class}.describeConstable();
 623             if (!arrayTypeRef.isPresent())
 624                 return Optional.empty();
 625 
 626             return Optional.of(VarHandleDesc.ofArray(arrayTypeRef.get()));
 627         }
 628 
 629         @Override
 630         final MethodType accessModeTypeUncached(AccessMode accessMode) {
 631             return accessMode.at.accessModeType({#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
 632         }
 633 
 634 #if[Object]
 635         @ForceInline
 636         static Object runtimeTypeCheck(Array handle, Object[] oarray, Object value) {



 637             if (handle.arrayType == oarray.getClass()) {
 638                 // Fast path: static array type same as argument array type
 639                 return handle.componentType.cast(value);
 640             } else {
 641                 // Slow path: check value against argument array component type
 642                 return reflectiveTypeCheck(oarray, value);
 643             }
 644         }
 645 
 646         @ForceInline
 647         static Object reflectiveTypeCheck(Object[] oarray, Object value) {
 648             try {
 649                 return oarray.getClass().getComponentType().cast(value);
 650             } catch (ClassCastException e) {
 651                 throw new ArrayStoreException();
 652             }
 653         }
 654 #end[Object]
 655 
 656         @ForceInline
 657         static $type$ get(Array handle, Object oarray, int index) {
 658 #if[Object]
 659             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 660 #else[Object]
 661             $type$[] array = ($type$[]) oarray;
 662 #end[Object]
 663             return array[index];
 664         }
 665 
 666         @ForceInline
 667         static void set(Array handle, Object oarray, int index, $type$ value) {
 668 #if[Object]
 669             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 670 #else[Object]
 671             $type$[] array = ($type$[]) oarray;
 672 #end[Object]
 673             array[index] = {#if[Object]?handle.componentType.cast(value):value};








 674         }
 675 
 676         @ForceInline
 677         static $type$ getVolatile(Array handle, Object oarray, int index) {
 678 #if[Object]
 679             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 680 #else[Object]
 681             $type$[] array = ($type$[]) oarray;
 682 #end[Object]







 683             return UNSAFE.get$Type$Volatile(array,
 684                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 685         }
 686 
 687         @ForceInline
 688         static void setVolatile(Array handle, Object oarray, int index, $type$ value) {
 689 #if[Object]
 690             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 691 #else[Object]
 692             $type$[] array = ($type$[]) oarray;
 693 #end[Object]








 694             UNSAFE.put$Type$Volatile(array,
 695                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 696                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 697         }
 698 
 699         @ForceInline
 700         static $type$ getOpaque(Array handle, Object oarray, int index) {
 701 #if[Object]
 702             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 703 #else[Object]
 704             $type$[] array = ($type$[]) oarray;
 705 #end[Object]







 706             return UNSAFE.get$Type$Opaque(array,
 707                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 708         }
 709 
 710         @ForceInline
 711         static void setOpaque(Array handle, Object oarray, int index, $type$ value) {
 712 #if[Object]
 713             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 714 #else[Object]
 715             $type$[] array = ($type$[]) oarray;
 716 #end[Object]








 717             UNSAFE.put$Type$Opaque(array,
 718                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 719                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 720         }
 721 
 722         @ForceInline
 723         static $type$ getAcquire(Array handle, Object oarray, int index) {
 724 #if[Object]
 725             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 726 #else[Object]
 727             $type$[] array = ($type$[]) oarray;
 728 #end[Object]







 729             return UNSAFE.get$Type$Acquire(array,
 730                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
 731         }
 732 
 733         @ForceInline
 734         static void setRelease(Array handle, Object oarray, int index, $type$ value) {
 735 #if[Object]
 736             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 737 #else[Object]
 738             $type$[] array = ($type$[]) oarray;
 739 #end[Object]








 740             UNSAFE.put$Type$Release(array,
 741                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 742                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 743         }
 744 #if[CAS]
 745 
 746         @ForceInline
 747         static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 748 #if[Object]
 749             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 750 #else[Object]
 751             $type$[] array = ($type$[]) oarray;
 752 #end[Object]







 753             return UNSAFE.compareAndSet$Type$(array,
 754                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 755                     {#if[Object]?handle.componentType.cast(expected):expected},
 756                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 757         }
 758 
 759         @ForceInline
 760         static $type$ compareAndExchange(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 761 #if[Object]
 762             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 763 #else[Object]
 764             $type$[] array = ($type$[]) oarray;
 765 #end[Object]







 766             return UNSAFE.compareAndExchange$Type$(array,
 767                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 768                     {#if[Object]?handle.componentType.cast(expected):expected},
 769                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 770         }
 771 
 772         @ForceInline
 773         static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 774 #if[Object]
 775             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 776 #else[Object]
 777             $type$[] array = ($type$[]) oarray;
 778 #end[Object]







 779             return UNSAFE.compareAndExchange$Type$Acquire(array,
 780                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 781                     {#if[Object]?handle.componentType.cast(expected):expected},
 782                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 783         }
 784 
 785         @ForceInline
 786         static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 787 #if[Object]
 788             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 789 #else[Object]
 790             $type$[] array = ($type$[]) oarray;
 791 #end[Object]







 792             return UNSAFE.compareAndExchange$Type$Release(array,
 793                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 794                     {#if[Object]?handle.componentType.cast(expected):expected},
 795                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 796         }
 797 
 798         @ForceInline
 799         static boolean weakCompareAndSetPlain(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 800 #if[Object]
 801             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 802 #else[Object]
 803             $type$[] array = ($type$[]) oarray;
 804 #end[Object]







 805             return UNSAFE.weakCompareAndSet$Type$Plain(array,
 806                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 807                     {#if[Object]?handle.componentType.cast(expected):expected},
 808                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 809         }
 810 
 811         @ForceInline
 812         static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 813 #if[Object]
 814             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 815 #else[Object]
 816             $type$[] array = ($type$[]) oarray;
 817 #end[Object]







 818             return UNSAFE.weakCompareAndSet$Type$(array,
 819                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 820                     {#if[Object]?handle.componentType.cast(expected):expected},
 821                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 822         }
 823 
 824         @ForceInline
 825         static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 826 #if[Object]
 827             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 828 #else[Object]
 829             $type$[] array = ($type$[]) oarray;
 830 #end[Object]







 831             return UNSAFE.weakCompareAndSet$Type$Acquire(array,
 832                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 833                     {#if[Object]?handle.componentType.cast(expected):expected},
 834                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 835         }
 836 
 837         @ForceInline
 838         static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 839 #if[Object]
 840             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 841 #else[Object]
 842             $type$[] array = ($type$[]) oarray;
 843 #end[Object]







 844             return UNSAFE.weakCompareAndSet$Type$Release(array,
 845                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 846                     {#if[Object]?handle.componentType.cast(expected):expected},
 847                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 848         }
 849 
 850         @ForceInline
 851         static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) {
 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.getAndSet$Type$(array,
 858                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 859                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 860         }
 861 
 862         @ForceInline
 863         static $type$ getAndSetAcquire(Array handle, Object oarray, int index, $type$ value) {
 864 #if[Object]
 865             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 866 #else[Object]
 867             $type$[] array = ($type$[]) oarray;
 868 #end[Object]







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







 881             return UNSAFE.getAndSet$Type$Release(array,
 882                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 883                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 884         }
 885 #end[CAS]
 886 #if[AtomicAdd]
 887 
 888         @ForceInline
 889         static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) {
 890             $type$[] array = ($type$[]) oarray;
 891             return UNSAFE.getAndAdd$Type$(array,
 892                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 893                     value);
 894         }
 895 
 896         @ForceInline
 897         static $type$ getAndAddAcquire(Array handle, Object oarray, int index, $type$ value) {
 898             $type$[] array = ($type$[]) oarray;
 899             return UNSAFE.getAndAdd$Type$Acquire(array,
 900                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
 901                     value);
 902         }




  62         final MethodType accessModeTypeUncached(AccessMode accessMode) {
  63             return accessMode.at.accessModeType(receiverType, {#if[Object]?fieldType:$type$.class});
  64         }
  65 
  66         @Override
  67         public Optional<VarHandleDesc> describeConstable() {
  68             var receiverTypeRef = receiverType.describeConstable();
  69             var fieldTypeRef = {#if[Object]?fieldType:$type$.class}.describeConstable();
  70             if (!receiverTypeRef.isPresent() || !fieldTypeRef.isPresent())
  71                 return Optional.empty();
  72 
  73             // Reflect on this VarHandle to extract the field name
  74             String name = VarHandles.getFieldFromReceiverAndOffset(
  75                 receiverType, fieldOffset, {#if[Object]?fieldType:$type$.class}).getName();
  76             return Optional.of(VarHandleDesc.ofField(receiverTypeRef.get(), name, fieldTypeRef.get()));
  77         }
  78 
  79         @ForceInline
  80         static $type$ get(FieldInstanceReadOnly handle, Object holder) {
  81             return UNSAFE.get$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
  82                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
  83         }
  84 
  85         @ForceInline
  86         static $type$ getVolatile(FieldInstanceReadOnly handle, Object holder) {
  87             return UNSAFE.get$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
  88                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
  89         }
  90 
  91         @ForceInline
  92         static $type$ getOpaque(FieldInstanceReadOnly handle, Object holder) {
  93             return UNSAFE.get$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
  94                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
  95         }
  96 
  97         @ForceInline
  98         static $type$ getAcquire(FieldInstanceReadOnly handle, Object holder) {
  99             return UNSAFE.get$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 100                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 101         }
 102 
 103         static final VarForm FORM = new VarForm(FieldInstanceReadOnly.class, Object.class, $type$.class);
 104     }
 105 
 106     static final class FieldInstanceReadWrite extends FieldInstanceReadOnly {

 107         FieldInstanceReadWrite(Class<?> receiverType, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 108             super(receiverType, fieldOffset{#if[Object]?, fieldType}, FieldInstanceReadWrite.FORM);
 109         }
 110 
 111 #if[Object]
 112         @ForceInline
 113         static Object checkCast(FieldInstanceReadWrite handle, $type$ value) {
 114             if (!handle.fieldType.isNullableType())
 115                 Objects.requireNonNull(value);
 116             return handle.fieldType.cast(value);
 117         }
 118 #end[Object]
 119 
 120         @ForceInline
 121         static void set(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 122             UNSAFE.put$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 123                              handle.fieldOffset{#if[Value]?, handle.fieldType},
 124                              {#if[Object]?checkCast(handle, value):value});
 125         }
 126 
 127         @ForceInline
 128         static void setVolatile(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 129             UNSAFE.put$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
 130                                      handle.fieldOffset{#if[Value]?, handle.fieldType},
 131                                      {#if[Object]?checkCast(handle, value):value});
 132         }
 133 
 134         @ForceInline
 135         static void setOpaque(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 136             UNSAFE.put$Type$Opaque(Objects.requireNonNull(handle.receiverType.cast(holder)),
 137                                    handle.fieldOffset{#if[Value]?, handle.fieldType},
 138                                    {#if[Object]?checkCast(handle, value):value});
 139         }
 140 
 141         @ForceInline
 142         static void setRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 143             UNSAFE.put$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 144                                     handle.fieldOffset{#if[Value]?, handle.fieldType},
 145                                     {#if[Object]?checkCast(handle, value):value});
 146         }
 147 #if[CAS]
 148 
 149         @ForceInline
 150         static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 151             return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 152                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 153                                                {#if[Object]?checkCast(handle, expected):expected},
 154                                                {#if[Object]?checkCast(handle, value):value});
 155         }
 156 
 157         @ForceInline
 158         static $type$ compareAndExchange(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 159             return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 160                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 161                                                {#if[Object]?checkCast(handle, expected):expected},
 162                                                {#if[Object]?checkCast(handle, value):value});
 163         }
 164 
 165         @ForceInline
 166         static $type$ compareAndExchangeAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 167             return UNSAFE.compareAndExchange$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 168                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 169                                                {#if[Object]?checkCast(handle, expected):expected},
 170                                                {#if[Object]?checkCast(handle, value):value});
 171         }
 172 
 173         @ForceInline
 174         static $type$ compareAndExchangeRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 175             return UNSAFE.compareAndExchange$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 176                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 177                                                {#if[Object]?checkCast(handle, expected):expected},
 178                                                {#if[Object]?checkCast(handle, value):value});
 179         }
 180 
 181         @ForceInline
 182         static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 183             return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)),
 184                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 185                                                {#if[Object]?checkCast(handle, expected):expected},
 186                                                {#if[Object]?checkCast(handle, value):value});
 187         }
 188 
 189         @ForceInline
 190         static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 191             return UNSAFE.weakCompareAndSet$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 boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 199             return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 200                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 201                                                {#if[Object]?checkCast(handle, expected):expected},
 202                                                {#if[Object]?checkCast(handle, value):value});
 203         }
 204 
 205         @ForceInline
 206         static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
 207             return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 208                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 209                                                {#if[Object]?checkCast(handle, expected):expected},
 210                                                {#if[Object]?checkCast(handle, value):value});
 211         }
 212 
 213         @ForceInline
 214         static $type$ getAndSet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 215             return UNSAFE.getAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 216                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 217                                           {#if[Object]?checkCast(handle, value):value});
 218         }
 219 
 220         @ForceInline
 221         static $type$ getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 222             return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 223                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 224                                           {#if[Object]?checkCast(handle, value):value});
 225         }
 226 
 227         @ForceInline
 228         static $type$ getAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 229             return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
 230                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 231                                           {#if[Object]?checkCast(handle, value):value});
 232         }
 233 #end[CAS]
 234 #if[AtomicAdd]
 235 
 236         @ForceInline
 237         static $type$ getAndAdd(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 238             return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
 239                                        handle.fieldOffset,
 240                                        value);
 241         }
 242 
 243         @ForceInline
 244         static $type$ getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) {
 245             return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
 246                                        handle.fieldOffset,
 247                                        value);
 248         }
 249 
 250         @ForceInline
 251         static $type$ getAndAddRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) {


 352             if (!fieldTypeRef.isPresent())
 353                 return Optional.empty();
 354 
 355             // Reflect on this VarHandle to extract the field name
 356             var staticField = VarHandles.getStaticFieldFromBaseAndOffset(
 357                 base, fieldOffset, {#if[Object]?fieldType:$type$.class});
 358             var receiverTypeRef = staticField.getDeclaringClass().describeConstable();
 359             if (!receiverTypeRef.isPresent())
 360                 return Optional.empty();
 361             return Optional.of(VarHandleDesc.ofStaticField(receiverTypeRef.get(), staticField.getName(), fieldTypeRef.get()));
 362         }
 363 
 364         @Override
 365         final MethodType accessModeTypeUncached(AccessMode accessMode) {
 366             return accessMode.at.accessModeType(null, {#if[Object]?fieldType:$type$.class});
 367         }
 368 
 369         @ForceInline
 370         static $type$ get(FieldStaticReadOnly handle) {
 371             return UNSAFE.get$Type$(handle.base,
 372                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 373         }
 374 
 375         @ForceInline
 376         static $type$ getVolatile(FieldStaticReadOnly handle) {
 377             return UNSAFE.get$Type$Volatile(handle.base,
 378                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 379         }
 380 
 381         @ForceInline
 382         static $type$ getOpaque(FieldStaticReadOnly handle) {
 383             return UNSAFE.get$Type$Opaque(handle.base,
 384                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 385         }
 386 
 387         @ForceInline
 388         static $type$ getAcquire(FieldStaticReadOnly handle) {
 389             return UNSAFE.get$Type$Acquire(handle.base,
 390                                  handle.fieldOffset{#if[Value]?, handle.fieldType});
 391         }
 392 
 393         static final VarForm FORM = new VarForm(FieldStaticReadOnly.class, null, $type$.class);
 394     }
 395 
 396     static final class FieldStaticReadWrite extends FieldStaticReadOnly {

 397         FieldStaticReadWrite(Object base, long fieldOffset{#if[Object]?, Class<?> fieldType}) {
 398             super(base, fieldOffset{#if[Object]?, fieldType}, FieldStaticReadWrite.FORM);
 399         }
 400 
 401 #if[Object]
 402         static Object checkCast(FieldStaticReadWrite handle, $type$ value) {
 403             if (!handle.fieldType.isNullableType())
 404                 Objects.requireNonNull(value);
 405             return handle.fieldType.cast(value);
 406         }
 407 #end[Object]
 408 
 409         @ForceInline
 410         static void set(FieldStaticReadWrite handle, $type$ value) {
 411             UNSAFE.put$Type$(handle.base,
 412                              handle.fieldOffset{#if[Value]?, handle.fieldType},
 413                              {#if[Object]?checkCast(handle, value):value});
 414         }
 415 
 416         @ForceInline
 417         static void setVolatile(FieldStaticReadWrite handle, $type$ value) {
 418             UNSAFE.put$Type$Volatile(handle.base,
 419                                      handle.fieldOffset{#if[Value]?, handle.fieldType},
 420                                      {#if[Object]?checkCast(handle, value):value});
 421         }
 422 
 423         @ForceInline
 424         static void setOpaque(FieldStaticReadWrite handle, $type$ value) {
 425             UNSAFE.put$Type$Opaque(handle.base,
 426                                    handle.fieldOffset{#if[Value]?, handle.fieldType},
 427                                    {#if[Object]?checkCast(handle, value):value});
 428         }
 429 
 430         @ForceInline
 431         static void setRelease(FieldStaticReadWrite handle, $type$ value) {
 432             UNSAFE.put$Type$Release(handle.base,
 433                                     handle.fieldOffset{#if[Value]?, handle.fieldType},
 434                                     {#if[Object]?checkCast(handle, value):value});
 435         }
 436 #if[CAS]
 437 
 438         @ForceInline
 439         static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 440             return UNSAFE.compareAndSet$Type$(handle.base,
 441                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 442                                                {#if[Object]?checkCast(handle, expected):expected},
 443                                                {#if[Object]?checkCast(handle, value):value});
 444         }
 445 
 446 
 447         @ForceInline
 448         static $type$ compareAndExchange(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 449             return UNSAFE.compareAndExchange$Type$(handle.base,
 450                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 451                                                {#if[Object]?checkCast(handle, expected):expected},
 452                                                {#if[Object]?checkCast(handle, value):value});
 453         }
 454 
 455         @ForceInline
 456         static $type$ compareAndExchangeAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 457             return UNSAFE.compareAndExchange$Type$Acquire(handle.base,
 458                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 459                                                {#if[Object]?checkCast(handle, expected):expected},
 460                                                {#if[Object]?checkCast(handle, value):value});
 461         }
 462 
 463         @ForceInline
 464         static $type$ compareAndExchangeRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 465             return UNSAFE.compareAndExchange$Type$Release(handle.base,
 466                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 467                                                {#if[Object]?checkCast(handle, expected):expected},
 468                                                {#if[Object]?checkCast(handle, value):value});
 469         }
 470 
 471         @ForceInline
 472         static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 473             return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
 474                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 475                                                {#if[Object]?checkCast(handle, expected):expected},
 476                                                {#if[Object]?checkCast(handle, value):value});
 477         }
 478 
 479         @ForceInline
 480         static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 481             return UNSAFE.weakCompareAndSet$Type$(handle.base,
 482                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 483                                                {#if[Object]?checkCast(handle, expected):expected},
 484                                                {#if[Object]?checkCast(handle, value):value});
 485         }
 486 
 487         @ForceInline
 488         static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 489             return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
 490                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 491                                                {#if[Object]?checkCast(handle, expected):expected},
 492                                                {#if[Object]?checkCast(handle, value):value});
 493         }
 494 
 495         @ForceInline
 496         static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
 497             return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
 498                                                handle.fieldOffset{#if[Object]?, handle.fieldType},
 499                                                {#if[Object]?checkCast(handle, expected):expected},
 500                                                {#if[Object]?checkCast(handle, value):value});
 501         }
 502 
 503         @ForceInline
 504         static $type$ getAndSet(FieldStaticReadWrite handle, $type$ value) {
 505             return UNSAFE.getAndSet$Type$(handle.base,
 506                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 507                                           {#if[Object]?checkCast(handle, value):value});
 508         }
 509 
 510         @ForceInline
 511         static $type$ getAndSetAcquire(FieldStaticReadWrite handle, $type$ value) {
 512             return UNSAFE.getAndSet$Type$Acquire(handle.base,
 513                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 514                                           {#if[Object]?checkCast(handle, value):value});
 515         }
 516 
 517         @ForceInline
 518         static $type$ getAndSetRelease(FieldStaticReadWrite handle, $type$ value) {
 519             return UNSAFE.getAndSet$Type$Release(handle.base,
 520                                           handle.fieldOffset{#if[Value]?, handle.fieldType},
 521                                           {#if[Object]?checkCast(handle, value):value});
 522         }
 523 #end[CAS]
 524 #if[AtomicAdd]
 525 
 526         @ForceInline
 527         static $type$ getAndAdd(FieldStaticReadWrite handle, $type$ value) {
 528             return UNSAFE.getAndAdd$Type$(handle.base,
 529                                        handle.fieldOffset,
 530                                        value);
 531         }
 532 
 533         @ForceInline
 534         static $type$ getAndAddAcquire(FieldStaticReadWrite handle, $type$ value) {
 535             return UNSAFE.getAndAdd$Type$Acquire(handle.base,
 536                                        handle.fieldOffset,
 537                                        value);
 538         }
 539 
 540         @ForceInline
 541         static $type$ getAndAddRelease(FieldStaticReadWrite handle, $type$ value) {


 596         }
 597 
 598         @ForceInline
 599         static $type$ getAndBitwiseXorRelease(FieldStaticReadWrite handle, $type$ value) {
 600             return UNSAFE.getAndBitwiseXor$Type$Release(handle.base,
 601                                        handle.fieldOffset,
 602                                        value);
 603         }
 604 
 605         @ForceInline
 606         static $type$ getAndBitwiseXorAcquire(FieldStaticReadWrite handle, $type$ value) {
 607             return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base,
 608                                        handle.fieldOffset,
 609                                        value);
 610         }
 611 #end[Bitwise]
 612 
 613         static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class);
 614     }
 615 
 616 #if[Reference]
 617     static VarHandle makeVarHandleValuesArray(Class<?> arrayClass) {
 618         Class<?> componentType = arrayClass.getComponentType();
 619         assert componentType.isInlineClass() && UNSAFE.isFlattenedArray(arrayClass);
 620         // should cache these VarHandle for performance
 621         return VarHandles.makeArrayElementHandle(arrayClass);
 622     }
 623 #end[Reference]
 624 
 625     static final class Array extends VarHandle {
 626         final int abase;
 627         final int ashift;
 628 #if[Object]
 629         final Class<{#if[Object]??:$type$[]}> arrayType;
 630         final Class<?> componentType;
 631 #end[Object]
 632 
 633         Array(int abase, int ashift{#if[Object]?, Class<?> arrayType}) {
 634             super(Array.FORM);
 635             this.abase = abase;
 636             this.ashift = ashift;
 637 #if[Object]
 638             this.arrayType = {#if[Object]?arrayType:$type$[].class};
 639             this.componentType = arrayType.getComponentType();
 640 #end[Object]
 641         }
 642 
 643         @Override
 644         public Optional<VarHandleDesc> describeConstable() {
 645             var arrayTypeRef = {#if[Object]?arrayType:$type$[].class}.describeConstable();
 646             if (!arrayTypeRef.isPresent())
 647                 return Optional.empty();
 648 
 649             return Optional.of(VarHandleDesc.ofArray(arrayTypeRef.get()));
 650         }
 651 
 652         @Override
 653         final MethodType accessModeTypeUncached(AccessMode accessMode) {
 654             return accessMode.at.accessModeType({#if[Object]?arrayType:$type$[].class}, {#if[Object]?arrayType.getComponentType():$type$.class}, int.class);
 655         }
 656 
 657 #if[Object]
 658         @ForceInline
 659         static Object runtimeTypeCheck(Array handle, Object[] oarray, Object value) {
 660             if (!handle.componentType.isNullableType())
 661                  Objects.requireNonNull(value);
 662 
 663             if (handle.arrayType == oarray.getClass()) {
 664                 // Fast path: static array type same as argument array type
 665                 return handle.componentType.cast(value);
 666             } else {
 667                 // Slow path: check value against argument array component type
 668                 return reflectiveTypeCheck(oarray, value);
 669             }
 670         }
 671 
 672         @ForceInline
 673         static Object reflectiveTypeCheck(Object[] oarray, Object value) {
 674             try {
 675                 return oarray.getClass().getComponentType().cast(value);
 676             } catch (ClassCastException e) {
 677                 throw new ArrayStoreException();
 678             }
 679         }
 680 #end[Object]
 681 
 682         @ForceInline
 683         static $type$ get(Array handle, Object oarray, int index) {
 684 #if[Object]
 685             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 686 #else[Object]
 687             $type$[] array = ($type$[]) oarray;
 688 #end[Object]
 689             return array[index];
 690         }
 691 
 692         @ForceInline
 693         static void set(Array handle, Object oarray, int index, $type$ value) {
 694 #if[Object]
 695             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 696 #else[Object]
 697             $type$[] array = ($type$[]) oarray;
 698 #end[Object]
 699 #if[Reference]
 700             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 701                 // for flattened array, delegate to VarHandle of the inline type array
 702                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 703                 vh.set(oarray, index, reflectiveTypeCheck(array, value));
 704                 return;
 705             }
 706 #end[Reference]
 707             array[index] = {#if[Object]?runtimeTypeCheck(handle, array, value):value};
 708         }
 709 
 710         @ForceInline
 711         static $type$ getVolatile(Array handle, Object oarray, int index) {
 712 #if[Object]
 713             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 714 #else[Object]
 715             $type$[] array = ($type$[]) oarray;
 716 #end[Object]
 717 #if[Reference]
 718             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 719                 // for flattened array, delegate to VarHandle of the inline type array
 720                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 721                 return vh.getVolatile(oarray, index);
 722             }
 723 #end[Reference]
 724             return UNSAFE.get$Type$Volatile(array,
 725                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType});
 726         }
 727 
 728         @ForceInline
 729         static void setVolatile(Array handle, Object oarray, int index, $type$ value) {
 730 #if[Object]
 731             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 732 #else[Object]
 733             $type$[] array = ($type$[]) oarray;
 734 #end[Object]
 735 #if[Reference]
 736             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 737                 // for flattened array, delegate to VarHandle of the inline type array
 738                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 739                 vh.setVolatile(oarray, index, reflectiveTypeCheck(array, value));
 740                 return;
 741             }
 742 #end[Reference]
 743             UNSAFE.put$Type$Volatile(array,
 744                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
 745                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 746         }
 747 
 748         @ForceInline
 749         static $type$ getOpaque(Array handle, Object oarray, int index) {
 750 #if[Object]
 751             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 752 #else[Object]
 753             $type$[] array = ($type$[]) oarray;
 754 #end[Object]
 755 #if[Reference]
 756             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 757                 // for flattened array, delegate to VarHandle of the inline type array
 758                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 759                 return vh.getOpaque(oarray, index);
 760             }
 761 #end[Reference]
 762             return UNSAFE.get$Type$Opaque(array,
 763                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType});
 764         }
 765 
 766         @ForceInline
 767         static void setOpaque(Array handle, Object oarray, int index, $type$ value) {
 768 #if[Object]
 769             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 770 #else[Object]
 771             $type$[] array = ($type$[]) oarray;
 772 #end[Object]
 773 #if[Reference]
 774             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 775                 // for flattened array, delegate to VarHandle of the inline type array
 776                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 777                 vh.setOpaque(oarray, index, reflectiveTypeCheck(array, value));
 778                 return;
 779             }
 780 #end[Reference]
 781             UNSAFE.put$Type$Opaque(array,
 782                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
 783                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 784         }
 785 
 786         @ForceInline
 787         static $type$ getAcquire(Array handle, Object oarray, int index) {
 788 #if[Object]
 789             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 790 #else[Object]
 791             $type$[] array = ($type$[]) oarray;
 792 #end[Object]
 793 #if[Reference]
 794             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 795                 // for flattened array, delegate to VarHandle of the inline type array
 796                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 797                 return vh.getAcquire(oarray, index);
 798             }
 799 #end[Reference]
 800             return UNSAFE.get$Type$Acquire(array,
 801                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType});
 802         }
 803 
 804         @ForceInline
 805         static void setRelease(Array handle, Object oarray, int index, $type$ value) {
 806 #if[Object]
 807             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 808 #else[Object]
 809             $type$[] array = ($type$[]) oarray;
 810 #end[Object]
 811 #if[Reference]
 812             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 813                 // for flattened array, delegate to VarHandle of the inline type array
 814                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 815                 vh.setRelease(oarray, index, reflectiveTypeCheck(array, value));
 816                 return;
 817             }
 818 #end[Reference]
 819             UNSAFE.put$Type$Release(array,
 820                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
 821                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 822         }
 823 #if[CAS]
 824 
 825         @ForceInline
 826         static boolean compareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 827 #if[Object]
 828             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 829 #else[Object]
 830             $type$[] array = ($type$[]) oarray;
 831 #end[Object]
 832 #if[Reference]
 833             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 834                 // for flattened array, delegate to VarHandle of the inline type array
 835                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 836                 return vh.compareAndSet(oarray, index, expected, reflectiveTypeCheck(array, value));
 837             }
 838 #end[Reference]
 839             return UNSAFE.compareAndSet$Type$(array,
 840                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 841                     {#if[Object]?handle.componentType.cast(expected):expected},
 842                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 843         }
 844 
 845         @ForceInline
 846         static $type$ compareAndExchange(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 847 #if[Object]
 848             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 849 #else[Object]
 850             $type$[] array = ($type$[]) oarray;
 851 #end[Object]
 852 #if[Reference]
 853             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 854                 // for flattened array, delegate to VarHandle of the inline type array
 855                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 856                 return vh.compareAndExchange(oarray, index, expected, reflectiveTypeCheck(array, value));
 857             }
 858 #end[Reference]
 859             return UNSAFE.compareAndExchange$Type$(array,
 860                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 861                     {#if[Object]?handle.componentType.cast(expected):expected},
 862                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 863         }
 864 
 865         @ForceInline
 866         static $type$ compareAndExchangeAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 867 #if[Object]
 868             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 869 #else[Object]
 870             $type$[] array = ($type$[]) oarray;
 871 #end[Object]
 872 #if[Reference]
 873             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 874                 // for flattened array, delegate to VarHandle of the inline type array
 875                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 876                 return vh.compareAndExchangeAcquire(oarray, index, expected, reflectiveTypeCheck(array, value));
 877             }
 878 #end[Reference]
 879             return UNSAFE.compareAndExchange$Type$Acquire(array,
 880                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 881                     {#if[Object]?handle.componentType.cast(expected):expected},
 882                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 883         }
 884 
 885         @ForceInline
 886         static $type$ compareAndExchangeRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 887 #if[Object]
 888             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 889 #else[Object]
 890             $type$[] array = ($type$[]) oarray;
 891 #end[Object]
 892 #if[Reference]
 893             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 894                 // for flattened array, delegate to VarHandle of the inline type array
 895                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 896                 return vh.compareAndExchangeRelease(oarray, index, expected, reflectiveTypeCheck(array, value));
 897             }
 898 #end[Reference]
 899             return UNSAFE.compareAndExchange$Type$Release(array,
 900                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 901                     {#if[Object]?handle.componentType.cast(expected):expected},
 902                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 903         }
 904 
 905         @ForceInline
 906         static boolean weakCompareAndSetPlain(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 907 #if[Object]
 908             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 909 #else[Object]
 910             $type$[] array = ($type$[]) oarray;
 911 #end[Object]
 912 #if[Reference]
 913             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 914                 // for flattened array, delegate to VarHandle of the inline type array
 915                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 916                 return vh.weakCompareAndSetPlain(oarray, index, expected, reflectiveTypeCheck(array, value));
 917             }
 918 #end[Reference]
 919             return UNSAFE.weakCompareAndSet$Type$Plain(array,
 920                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 921                     {#if[Object]?handle.componentType.cast(expected):expected},
 922                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 923         }
 924 
 925         @ForceInline
 926         static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 927 #if[Object]
 928             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 929 #else[Object]
 930             $type$[] array = ($type$[]) oarray;
 931 #end[Object]
 932 #if[Reference]
 933             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 934                 // for flattened array, delegate to VarHandle of the inline type array
 935                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 936                 return vh.weakCompareAndSet(oarray, index, expected, reflectiveTypeCheck(array, value));
 937             }
 938 #end[Reference]
 939             return UNSAFE.weakCompareAndSet$Type$(array,
 940                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 941                     {#if[Object]?handle.componentType.cast(expected):expected},
 942                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 943         }
 944 
 945         @ForceInline
 946         static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 947 #if[Object]
 948             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 949 #else[Object]
 950             $type$[] array = ($type$[]) oarray;
 951 #end[Object]
 952 #if[Reference]
 953             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 954                 // for flattened array, delegate to VarHandle of the inline type array
 955                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 956                 return vh.weakCompareAndSetAcquire(oarray, index, expected, reflectiveTypeCheck(array, value));
 957             }
 958 #end[Reference]
 959             return UNSAFE.weakCompareAndSet$Type$Acquire(array,
 960                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 961                     {#if[Object]?handle.componentType.cast(expected):expected},
 962                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 963         }
 964 
 965         @ForceInline
 966         static boolean weakCompareAndSetRelease(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
 967 #if[Object]
 968             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 969 #else[Object]
 970             $type$[] array = ($type$[]) oarray;
 971 #end[Object]
 972 #if[Reference]
 973             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 974                 // for flattened array, delegate to VarHandle of the inline type array
 975                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 976                 return vh.weakCompareAndSetRelease(oarray, index, expected, reflectiveTypeCheck(array, value));
 977             }
 978 #end[Reference]
 979             return UNSAFE.weakCompareAndSet$Type$Release(array,
 980                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Object]?, handle.componentType},
 981                     {#if[Object]?handle.componentType.cast(expected):expected},
 982                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
 983         }
 984 
 985         @ForceInline
 986         static $type$ getAndSet(Array handle, Object oarray, int index, $type$ value) {
 987 #if[Object]
 988             Object[] array = (Object[]) handle.arrayType.cast(oarray);
 989 #else[Object]
 990             $type$[] array = ($type$[]) oarray;
 991 #end[Object]
 992 #if[Reference]
 993             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
 994                 // for flattened array, delegate to VarHandle of the inline type array
 995                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
 996                 return vh.getAndSet(oarray, index, reflectiveTypeCheck(array, value));
 997             }
 998 #end[Reference]
 999             return UNSAFE.getAndSet$Type$(array,
1000                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
1001                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1002         }
1003 
1004         @ForceInline
1005         static $type$ getAndSetAcquire(Array handle, Object oarray, int index, $type$ value) {
1006 #if[Object]
1007             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1008 #else[Object]
1009             $type$[] array = ($type$[]) oarray;
1010 #end[Object]
1011 #if[Reference]
1012             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1013                 // for flattened array, delegate to VarHandle of the inline type array
1014                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1015                 return vh.getAndSetAcquire(oarray, index, reflectiveTypeCheck(array, value));
1016             }
1017 #end[Reference]
1018             return UNSAFE.getAndSet$Type$Acquire(array,
1019                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
1020                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1021         }
1022 
1023         @ForceInline
1024         static $type$ getAndSetRelease(Array handle, Object oarray, int index, $type$ value) {
1025 #if[Object]
1026             Object[] array = (Object[]) handle.arrayType.cast(oarray);
1027 #else[Object]
1028             $type$[] array = ($type$[]) oarray;
1029 #end[Object]
1030 #if[Reference]
1031             if (UNSAFE.isFlattenedArray(oarray.getClass())) {
1032                 // for flattened array, delegate to VarHandle of the inline type array
1033                 VarHandle vh = makeVarHandleValuesArray(oarray.getClass());
1034                 return vh.getAndSetRelease(oarray, index, reflectiveTypeCheck(array, value));
1035             }
1036 #end[Reference]
1037             return UNSAFE.getAndSet$Type$Release(array,
1038                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase{#if[Value]?, handle.componentType},
1039                     {#if[Object]?runtimeTypeCheck(handle, array, value):value});
1040         }
1041 #end[CAS]
1042 #if[AtomicAdd]
1043 
1044         @ForceInline
1045         static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) {
1046             $type$[] array = ($type$[]) oarray;
1047             return UNSAFE.getAndAdd$Type$(array,
1048                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
1049                     value);
1050         }
1051 
1052         @ForceInline
1053         static $type$ getAndAddAcquire(Array handle, Object oarray, int index, $type$ value) {
1054             $type$[] array = ($type$[]) oarray;
1055             return UNSAFE.getAndAdd$Type$Acquire(array,
1056                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
1057                     value);
1058         }


< prev index next >