jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java
changeset 38358 cb99c6d2af1b
parent 37719 add11bc0e6e2
parent 38357 f18eb84a3b96
child 38368 c8eb5d6812c5
equal deleted inserted replaced
38350:da6c6f544dfb 38358:cb99c6d2af1b
   712                     int x = (int) vh.get(array, i);
   712                     int x = (int) vh.get(array, i);
   713                     assertEquals(x, VALUE_1, "failing compareAndExchangeRelease int value");
   713                     assertEquals(x, VALUE_1, "failing compareAndExchangeRelease int value");
   714                 }
   714                 }
   715 
   715 
   716                 {
   716                 {
   717                     boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
   717                     boolean success = false;
   718                     assertEquals(r, true, "weakCompareAndSet int");
   718                     for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   719                         success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
       
   720                     }
       
   721                     assertEquals(success, true, "weakCompareAndSet int");
   719                     int x = (int) vh.get(array, i);
   722                     int x = (int) vh.get(array, i);
   720                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
   723                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
   721                 }
   724                 }
   722 
   725 
   723                 {
   726                 {
   724                     boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
   727                     boolean success = false;
   725                     assertEquals(r, true, "weakCompareAndSetAcquire int");
   728                     for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   729                         success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
       
   730                     }
       
   731                     assertEquals(success, true, "weakCompareAndSetAcquire int");
   726                     int x = (int) vh.get(array, i);
   732                     int x = (int) vh.get(array, i);
   727                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
   733                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
   728                 }
   734                 }
   729 
   735 
   730                 {
   736                 {
   731                     boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
   737                     boolean success = false;
   732                     assertEquals(r, true, "weakCompareAndSetRelease int");
   738                     for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   739                         success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
       
   740                     }
       
   741                     assertEquals(success, true, "weakCompareAndSetRelease int");
   733                     int x = (int) vh.get(array, i);
   742                     int x = (int) vh.get(array, i);
   734                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
   743                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
   735                 }
   744                 }
   736 
   745 
   737                 {
   746                 {
   861                     int x = (int) vh.get(array, i);
   870                     int x = (int) vh.get(array, i);
   862                     assertEquals(x, VALUE_1, "failing compareAndExchangeRelease int value");
   871                     assertEquals(x, VALUE_1, "failing compareAndExchangeRelease int value");
   863                 }
   872                 }
   864 
   873 
   865                 {
   874                 {
   866                     boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
   875                     boolean success = false;
   867                     assertEquals(r, true, "weakCompareAndSet int");
   876                     for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   877                         success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2);
       
   878                     }
       
   879                     assertEquals(success, true, "weakCompareAndSet int");
   868                     int x = (int) vh.get(array, i);
   880                     int x = (int) vh.get(array, i);
   869                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
   881                     assertEquals(x, VALUE_2, "weakCompareAndSet int value");
   870                 }
   882                 }
   871 
   883 
   872                 {
   884                 {
   873                     boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
   885                     boolean success = false;
   874                     assertEquals(r, true, "weakCompareAndSetAcquire int");
   886                     for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   887                         success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1);
       
   888                     }
       
   889                     assertEquals(success, true, "weakCompareAndSetAcquire int");
   875                     int x = (int) vh.get(array, i);
   890                     int x = (int) vh.get(array, i);
   876                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
   891                     assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int");
   877                 }
   892                 }
   878 
   893 
   879                 {
   894                 {
   880                     boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
   895                     boolean success = false;
   881                     assertEquals(r, true, "weakCompareAndSetRelease int");
   896                     for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
       
   897                         success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2);
       
   898                     }
       
   899                     assertEquals(success, true, "weakCompareAndSetRelease int");
   882                     int x = (int) vh.get(array, i);
   900                     int x = (int) vh.get(array, i);
   883                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
   901                     assertEquals(x, VALUE_2, "weakCompareAndSetRelease int");
   884                 }
   902                 }
   885 
   903 
   886                 {
   904                 {