jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template
changeset 37719 add11bc0e6e2
parent 37343 35a2231828a7
child 38328 40435a469d25
child 38358 cb99c6d2af1b
equal deleted inserted replaced
37718:79b158dae903 37719:add11bc0e6e2
   227             assertEquals(r, true, "weakCompareAndSetRelease $type$");
   227             assertEquals(r, true, "weakCompareAndSetRelease $type$");
   228             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   228             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   229             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   229             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   230         }
   230         }
   231 
   231 
       
   232         {
       
   233             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$);
       
   234             assertEquals(r, true, "weakCompareAndSetVolatile $type$");
       
   235             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
       
   236             assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
       
   237         }
       
   238 
   232         // Compare set and get
   239         // Compare set and get
   233         {
   240         {
   234             $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value1$);
   241             $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value2$);
   235             assertEquals(o, $value2$, "getAndSet $type$");
   242             assertEquals(o, $value1$, "getAndSet $type$");
   236             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   243             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
   237             assertEquals(x, $value1$, "getAndSet $type$ value");
   244             assertEquals(x, $value2$, "getAndSet $type$ value");
   238         }
   245         }
   239 #end[CAS]
   246 #end[CAS]
   240 
   247 
   241 #if[AtomicAdd]
   248 #if[AtomicAdd]
   242         hs.get(TestAccessMode.SET).invokeExact(recv, $value1$);
   249         hs.get(TestAccessMode.SET).invokeExact(recv, $value1$);
   385             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   392             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   386             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   393             assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
   387         }
   394         }
   388 
   395 
   389         {
   396         {
   390             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( $value1$, $value2$);
   397             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$);
   391             assertEquals(r, true, "weakCompareAndSetRelease $type$");
   398             assertEquals(r, true, "weakCompareAndSetRelease $type$");
   392             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   399             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   393             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   400             assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   394         }
   401         }
   395 
   402 
       
   403         {
       
   404             boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$);
       
   405             assertEquals(r, true, "weakCompareAndSetVolatile $type$");
       
   406             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
       
   407             assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
       
   408         }
       
   409 
   396         // Compare set and get
   410         // Compare set and get
   397         {
   411         {
   398             $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value1$);
   412             $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact($value2$);
   399             assertEquals(o, $value2$, "getAndSet $type$");
   413             assertEquals(o, $value1$, "getAndSet $type$");
   400             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   414             $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact();
   401             assertEquals(x, $value1$, "getAndSet $type$ value");
   415             assertEquals(x, $value2$, "getAndSet $type$ value");
   402         }
   416         }
   403 #end[CAS]
   417 #end[CAS]
   404 
   418 
   405 #if[AtomicAdd]
   419 #if[AtomicAdd]
   406         hs.get(TestAccessMode.SET).invokeExact($value1$);
   420         hs.get(TestAccessMode.SET).invokeExact($value1$);
   558                 assertEquals(r, true, "weakCompareAndSetRelease $type$");
   572                 assertEquals(r, true, "weakCompareAndSetRelease $type$");
   559                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   573                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   560                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   574                 assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
   561             }
   575             }
   562 
   576 
       
   577             {
       
   578                 boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$);
       
   579                 assertEquals(r, true, "weakCompareAndSetVolatile $type$");
       
   580                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
       
   581                 assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value");
       
   582             }
       
   583 
   563             // Compare set and get
   584             // Compare set and get
   564             {
   585             {
   565                 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value1$);
   586                 $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value2$);
   566                 assertEquals(o, $value2$, "getAndSet $type$");
   587                 assertEquals(o, $value1$, "getAndSet $type$");
   567                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   588                 $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i);
   568                 assertEquals(x, $value1$, "getAndSet $type$ value");
   589                 assertEquals(x, $value2$, "getAndSet $type$ value");
   569             }
   590             }
   570 #end[CAS]
   591 #end[CAS]
   571 
   592 
   572 #if[AtomicAdd]
   593 #if[AtomicAdd]
   573             hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$);
   594             hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$);