jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
changeset 37719 add11bc0e6e2
parent 37345 9cb6e1141bdb
child 37792 dd626e6f5967
child 38358 cb99c6d2af1b
equal deleted inserted replaced
37718:79b158dae903 37719:add11bc0e6e2
   134  * the value of a variable under specified memory ordering effects.
   134  * the value of a variable under specified memory ordering effects.
   135  * The set of corresponding access mode methods belonging to this group
   135  * The set of corresponding access mode methods belonging to this group
   136  * consists of the methods
   136  * consists of the methods
   137  * {@link #compareAndSet compareAndSet},
   137  * {@link #compareAndSet compareAndSet},
   138  * {@link #weakCompareAndSet weakCompareAndSet},
   138  * {@link #weakCompareAndSet weakCompareAndSet},
       
   139  * {@link #weakCompareAndSetVolatile weakCompareAndSetVolatile},
   139  * {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire},
   140  * {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire},
   140  * {@link #weakCompareAndSetRelease weakCompareAndSetRelease},
   141  * {@link #weakCompareAndSetRelease weakCompareAndSetRelease},
   141  * {@link #compareAndExchangeAcquire compareAndExchangeAcquire},
   142  * {@link #compareAndExchangeAcquire compareAndExchangeAcquire},
   142  * {@link #compareAndExchangeVolatile compareAndExchangeVolatile},
   143  * {@link #compareAndExchangeVolatile compareAndExchangeVolatile},
   143  * {@link #compareAndExchangeRelease compareAndExchangeRelease},
   144  * {@link #compareAndExchangeRelease compareAndExchangeRelease},
   456      *
   457      *
   457      * <p>The method signature is of the form {@code (CT)T}.
   458      * <p>The method signature is of the form {@code (CT)T}.
   458      *
   459      *
   459      * <p>The symbolic type descriptor at the call site of {@code get}
   460      * <p>The symbolic type descriptor at the call site of {@code get}
   460      * must match the access mode type that is the result of calling
   461      * must match the access mode type that is the result of calling
   461      * {@code accessModeType(VarHandle.AccessMode.get)} on this VarHandle.
   462      * {@code accessModeType(VarHandle.AccessMode.GET)} on this VarHandle.
   462      *
   463      *
   463      * <p>This access mode is supported by all VarHandle instances and never
   464      * <p>This access mode is supported by all VarHandle instances and never
   464      * throws {@code UnsupportedOperationException}.
   465      * throws {@code UnsupportedOperationException}.
   465      *
   466      *
   466      * @param args the signature-polymorphic parameter list of the form
   467      * @param args the signature-polymorphic parameter list of the form
   486      *
   487      *
   487      * <p>The method signature is of the form {@code (CT, T newValue)void}
   488      * <p>The method signature is of the form {@code (CT, T newValue)void}
   488      *
   489      *
   489      * <p>The symbolic type descriptor at the call site of {@code set}
   490      * <p>The symbolic type descriptor at the call site of {@code set}
   490      * must match the access mode type that is the result of calling
   491      * must match the access mode type that is the result of calling
   491      * {@code accessModeType(VarHandle.AccessMode.set)} on this VarHandle.
   492      * {@code accessModeType(VarHandle.AccessMode.SET)} on this VarHandle.
   492      *
   493      *
   493      * @param args the signature-polymorphic parameter list of the form
   494      * @param args the signature-polymorphic parameter list of the form
   494      * {@code (CT, T newValue)}
   495      * {@code (CT, T newValue)}
   495      * , statically represented using varargs.
   496      * , statically represented using varargs.
   496      * @throws UnsupportedOperationException if the access mode is unsupported
   497      * @throws UnsupportedOperationException if the access mode is unsupported
   514      *
   515      *
   515      * <p>The method signature is of the form {@code (CT)T}.
   516      * <p>The method signature is of the form {@code (CT)T}.
   516      *
   517      *
   517      * <p>The symbolic type descriptor at the call site of {@code getVolatile}
   518      * <p>The symbolic type descriptor at the call site of {@code getVolatile}
   518      * must match the access mode type that is the result of calling
   519      * must match the access mode type that is the result of calling
   519      * {@code accessModeType(VarHandle.AccessMode.getVolatile)} on this VarHandle.
   520      * {@code accessModeType(VarHandle.AccessMode.GET_VOLATILE)} on this
       
   521      * VarHandle.
   520      *
   522      *
   521      * @param args the signature-polymorphic parameter list of the form
   523      * @param args the signature-polymorphic parameter list of the form
   522      * {@code (CT)}
   524      * {@code (CT)}
   523      * , statically represented using varargs.
   525      * , statically represented using varargs.
   524      * @return the signature-polymorphic result that is the value of the
   526      * @return the signature-polymorphic result that is the value of the
   542      *
   544      *
   543      * <p>The method signature is of the form {@code (CT, T newValue)void}.
   545      * <p>The method signature is of the form {@code (CT, T newValue)void}.
   544      *
   546      *
   545      * <p>The symbolic type descriptor at the call site of {@code setVolatile}
   547      * <p>The symbolic type descriptor at the call site of {@code setVolatile}
   546      * must match the access mode type that is the result of calling
   548      * must match the access mode type that is the result of calling
   547      * {@code accessModeType(VarHandle.AccessMode.setVolatile)} on this VarHandle.
   549      * {@code accessModeType(VarHandle.AccessMode.SET_VOLATILE)} on this
       
   550      * VarHandle.
   548      *
   551      *
   549      * @apiNote
   552      * @apiNote
   550      * Ignoring the many semantic differences from C and C++, this method has
   553      * Ignoring the many semantic differences from C and C++, this method has
   551      * memory ordering effects compatible with {@code memory_order_seq_cst}.
   554      * memory ordering effects compatible with {@code memory_order_seq_cst}.
   552      *
   555      *
   572      *
   575      *
   573      * <p>The method signature is of the form {@code (CT)T}.
   576      * <p>The method signature is of the form {@code (CT)T}.
   574      *
   577      *
   575      * <p>The symbolic type descriptor at the call site of {@code getOpaque}
   578      * <p>The symbolic type descriptor at the call site of {@code getOpaque}
   576      * must match the access mode type that is the result of calling
   579      * must match the access mode type that is the result of calling
   577      * {@code accessModeType(VarHandle.AccessMode.getOpaque)} on this VarHandle.
   580      * {@code accessModeType(VarHandle.AccessMode.GET_OPAQUE)} on this
       
   581      * VarHandle.
   578      *
   582      *
   579      * @param args the signature-polymorphic parameter list of the form
   583      * @param args the signature-polymorphic parameter list of the form
   580      * {@code (CT)}
   584      * {@code (CT)}
   581      * , statically represented using varargs.
   585      * , statically represented using varargs.
   582      * @return the signature-polymorphic result that is the value of the
   586      * @return the signature-polymorphic result that is the value of the
   601      *
   605      *
   602      * <p>The method signature is of the form {@code (CT, T newValue)void}.
   606      * <p>The method signature is of the form {@code (CT, T newValue)void}.
   603      *
   607      *
   604      * <p>The symbolic type descriptor at the call site of {@code setOpaque}
   608      * <p>The symbolic type descriptor at the call site of {@code setOpaque}
   605      * must match the access mode type that is the result of calling
   609      * must match the access mode type that is the result of calling
   606      * {@code accessModeType(VarHandle.AccessMode.setOpaque)} on this VarHandle.
   610      * {@code accessModeType(VarHandle.AccessMode.SET_OPAQUE)} on this
       
   611      * VarHandle.
   607      *
   612      *
   608      * @param args the signature-polymorphic parameter list of the form
   613      * @param args the signature-polymorphic parameter list of the form
   609      * {@code (CT, T newValue)}
   614      * {@code (CT, T newValue)}
   610      * , statically represented using varargs.
   615      * , statically represented using varargs.
   611      * @throws UnsupportedOperationException if the access mode is unsupported
   616      * @throws UnsupportedOperationException if the access mode is unsupported
   629      *
   634      *
   630      * <p>The method signature is of the form {@code (CT)T}.
   635      * <p>The method signature is of the form {@code (CT)T}.
   631      *
   636      *
   632      * <p>The symbolic type descriptor at the call site of {@code getAcquire}
   637      * <p>The symbolic type descriptor at the call site of {@code getAcquire}
   633      * must match the access mode type that is the result of calling
   638      * must match the access mode type that is the result of calling
   634      * {@code accessModeType(VarHandle.AccessMode.getAcquire)} on this VarHandle.
   639      * {@code accessModeType(VarHandle.AccessMode.GET_ACQUIRE)} on this
       
   640      * VarHandle.
   635      *
   641      *
   636      * @apiNote
   642      * @apiNote
   637      * Ignoring the many semantic differences from C and C++, this method has
   643      * Ignoring the many semantic differences from C and C++, this method has
   638      * memory ordering effects compatible with {@code memory_order_acquire}
   644      * memory ordering effects compatible with {@code memory_order_acquire}
   639      * ordering.
   645      * ordering.
   662      *
   668      *
   663      * <p>The method signature is of the form {@code (CT, T newValue)void}.
   669      * <p>The method signature is of the form {@code (CT, T newValue)void}.
   664      *
   670      *
   665      * <p>The symbolic type descriptor at the call site of {@code setRelease}
   671      * <p>The symbolic type descriptor at the call site of {@code setRelease}
   666      * must match the access mode type that is the result of calling
   672      * must match the access mode type that is the result of calling
   667      * {@code accessModeType(VarHandle.AccessMode.setRelease)} on this VarHandle.
   673      * {@code accessModeType(VarHandle.AccessMode.SET_RELEASE)} on this
       
   674      * VarHandle.
   668      *
   675      *
   669      * @apiNote
   676      * @apiNote
   670      * Ignoring the many semantic differences from C and C++, this method has
   677      * Ignoring the many semantic differences from C and C++, this method has
   671      * memory ordering effects compatible with {@code memory_order_release}
   678      * memory ordering effects compatible with {@code memory_order_release}
   672      * ordering.
   679      * ordering.
   698      *
   705      *
   699      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   706      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   700      *
   707      *
   701      * <p>The symbolic type descriptor at the call site of {@code
   708      * <p>The symbolic type descriptor at the call site of {@code
   702      * compareAndSet} must match the access mode type that is the result of
   709      * compareAndSet} must match the access mode type that is the result of
   703      * calling {@code accessModeType(VarHandle.AccessMode.compareAndSet)} on
   710      * calling {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_SET)} on
   704      * this VarHandle.
   711      * this VarHandle.
   705      *
   712      *
   706      * @param args the signature-polymorphic parameter list of the form
   713      * @param args the signature-polymorphic parameter list of the form
   707      * {@code (CT, T expectedValue, T newValue)}
   714      * {@code (CT, T expectedValue, T newValue)}
   708      * , statically represented using varargs.
   715      * , statically represented using varargs.
   732      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)T}.
   739      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)T}.
   733      *
   740      *
   734      * <p>The symbolic type descriptor at the call site of {@code
   741      * <p>The symbolic type descriptor at the call site of {@code
   735      * compareAndExchangeVolatile}
   742      * compareAndExchangeVolatile}
   736      * must match the access mode type that is the result of calling
   743      * must match the access mode type that is the result of calling
   737      * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeVolatile)}
   744      * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE)}
   738      * on this VarHandle.
   745      * on this VarHandle.
   739      *
   746      *
   740      * @param args the signature-polymorphic parameter list of the form
   747      * @param args the signature-polymorphic parameter list of the form
   741      * {@code (CT, T expectedValue, T newValue)}
   748      * {@code (CT, T expectedValue, T newValue)}
   742      * , statically represented using varargs.
   749      * , statically represented using varargs.
   767      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)T}.
   774      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)T}.
   768      *
   775      *
   769      * <p>The symbolic type descriptor at the call site of {@code
   776      * <p>The symbolic type descriptor at the call site of {@code
   770      * compareAndExchangeAcquire}
   777      * compareAndExchangeAcquire}
   771      * must match the access mode type that is the result of calling
   778      * must match the access mode type that is the result of calling
   772      * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeAcquire)} on
   779      * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)} on
   773      * this VarHandle.
   780      * this VarHandle.
   774      *
   781      *
   775      * @param args the signature-polymorphic parameter list of the form
   782      * @param args the signature-polymorphic parameter list of the form
   776      * {@code (CT, T expectedValue, T newValue)}
   783      * {@code (CT, T expectedValue, T newValue)}
   777      * , statically represented using varargs.
   784      * , statically represented using varargs.
   802      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)T}.
   809      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)T}.
   803      *
   810      *
   804      * <p>The symbolic type descriptor at the call site of {@code
   811      * <p>The symbolic type descriptor at the call site of {@code
   805      * compareAndExchangeRelease}
   812      * compareAndExchangeRelease}
   806      * must match the access mode type that is the result of calling
   813      * must match the access mode type that is the result of calling
   807      * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeRelease)} on this VarHandle.
   814      * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)}
       
   815      * on this VarHandle.
   808      *
   816      *
   809      * @param args the signature-polymorphic parameter list of the form
   817      * @param args the signature-polymorphic parameter list of the form
   810      * {@code (CT, T expectedValue, T newValue)}
   818      * {@code (CT, T expectedValue, T newValue)}
   811      * , statically represented using varargs.
   819      * , statically represented using varargs.
   812      * @return the signature-polymorphic result that is the witness value, which
   820      * @return the signature-polymorphic result that is the witness value, which
   834      * referred to as the <em>witness value</em>, {@code ==} the
   842      * referred to as the <em>witness value</em>, {@code ==} the
   835      * {@code expectedValue}, as accessed with the memory semantics of
   843      * {@code expectedValue}, as accessed with the memory semantics of
   836      * {@link #get}.
   844      * {@link #get}.
   837      *
   845      *
   838      * <p>This operation may fail spuriously (typically, due to memory
   846      * <p>This operation may fail spuriously (typically, due to memory
   839      * contention) even if the current value does match the expected value.
   847      * contention) even if the witness value does match the expected value.
   840      *
   848      *
   841      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   849      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   842      *
   850      *
   843      * <p>The symbolic type descriptor at the call site of {@code
   851      * <p>The symbolic type descriptor at the call site of {@code
   844      * weakCompareAndSet} must match the access mode type that is the result of
   852      * weakCompareAndSet} must match the access mode type that is the result of
   845      * calling {@code accessModeType(VarHandle.AccessMode.weakCompareAndSet)} on
   853      * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)}
   846      * this VarHandle.
   854      * on this VarHandle.
   847      *
   855      *
   848      * @param args the signature-polymorphic parameter list of the form
   856      * @param args the signature-polymorphic parameter list of the form
   849      * {@code (CT, T expectedValue, T newValue)}
   857      * {@code (CT, T expectedValue, T newValue)}
   850      * , statically represented using varargs.
   858      * , statically represented using varargs.
   851      * @return {@code true} if successful, otherwise {@code false} if the
   859      * @return {@code true} if successful, otherwise {@code false} if the
   862      */
   870      */
   863     public final native
   871     public final native
   864     @MethodHandle.PolymorphicSignature
   872     @MethodHandle.PolymorphicSignature
   865     @HotSpotIntrinsicCandidate
   873     @HotSpotIntrinsicCandidate
   866     boolean weakCompareAndSet(Object... args);
   874     boolean weakCompareAndSet(Object... args);
       
   875 
       
   876     /**
       
   877      * Possibly atomically sets the value of a variable to the {@code newValue}
       
   878      * with the memory semantics of {@link #setVolatile} if the variable's
       
   879      * current value, referred to as the <em>witness value</em>, {@code ==} the
       
   880      * {@code expectedValue}, as accessed with the memory semantics of
       
   881      * {@link #getVolatile}.
       
   882      *
       
   883      * <p>This operation may fail spuriously (typically, due to memory
       
   884      * contention) even if the witness value does match the expected value.
       
   885      *
       
   886      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
       
   887      *
       
   888      * <p>The symbolic type descriptor at the call site of {@code
       
   889      * weakCompareAndSetVolatile} must match the access mode type that is the
       
   890      * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)}
       
   891      * on this VarHandle.
       
   892      *
       
   893      * @param args the signature-polymorphic parameter list of the form
       
   894      * {@code (CT, T expectedValue, T newValue)}
       
   895      * , statically represented using varargs.
       
   896      * @return {@code true} if successful, otherwise {@code false} if the
       
   897      * witness value was not the same as the {@code expectedValue} or if this
       
   898      * operation spuriously failed.
       
   899      * @throws UnsupportedOperationException if the access mode is unsupported
       
   900      * for this VarHandle.
       
   901      * @throws WrongMethodTypeException if the access mode type is not
       
   902      * compatible with the caller's symbolic type descriptor.
       
   903      * @throws ClassCastException if the access mode type is compatible with the
       
   904      * caller's symbolic type descriptor, but a reference cast fails.
       
   905      * @see #setVolatile(Object...)
       
   906      * @see #getVolatile(Object...)
       
   907      */
       
   908     public final native
       
   909     @MethodHandle.PolymorphicSignature
       
   910     @HotSpotIntrinsicCandidate
       
   911     boolean weakCompareAndSetVolatile(Object... args);
   867 
   912 
   868     /**
   913     /**
   869      * Possibly atomically sets the value of a variable to the {@code newValue}
   914      * Possibly atomically sets the value of a variable to the {@code newValue}
   870      * with the semantics of {@link #set} if the variable's current value,
   915      * with the semantics of {@link #set} if the variable's current value,
   871      * referred to as the <em>witness value</em>, {@code ==} the
   916      * referred to as the <em>witness value</em>, {@code ==} the
   872      * {@code expectedValue}, as accessed with the memory semantics of
   917      * {@code expectedValue}, as accessed with the memory semantics of
   873      * {@link #getAcquire}.
   918      * {@link #getAcquire}.
   874      *
   919      *
   875      * <p>This operation may fail spuriously (typically, due to memory
   920      * <p>This operation may fail spuriously (typically, due to memory
   876      * contention) even if the current value does match the expected value.
   921      * contention) even if the witness value does match the expected value.
   877      *
   922      *
   878      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   923      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   879      *
   924      *
   880      * <p>The symbolic type descriptor at the call site of {@code
   925      * <p>The symbolic type descriptor at the call site of {@code
   881      * weakCompareAndSetAcquire}
   926      * weakCompareAndSetAcquire}
   882      * must match the access mode type that is the result of calling
   927      * must match the access mode type that is the result of calling
   883      * {@code accessModeType(VarHandle.AccessMode.weakCompareAndSetAcquire)} on this VarHandle.
   928      * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)}
       
   929      * on this VarHandle.
   884      *
   930      *
   885      * @param args the signature-polymorphic parameter list of the form
   931      * @param args the signature-polymorphic parameter list of the form
   886      * {@code (CT, T expectedValue, T newValue)}
   932      * {@code (CT, T expectedValue, T newValue)}
   887      * , statically represented using varargs.
   933      * , statically represented using varargs.
   888      * @return {@code true} if successful, otherwise {@code false} if the
   934      * @return {@code true} if successful, otherwise {@code false} if the
   908      * value, referred to as the <em>witness value</em>, {@code ==} the
   954      * value, referred to as the <em>witness value</em>, {@code ==} the
   909      * {@code expectedValue}, as accessed with the memory semantics of
   955      * {@code expectedValue}, as accessed with the memory semantics of
   910      * {@link #get}.
   956      * {@link #get}.
   911      *
   957      *
   912      * <p>This operation may fail spuriously (typically, due to memory
   958      * <p>This operation may fail spuriously (typically, due to memory
   913      * contention) even if the current value does match the expected value.
   959      * contention) even if the witness value does match the expected value.
   914      *
   960      *
   915      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   961      * <p>The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
   916      *
   962      *
   917      * <p>The symbolic type descriptor at the call site of {@code
   963      * <p>The symbolic type descriptor at the call site of {@code
   918      * weakCompareAndSetRelease}
   964      * weakCompareAndSetRelease}
   919      * must match the access mode type that is the result of calling
   965      * must match the access mode type that is the result of calling
   920      * {@code accessModeType(VarHandle.AccessMode.weakCompareAndSetRelease)} on this VarHandle.
   966      * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)}
       
   967      * on this VarHandle.
   921      *
   968      *
   922      * @param args the signature-polymorphic parameter list of the form
   969      * @param args the signature-polymorphic parameter list of the form
   923      * {@code (CT, T expectedValue, T newValue)}
   970      * {@code (CT, T expectedValue, T newValue)}
   924      * , statically represented using varargs.
   971      * , statically represented using varargs.
   925      * @return {@code true} if successful, otherwise {@code false} if the
   972      * @return {@code true} if successful, otherwise {@code false} if the
   947      *
   994      *
   948      * <p>The method signature is of the form {@code (CT, T newValue)T}.
   995      * <p>The method signature is of the form {@code (CT, T newValue)T}.
   949      *
   996      *
   950      * <p>The symbolic type descriptor at the call site of {@code getAndSet}
   997      * <p>The symbolic type descriptor at the call site of {@code getAndSet}
   951      * must match the access mode type that is the result of calling
   998      * must match the access mode type that is the result of calling
   952      * {@code accessModeType(VarHandle.AccessMode.getAndSet)} on this VarHandle.
   999      * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET)} on this
       
  1000      * VarHandle.
   953      *
  1001      *
   954      * @param args the signature-polymorphic parameter list of the form
  1002      * @param args the signature-polymorphic parameter list of the form
   955      * {@code (CT, T newValue)}
  1003      * {@code (CT, T newValue)}
   956      * , statically represented using varargs.
  1004      * , statically represented using varargs.
   957      * @return the signature-polymorphic result that is the previous value of
  1005      * @return the signature-polymorphic result that is the previous value of
   983      *
  1031      *
   984      * <p>The method signature is of the form {@code (CT, T value)T}.
  1032      * <p>The method signature is of the form {@code (CT, T value)T}.
   985      *
  1033      *
   986      * <p>The symbolic type descriptor at the call site of {@code getAndAdd}
  1034      * <p>The symbolic type descriptor at the call site of {@code getAndAdd}
   987      * must match the access mode type that is the result of calling
  1035      * must match the access mode type that is the result of calling
   988      * {@code accessModeType(VarHandle.AccessMode.getAndAdd)} on this VarHandle.
  1036      * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD)} on this
       
  1037      * VarHandle.
   989      *
  1038      *
   990      * @param args the signature-polymorphic parameter list of the form
  1039      * @param args the signature-polymorphic parameter list of the form
   991      * {@code (CT, T value)}
  1040      * {@code (CT, T value)}
   992      * , statically represented using varargs.
  1041      * , statically represented using varargs.
   993      * @return the signature-polymorphic result that is the previous value of
  1042      * @return the signature-polymorphic result that is the previous value of
  1015      *
  1064      *
  1016      * <p>The method signature is of the form {@code (CT, T value)T}.
  1065      * <p>The method signature is of the form {@code (CT, T value)T}.
  1017      *
  1066      *
  1018      * <p>The symbolic type descriptor at the call site of {@code addAndGet}
  1067      * <p>The symbolic type descriptor at the call site of {@code addAndGet}
  1019      * must match the access mode type that is the result of calling
  1068      * must match the access mode type that is the result of calling
  1020      * {@code accessModeType(VarHandle.AccessMode.addAndGet)} on this VarHandle.
  1069      * {@code accessModeType(VarHandle.AccessMode.ADD_AND_GET)} on this
       
  1070      * VarHandle.
  1021      *
  1071      *
  1022      * @param args the signature-polymorphic parameter list of the form
  1072      * @param args the signature-polymorphic parameter list of the form
  1023      * {@code (CT, T value)}
  1073      * {@code (CT, T value)}
  1024      * , statically represented using varargs.
  1074      * , statically represented using varargs.
  1025      * @return the signature-polymorphic result that is the current value of
  1075      * @return the signature-polymorphic result that is the current value of
  1081         /**
  1131         /**
  1082          * The access mode whose access is specified by the corresponding
  1132          * The access mode whose access is specified by the corresponding
  1083          * method
  1133          * method
  1084          * {@link VarHandle#get VarHandle.get}
  1134          * {@link VarHandle#get VarHandle.get}
  1085          */
  1135          */
  1086         GET("get", AccessType.GET, Object.class),   // 0
  1136         GET("get", AccessType.GET, Object.class),
  1087         /**
  1137         /**
  1088          * The access mode whose access is specified by the corresponding
  1138          * The access mode whose access is specified by the corresponding
  1089          * method
  1139          * method
  1090          * {@link VarHandle#set VarHandle.set}
  1140          * {@link VarHandle#set VarHandle.set}
  1091          */
  1141          */
  1092         SET("set", AccessType.SET, void.class),     // 1
  1142         SET("set", AccessType.SET, void.class),
  1093         /**
  1143         /**
  1094          * The access mode whose access is specified by the corresponding
  1144          * The access mode whose access is specified by the corresponding
  1095          * method
  1145          * method
  1096          * {@link VarHandle#getVolatile VarHandle.getVolatile}
  1146          * {@link VarHandle#getVolatile VarHandle.getVolatile}
  1097          */
  1147          */
  1098         GET_VOLATILE("getVolatile", AccessType.GET, Object.class),  // 2
  1148         GET_VOLATILE("getVolatile", AccessType.GET, Object.class),
  1099         /**
  1149         /**
  1100          * The access mode whose access is specified by the corresponding
  1150          * The access mode whose access is specified by the corresponding
  1101          * method
  1151          * method
  1102          * {@link VarHandle#setVolatile VarHandle.setVolatile}
  1152          * {@link VarHandle#setVolatile VarHandle.setVolatile}
  1103          */
  1153          */
  1104         SET_VOLATILE("setVolatile", AccessType.SET, void.class),    // 3
  1154         SET_VOLATILE("setVolatile", AccessType.SET, void.class),
  1105         /**
  1155         /**
  1106          * The access mode whose access is specified by the corresponding
  1156          * The access mode whose access is specified by the corresponding
  1107          * method
  1157          * method
  1108          * {@link VarHandle#getAcquire VarHandle.getAcquire}
  1158          * {@link VarHandle#getAcquire VarHandle.getAcquire}
  1109          */
  1159          */
  1110         GET_ACQUIRE("getAcquire", AccessType.GET, Object.class),   // 4
  1160         GET_ACQUIRE("getAcquire", AccessType.GET, Object.class),
  1111         /**
  1161         /**
  1112          * The access mode whose access is specified by the corresponding
  1162          * The access mode whose access is specified by the corresponding
  1113          * method
  1163          * method
  1114          * {@link VarHandle#setRelease VarHandle.setRelease}
  1164          * {@link VarHandle#setRelease VarHandle.setRelease}
  1115          */
  1165          */
  1116         SET_RELEASE("setRelease", AccessType.SET, void.class),     // 5
  1166         SET_RELEASE("setRelease", AccessType.SET, void.class),
  1117         /**
  1167         /**
  1118          * The access mode whose access is specified by the corresponding
  1168          * The access mode whose access is specified by the corresponding
  1119          * method
  1169          * method
  1120          * {@link VarHandle#getOpaque VarHandle.getOpaque}
  1170          * {@link VarHandle#getOpaque VarHandle.getOpaque}
  1121          */
  1171          */
  1122         GET_OPAQUE("getOpaque", AccessType.GET, Object.class),    // 6
  1172         GET_OPAQUE("getOpaque", AccessType.GET, Object.class),
  1123         /**
  1173         /**
  1124          * The access mode whose access is specified by the corresponding
  1174          * The access mode whose access is specified by the corresponding
  1125          * method
  1175          * method
  1126          * {@link VarHandle#setOpaque VarHandle.setOpaque}
  1176          * {@link VarHandle#setOpaque VarHandle.setOpaque}
  1127          */
  1177          */
  1128         SET_OPAQUE("setOpaque", AccessType.SET, void.class),      // 7
  1178         SET_OPAQUE("setOpaque", AccessType.SET, void.class),
  1129         /**
  1179         /**
  1130          * The access mode whose access is specified by the corresponding
  1180          * The access mode whose access is specified by the corresponding
  1131          * method
  1181          * method
  1132          * {@link VarHandle#compareAndSet VarHandle.compareAndSet}
  1182          * {@link VarHandle#compareAndSet VarHandle.compareAndSet}
  1133          */
  1183          */
  1134         COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),    // 8
  1184         COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),
  1135         /**
  1185         /**
  1136          * The access mode whose access is specified by the corresponding
  1186          * The access mode whose access is specified by the corresponding
  1137          * method
  1187          * method
  1138          * {@link VarHandle#compareAndExchangeVolatile VarHandle.compareAndExchangeVolatile}
  1188          * {@link VarHandle#compareAndExchangeVolatile VarHandle.compareAndExchangeVolatile}
  1139          */
  1189          */
  1140         COMPARE_AND_EXCHANGE_VOLATILE("compareAndExchangeVolatile", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 9
  1190         COMPARE_AND_EXCHANGE_VOLATILE("compareAndExchangeVolatile", AccessType.COMPARE_AND_EXCHANGE, Object.class),
  1141         /**
  1191         /**
  1142          * The access mode whose access is specified by the corresponding
  1192          * The access mode whose access is specified by the corresponding
  1143          * method
  1193          * method
  1144          * {@link VarHandle#compareAndExchangeAcquire VarHandle.compareAndExchangeAcquire}
  1194          * {@link VarHandle#compareAndExchangeAcquire VarHandle.compareAndExchangeAcquire}
  1145          */
  1195          */
  1146         COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE, Object.class),  // 10
  1196         COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE, Object.class),
  1147         /**
  1197         /**
  1148          * The access mode whose access is specified by the corresponding
  1198          * The access mode whose access is specified by the corresponding
  1149          * method
  1199          * method
  1150          * {@link VarHandle#compareAndExchangeRelease VarHandle.compareAndExchangeRelease}
  1200          * {@link VarHandle#compareAndExchangeRelease VarHandle.compareAndExchangeRelease}
  1151          */
  1201          */
  1152         COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE, Object.class),  // 11
  1202         COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE, Object.class),
  1153         /**
  1203         /**
  1154          * The access mode whose access is specified by the corresponding
  1204          * The access mode whose access is specified by the corresponding
  1155          * method
  1205          * method
  1156          * {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet}
  1206          * {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet}
  1157          */
  1207          */
  1158         WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),        // 12
  1208         WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),
       
  1209         /**
       
  1210          * The access mode whose access is specified by the corresponding
       
  1211          * method
       
  1212          * {@link VarHandle#weakCompareAndSetVolatile VarHandle.weakCompareAndSetVolatile}
       
  1213          */
       
  1214         WEAK_COMPARE_AND_SET_VOLATILE("weakCompareAndSetVolatile", AccessType.COMPARE_AND_SWAP, boolean.class),
  1159         /**
  1215         /**
  1160          * The access mode whose access is specified by the corresponding
  1216          * The access mode whose access is specified by the corresponding
  1161          * method
  1217          * method
  1162          * {@link VarHandle#weakCompareAndSetAcquire VarHandle.weakCompareAndSetAcquire}
  1218          * {@link VarHandle#weakCompareAndSetAcquire VarHandle.weakCompareAndSetAcquire}
  1163          */
  1219          */
  1164         WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SWAP, boolean.class), // 13
  1220         WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SWAP, boolean.class),
  1165         /**
  1221         /**
  1166          * The access mode whose access is specified by the corresponding
  1222          * The access mode whose access is specified by the corresponding
  1167          * method
  1223          * method
  1168          * {@link VarHandle#weakCompareAndSetRelease VarHandle.weakCompareAndSetRelease}
  1224          * {@link VarHandle#weakCompareAndSetRelease VarHandle.weakCompareAndSetRelease}
  1169          */
  1225          */
  1170         WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SWAP, boolean.class), // 14
  1226         WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SWAP, boolean.class),
  1171         /**
  1227         /**
  1172          * The access mode whose access is specified by the corresponding
  1228          * The access mode whose access is specified by the corresponding
  1173          * method
  1229          * method
  1174          * {@link VarHandle#getAndSet VarHandle.getAndSet}
  1230          * {@link VarHandle#getAndSet VarHandle.getAndSet}
  1175          */
  1231          */
  1176         GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE, Object.class),   // 15
  1232         GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE, Object.class),
  1177         /**
  1233         /**
  1178          * The access mode whose access is specified by the corresponding
  1234          * The access mode whose access is specified by the corresponding
  1179          * method
  1235          * method
  1180          * {@link VarHandle#getAndAdd VarHandle.getAndAdd}
  1236          * {@link VarHandle#getAndAdd VarHandle.getAndAdd}
  1181          */
  1237          */
  1182         GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE, Object.class),   // 16
  1238         GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE, Object.class),
  1183         /**
  1239         /**
  1184          * The access mode whose access is specified by the corresponding
  1240          * The access mode whose access is specified by the corresponding
  1185          * method
  1241          * method
  1186          * {@link VarHandle#addAndGet VarHandle.addAndGet}
  1242          * {@link VarHandle#addAndGet VarHandle.addAndGet}
  1187          */
  1243          */
  1188         ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE, Object.class),   // 17
  1244         ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE, Object.class),
  1189         ;
  1245         ;
  1190 
  1246 
  1191         static final Map<String, AccessMode> methodNameToAccessMode;
  1247         static final Map<String, AccessMode> methodNameToAccessMode;
  1192         static {
  1248         static {
  1193             // Initial capacity of # values is sufficient to avoid resizes
  1249             // Initial capacity of # values is sufficient to avoid resizes