jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template
changeset 38355 674cfd9b90cf
parent 37343 35a2231828a7
child 38358 cb99c6d2af1b
equal deleted inserted replaced
38354:d72736f07dba 38355:674cfd9b90cf
   207             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   207             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   208             assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
   208             assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
   209         }
   209         }
   210 
   210 
   211         {
   211         {
   212             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
   212             boolean success = false;
   213             assertEquals(r, true, "weakCompareAndSet $type$");
   213             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   214                 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$);
       
   215             }
       
   216             assertEquals(success, true, "weakCompareAndSet $type$");
   214             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   217             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   215             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
   218             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
   216         }
   219         }
   217 
   220 
   218         {
   221         {
   219             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$);
   222             boolean success = false;
   220             assertEquals(r, true, "weakCompareAndSetAcquire $type$");
   223             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   224                 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$);
       
   225             }
       
   226             assertEquals(success, true, "weakCompareAndSetAcquire $type$");
   221             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   227             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   222             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   228             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   223         }
   229         }
   224 
   230 
   225         {
   231         {
   226             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$);
   232             boolean success = false;
   227             assertEquals(r, true, "weakCompareAndSetRelease $type$");
   233             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   234                 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$);
       
   235             }
       
   236             assertEquals(success, true, "weakCompareAndSetRelease $type$");
   228             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   237             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   229             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   238             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   230         }
   239         }
   231 
   240 
   232         // Compare set and get
   241         // Compare set and get
   371             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   380             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   372             assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
   381             assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
   373         }
   382         }
   374 
   383 
   375         {
   384         {
   376             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$);
   385             boolean success = false;
   377             assertEquals(r, true, "weakCompareAndSet $type$");
   386             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   387                 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$);
       
   388             }
       
   389             assertEquals(success, true, "weakCompareAndSet $type$");
   378             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   390             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   379             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
   391             assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
   380         }
   392         }
   381 
   393 
   382         {
   394         {
   383             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$);
   395             boolean success = false;
   384             assertEquals(r, true, "weakCompareAndSetAcquire $type$");
   396             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   397                 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$);
       
   398             }
       
   399             assertEquals(success, true, "weakCompareAndSetAcquire $type$");
   385             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   400             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   386             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   401             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   387         }
   402         }
   388 
   403 
   389         {
   404         {
   390             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( $value1$, $value2$);
   405             boolean success = false;
   391             assertEquals(r, true, "weakCompareAndSetRelease $type$");
   406             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   407                 success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$);
       
   408             }
       
   409             assertEquals(success, true, "weakCompareAndSetRelease $type$");
   392             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   410             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   393             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   411             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   394         }
   412         }
   395 
   413 
   396         // Compare set and get
   414         // Compare set and get
   538                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   556                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   539                 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
   557                 assertEquals(x, $value1$, "failing compareAndExchangeRelease $type$ value");
   540             }
   558             }
   541 
   559 
   542             {
   560             {
   543                 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
   561                 boolean success = false;
   544                 assertEquals(r, true, "weakCompareAndSet $type$");
   562                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   563                     success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$);
       
   564                 }
       
   565                 assertEquals(success, true, "weakCompareAndSet $type$");
   545                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   566                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   546                 assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
   567                 assertEquals(x, $value2$, "weakCompareAndSet $type$ value");
   547             }
   568             }
   548 
   569 
   549             {
   570             {
   550                 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$);
   571                 boolean success = false;
   551                 assertEquals(r, true, "weakCompareAndSetAcquire $type$");
   572                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   573                     success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$);
       
   574                 }
       
   575                 assertEquals(success, true, "weakCompareAndSetAcquire $type$");
   552                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   576                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   553                 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   577                 assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   554             }
   578             }
   555 
   579 
   556             {
   580             {
   557                 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$);
   581                 boolean success = false;
   558                 assertEquals(r, true, "weakCompareAndSetRelease $type$");
   582                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   583                     success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$);
       
   584                 }
       
   585                 assertEquals(success, true, "weakCompareAndSetRelease $type$");
   559                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   586                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   560                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   587                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   561             }
   588             }
   562 
   589 
   563             // Compare set and get
   590             // Compare set and get