< prev index next >

test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java

Print this page
rev 12711 : 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
Reviewed-by: psandoz, dholmes, thartmann
Contributed-by: ron.pressler@oracle.com, claes.redestad@oracle.com

*** 1,7 **** /* ! * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 196,231 **** UNSAFE.putChar(base, offset, '\u0123'); // Compare { ! boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u4567'); ! assertEquals(r, true, "success compareAndSwap char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "success compareAndSwap char value"); } { ! boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u89AB'); ! assertEquals(r, false, "failing compareAndSwap char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "failing compareAndSwap char value"); } // Advanced compare { ! char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u0123'); ! assertEquals(r, '\u4567', "success compareAndExchangeVolatile char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value"); } { ! char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u89AB'); ! assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value"); } { char r = UNSAFE.compareAndExchangeCharAcquire(base, offset, '\u0123', '\u4567'); assertEquals(r, '\u0123', "success compareAndExchangeAcquire char"); --- 196,231 ---- UNSAFE.putChar(base, offset, '\u0123'); // Compare { ! boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u4567'); ! assertEquals(r, true, "success compareAndSet char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "success compareAndSet char value"); } { ! boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u89AB'); ! assertEquals(r, false, "failing compareAndSet char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "failing compareAndSet char value"); } // Advanced compare { ! char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u0123'); ! assertEquals(r, '\u4567', "success compareAndExchange char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "success compareAndExchange char value"); } { ! char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u89AB'); ! assertEquals(r, '\u0123', "failing compareAndExchange char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "failing compareAndExchange char value"); } { char r = UNSAFE.compareAndExchangeCharAcquire(base, offset, '\u0123', '\u4567'); assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
*** 255,299 **** } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapChar(base, offset, '\u0123', '\u4567'); } ! assertEquals(success, true, "weakCompareAndSwap char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "weakCompareAndSwap char value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapCharAcquire(base, offset, '\u4567', '\u0123'); } ! assertEquals(success, true, "weakCompareAndSwapAcquire char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "weakCompareAndSwapAcquire char"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapCharRelease(base, offset, '\u0123', '\u4567'); } ! assertEquals(success, true, "weakCompareAndSwapRelease char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "weakCompareAndSwapRelease char"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSwapCharVolatile(base, offset, '\u4567', '\u0123'); } ! assertEquals(success, true, "weakCompareAndSwapVolatile char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "weakCompareAndSwapVolatile char"); } UNSAFE.putChar(base, offset, '\u4567'); // Compare set and get --- 255,299 ---- } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetCharPlain(base, offset, '\u0123', '\u4567'); } ! assertEquals(success, true, "weakCompareAndSetPlain char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetCharAcquire(base, offset, '\u4567', '\u0123'); } ! assertEquals(success, true, "weakCompareAndSetAcquire char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "weakCompareAndSetAcquire char"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetCharRelease(base, offset, '\u0123', '\u4567'); } ! assertEquals(success, true, "weakCompareAndSetRelease char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u4567', "weakCompareAndSetRelease char"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { ! success = UNSAFE.weakCompareAndSetChar(base, offset, '\u4567', '\u0123'); } ! assertEquals(success, true, "weakCompareAndSet char"); char x = UNSAFE.getChar(base, offset); ! assertEquals(x, '\u0123', "weakCompareAndSet char"); } UNSAFE.putChar(base, offset, '\u4567'); // Compare set and get
*** 322,327 **** char x = UNSAFE.getChar(address); assertEquals(x, '\u0123', "set char value"); } } } - --- 322,326 ----
< prev index next >