[atomicfu-JVM] Preparation for commonization of JVM and K/N transformers
The following updates in the JVM/IR plugin were made: * Lots of refactoring with preparation for K/N support: commonization of transformations. * Improved error handling (checks for visibility constraints, appending message about usage constraints in case of an error). * Explicit requirements for the visibility of atomic properties: to prevent leaking they should be private/internal or be members of private/internal classes. * Fixed visibility of generated properties: volatile properties are always private and atomic updaters have the same visibility as the original atomic property. * Volatile fields are generated from scratch and original atomic properties are removed. * Delegated properties support is fixed (only declaration in the same scope is allowed). * Non-inline atomic extensions are forbidden. * For top-level atomics: only one wrapper class per file (with corresponding visibility) is generated. * Bug fixes. The corresponding tickets: https://github.com/Kotlin/kotlinx-atomicfu/issues/322 KT-60528 Merge-request: KT-MR-10579 Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
This commit is contained in:
+130
@@ -0,0 +1,130 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class IntArithmetic {
|
||||
private val _x = atomic(0)
|
||||
val x get() = _x.value
|
||||
|
||||
private val local = atomic(0)
|
||||
|
||||
private fun testGetValue() {
|
||||
_x.value = 5
|
||||
assertEquals(5, _x.value)
|
||||
var aValue = _x.value
|
||||
assertEquals(5, aValue)
|
||||
assertEquals(5, x)
|
||||
|
||||
local.value = 555
|
||||
aValue = local.value
|
||||
assertEquals(aValue, local.value)
|
||||
}
|
||||
|
||||
private fun testAtomicCallPlaces() {
|
||||
_x.value = 5
|
||||
_x.compareAndSet(5, 42)
|
||||
val res = _x.compareAndSet(42, 45)
|
||||
assertTrue(res)
|
||||
assertTrue(_x.compareAndSet(45, 77))
|
||||
assertFalse(_x.compareAndSet(95, 77))
|
||||
assertTrue(_x.compareAndSet(77, 88))
|
||||
}
|
||||
|
||||
private fun testInt() {
|
||||
_x.value = 0
|
||||
assertEquals(0, x)
|
||||
val update = 3
|
||||
assertEquals(0, _x.getAndSet(update))
|
||||
assertTrue(_x.compareAndSet(update, 8))
|
||||
_x.lazySet(1)
|
||||
assertEquals(1, x)
|
||||
assertEquals(1, _x.getAndSet(2))
|
||||
assertEquals(2, x)
|
||||
assertEquals(2, _x.getAndIncrement())
|
||||
assertEquals(3, x)
|
||||
assertEquals(3, _x.getAndDecrement())
|
||||
assertEquals(2, x)
|
||||
assertEquals(2, _x.getAndAdd(2))
|
||||
assertEquals(4, x)
|
||||
assertEquals(7, _x.addAndGet(3))
|
||||
assertEquals(7, x)
|
||||
assertEquals(8, _x.incrementAndGet())
|
||||
assertEquals(8, x)
|
||||
assertEquals(7, _x.decrementAndGet())
|
||||
assertEquals(7, x)
|
||||
assertTrue(_x.compareAndSet(7, 10))
|
||||
}
|
||||
|
||||
fun test() {
|
||||
testGetValue()
|
||||
testAtomicCallPlaces()
|
||||
testInt()
|
||||
}
|
||||
}
|
||||
|
||||
class LongArithmetic {
|
||||
private val _x = atomic(4294967296)
|
||||
val x get() = _x.value
|
||||
private val y = atomic(5000000000)
|
||||
private val z = atomic(2424920024888888848)
|
||||
private val max = atomic(9223372036854775807)
|
||||
|
||||
fun testLong() {
|
||||
assertEquals(2424920024888888848, z.value)
|
||||
z.lazySet(8424920024888888848)
|
||||
assertEquals(8424920024888888848, z.value)
|
||||
assertEquals(8424920024888888848, z.getAndSet(8924920024888888848))
|
||||
assertEquals(8924920024888888848, z.value)
|
||||
assertEquals(8924920024888888849, z.incrementAndGet())
|
||||
assertEquals(8924920024888888849, z.value)
|
||||
assertEquals(8924920024888888849, z.getAndDecrement())
|
||||
assertEquals(8924920024888888848, z.value)
|
||||
assertEquals(8924920024888888848, z.getAndAdd(100000000000000000))
|
||||
assertEquals(9024920024888888848, z.value)
|
||||
assertEquals(-198452011965886959, z.addAndGet(-9223372036854775807))
|
||||
assertEquals(-198452011965886959, z.value)
|
||||
assertEquals(-198452011965886958, z.incrementAndGet())
|
||||
assertEquals(-198452011965886958, z.value)
|
||||
assertEquals(-198452011965886959, z.decrementAndGet())
|
||||
assertEquals(-198452011965886959, z.value)
|
||||
}
|
||||
}
|
||||
|
||||
class BooleanArithmetic {
|
||||
private val _x = atomic(false)
|
||||
val x get() = _x.value
|
||||
|
||||
fun testBoolean() {
|
||||
assertEquals(false, _x.value)
|
||||
assertFalse(x)
|
||||
_x.lazySet(true)
|
||||
assertTrue(x)
|
||||
assertTrue(_x.getAndSet(true))
|
||||
assertTrue(_x.compareAndSet(true, false))
|
||||
assertFalse(x)
|
||||
}
|
||||
}
|
||||
|
||||
class ReferenceArithmetic {
|
||||
private val _x = atomic<String?>(null)
|
||||
|
||||
fun testReference() {
|
||||
_x.value = "aaa"
|
||||
assertEquals("aaa", _x.value)
|
||||
_x.lazySet("bb")
|
||||
assertEquals("bb", _x.value)
|
||||
assertEquals("bb", _x.getAndSet("ccc"))
|
||||
assertEquals("ccc", _x.value)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val intClass = IntArithmetic()
|
||||
intClass.test()
|
||||
val longClass = LongArithmetic()
|
||||
longClass.testLong()
|
||||
val booleanClass = BooleanArithmetic()
|
||||
booleanClass.testBoolean()
|
||||
val refClass = ReferenceArithmetic()
|
||||
refClass.testReference()
|
||||
return "OK"
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
@kotlin.Metadata
|
||||
public final class ArithmeticTestKt {
|
||||
// source: 'ArithmeticTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class BooleanArithmetic {
|
||||
// source: 'ArithmeticTest.kt'
|
||||
private synthetic final static field _x$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field _x$volatile: int
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public final method getX(): boolean
|
||||
private synthetic final static method get_x$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method get_x$volatile(): int
|
||||
private synthetic final method set_x$volatile(p0: int): void
|
||||
public final method testBoolean(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class IntArithmetic {
|
||||
// source: 'ArithmeticTest.kt'
|
||||
private synthetic final static field _x$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field _x$volatile: int
|
||||
private synthetic final static field local$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field local$volatile: int
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private synthetic final static method getLocal$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getLocal$volatile(): int
|
||||
public final method getX(): int
|
||||
private synthetic final static method get_x$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method get_x$volatile(): int
|
||||
private synthetic final method setLocal$volatile(p0: int): void
|
||||
private synthetic final method set_x$volatile(p0: int): void
|
||||
public final method test(): void
|
||||
private final method testAtomicCallPlaces(): void
|
||||
private final method testGetValue(): void
|
||||
private final method testInt(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LongArithmetic {
|
||||
// source: 'ArithmeticTest.kt'
|
||||
private synthetic final static field _x$volatile$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic volatile field _x$volatile: long
|
||||
private synthetic final static field max$volatile$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic volatile field max$volatile: long
|
||||
private synthetic final static field y$volatile$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic volatile field y$volatile: long
|
||||
private synthetic final static field z$volatile$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic volatile field z$volatile: long
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private synthetic final static method getMax$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic final method getMax$volatile(): long
|
||||
public final method getX(): long
|
||||
private synthetic final static method getY$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic final method getY$volatile(): long
|
||||
private synthetic final static method getZ$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic final method getZ$volatile(): long
|
||||
private synthetic final static method get_x$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic final method get_x$volatile(): long
|
||||
private synthetic final method setMax$volatile(p0: long): void
|
||||
private synthetic final method setY$volatile(p0: long): void
|
||||
private synthetic final method setZ$volatile(p0: long): void
|
||||
private synthetic final method set_x$volatile(p0: long): void
|
||||
public final method testLong(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class ReferenceArithmetic {
|
||||
// source: 'ArithmeticTest.kt'
|
||||
private synthetic final static field _x$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field _x$volatile: java.lang.Object
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private synthetic final static method get_x$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method get_x$volatile(): java.lang.Object
|
||||
private synthetic final method set_x$volatile(p0: java.lang.Object): void
|
||||
public final method testReference(): void
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class AtomicArrayTest {
|
||||
|
||||
fun testIntArray() {
|
||||
val A = AtomicArrayClass()
|
||||
assertTrue(A.intArr[0].compareAndSet(0, 3))
|
||||
assertEquals(0, A.intArr[1].value)
|
||||
A.intArr[0].lazySet(5)
|
||||
assertEquals(5, A.intArr[0].value + A.intArr[1].value + A.intArr[2].value)
|
||||
assertTrue(A.intArr[0].compareAndSet(5, 10))
|
||||
assertEquals(10, A.intArr[0].getAndDecrement())
|
||||
assertEquals(9, A.intArr[0].value)
|
||||
A.intArr[2].value = 2
|
||||
assertEquals(2, A.intArr[2].value)
|
||||
assertTrue(A.intArr[2].compareAndSet(2, 34))
|
||||
assertEquals(34, A.intArr[2].value)
|
||||
}
|
||||
|
||||
fun testLongArray() {
|
||||
val A = AtomicArrayClass()
|
||||
A.longArr[0].value = 2424920024888888848
|
||||
assertEquals(2424920024888888848, A.longArr[0].value)
|
||||
A.longArr[0].lazySet(8424920024888888848)
|
||||
assertEquals(8424920024888888848, A.longArr[0].value)
|
||||
val ac = A.longArr[0].value
|
||||
A.longArr[3].value = ac
|
||||
assertEquals(8424920024888888848, A.longArr[3].getAndSet(8924920024888888848))
|
||||
assertEquals(8924920024888888848, A.longArr[3].value)
|
||||
val ac1 = A.longArr[3].value
|
||||
A.longArr[4].value = ac1
|
||||
assertEquals(8924920024888888849, A.longArr[4].incrementAndGet())
|
||||
assertEquals(8924920024888888849, A.longArr[4].value)
|
||||
assertEquals(8924920024888888849, A.longArr[4].getAndDecrement())
|
||||
assertEquals(8924920024888888848, A.longArr[4].value)
|
||||
A.longArr[4].value = 8924920024888888848
|
||||
assertEquals(8924920024888888848, A.longArr[4].getAndAdd(100000000000000000))
|
||||
val ac2 = A.longArr[4].value
|
||||
A.longArr[1].value = ac2
|
||||
assertEquals(9024920024888888848, A.longArr[1].value)
|
||||
assertEquals(-198452011965886959, A.longArr[1].addAndGet(-9223372036854775807))
|
||||
assertEquals(-198452011965886959, A.longArr[1].value)
|
||||
assertEquals(-198452011965886958, A.longArr[1].incrementAndGet())
|
||||
assertEquals(-198452011965886958, A.longArr[1].value)
|
||||
assertEquals(-198452011965886959, A.longArr[1].decrementAndGet())
|
||||
assertEquals(-198452011965886959, A.longArr[1].value)
|
||||
}
|
||||
|
||||
fun testBooleanArray() {
|
||||
val A = AtomicArrayClass()
|
||||
assertFalse(A.booleanArr[1].value)
|
||||
assertTrue(A.booleanArr[1].compareAndSet(false, true))
|
||||
A.booleanArr[0].lazySet(true)
|
||||
assertFalse(A.booleanArr[2].getAndSet(true))
|
||||
assertTrue(A.booleanArr[0].value && A.booleanArr[1].value && A.booleanArr[2].value)
|
||||
A.booleanArr[0].value = false
|
||||
assertFalse(A.booleanArr[0].value)
|
||||
}
|
||||
|
||||
fun testRefArray() {
|
||||
val A = AtomicArrayClass()
|
||||
val a2 = ARef(2)
|
||||
val a3 = ARef(3)
|
||||
A.refArr[0].value = a2
|
||||
assertEquals(2, A.refArr[0].value!!.n)
|
||||
assertTrue(A.refArr[0].compareAndSet(a2, a3))
|
||||
assertEquals(3, A.refArr[0].value!!.n)
|
||||
val r0 = A.refArr[0].value
|
||||
A.refArr[3].value = r0
|
||||
assertEquals(3, A.refArr[3].value!!.n)
|
||||
val a = A.a.value
|
||||
assertTrue(A.refArr[3].compareAndSet(a3, a))
|
||||
}
|
||||
|
||||
fun testAnyArray() {
|
||||
val A = AtomicArrayClass()
|
||||
val s1 = "aaa"
|
||||
val s2 = "bbb"
|
||||
A.anyArr[0].value = s1
|
||||
assertEquals("aaa", A.anyArr[0].value)
|
||||
assertTrue(A.anyArr[0].compareAndSet(s1, s2))
|
||||
assertEquals("bbb", A.anyArr[0].value)
|
||||
val r0 = A.anyArr[0].value
|
||||
A.anyArr[3].value = r0
|
||||
assertEquals("bbb", A.anyArr[3].value)
|
||||
}
|
||||
}
|
||||
|
||||
private class AtomicArrayClass {
|
||||
val intArr = AtomicIntArray(10)
|
||||
val longArr = AtomicLongArray(10)
|
||||
val booleanArr = AtomicBooleanArray(10)
|
||||
val refArr = atomicArrayOfNulls<ARef>(10)
|
||||
val anyArr = atomicArrayOfNulls<Any?>(10)
|
||||
internal val a = atomic(ARef(8))
|
||||
}
|
||||
|
||||
data class ARef(val n: Int)
|
||||
|
||||
fun box(): String {
|
||||
val testClass = AtomicArrayTest()
|
||||
testClass.testIntArray()
|
||||
testClass.testLongArray()
|
||||
testClass.testBooleanArray()
|
||||
testClass.testRefArray()
|
||||
testClass.testAnyArray()
|
||||
return "OK"
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
@kotlin.Metadata
|
||||
public final class ARef {
|
||||
// source: 'AtomicArrayTest.kt'
|
||||
private final field n: int
|
||||
public method <init>(p0: int): void
|
||||
public final method component1(): int
|
||||
public synthetic static method copy$default(p0: ARef, p1: int, p2: int, p3: java.lang.Object): ARef
|
||||
public final @org.jetbrains.annotations.NotNull method copy(p0: int): ARef
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public final method getN(): int
|
||||
public method hashCode(): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
final class AtomicArrayClass {
|
||||
// source: 'AtomicArrayTest.kt'
|
||||
private synthetic final static field a$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field a$volatile: java.lang.Object
|
||||
private synthetic final field anyArr: java.util.concurrent.atomic.AtomicReferenceArray
|
||||
private synthetic final field booleanArr: java.util.concurrent.atomic.AtomicIntegerArray
|
||||
private synthetic final field intArr: java.util.concurrent.atomic.AtomicIntegerArray
|
||||
private synthetic final field longArr: java.util.concurrent.atomic.AtomicLongArray
|
||||
private synthetic final field refArr: java.util.concurrent.atomic.AtomicReferenceArray
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public synthetic final static method access$getA$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final static method getA$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getA$volatile(): java.lang.Object
|
||||
public synthetic final method getAnyArr(): java.util.concurrent.atomic.AtomicReferenceArray
|
||||
public synthetic final method getBooleanArr(): java.util.concurrent.atomic.AtomicIntegerArray
|
||||
public synthetic final method getIntArr(): java.util.concurrent.atomic.AtomicIntegerArray
|
||||
public synthetic final method getLongArr(): java.util.concurrent.atomic.AtomicLongArray
|
||||
public synthetic final method getRefArr(): java.util.concurrent.atomic.AtomicReferenceArray
|
||||
private synthetic final method setA$volatile(p0: java.lang.Object): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class AtomicArrayTest {
|
||||
// source: 'AtomicArrayTest.kt'
|
||||
public method <init>(): void
|
||||
public final method testAnyArray(): void
|
||||
public final method testBooleanArray(): void
|
||||
public final method testIntArray(): void
|
||||
public final method testLongArray(): void
|
||||
public final method testRefArray(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class AtomicArrayTestKt {
|
||||
// source: 'AtomicArrayTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class IndexArrayElementGetterTest {
|
||||
private val clazz = AtomicArrayClass()
|
||||
|
||||
fun fib(a: Int): Int = if (a == 0 || a == 1) a else fib(a - 1) + fib(a - 2)
|
||||
|
||||
fun testIndexArrayElementGetting() {
|
||||
clazz.intArr[8].value = 3
|
||||
val i = fib(4)
|
||||
val j = fib(5)
|
||||
assertEquals(3, clazz.intArr[i + j].value)
|
||||
assertEquals(3, clazz.intArr[fib(4) + fib(5)].value)
|
||||
clazz.longArr[3].value = 100
|
||||
assertEquals(100, clazz.longArr[fib(6) - fib(5)].value)
|
||||
assertEquals(100, clazz.longArr[(fib(6) + fib(4)) % 8].value)
|
||||
assertEquals(100, clazz.longArr[(fib(6) + fib(4)) % 8].value)
|
||||
assertEquals(100, clazz.longArr[(fib(4) + fib(5)) % fib(5)].value)
|
||||
}
|
||||
|
||||
private class AtomicArrayClass {
|
||||
val intArr = AtomicIntArray(10)
|
||||
val longArr = AtomicLongArray(10)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = IndexArrayElementGetterTest()
|
||||
testClass.testIndexArrayElementGetting()
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
@kotlin.Metadata
|
||||
final class IndexArrayElementGetterTest$AtomicArrayClass {
|
||||
// source: 'IndexArrayElementGetterTest.kt'
|
||||
private synthetic final field intArr: java.util.concurrent.atomic.AtomicIntegerArray
|
||||
private synthetic final field longArr: java.util.concurrent.atomic.AtomicLongArray
|
||||
public method <init>(): void
|
||||
public synthetic final method getIntArr(): java.util.concurrent.atomic.AtomicIntegerArray
|
||||
public synthetic final method getLongArr(): java.util.concurrent.atomic.AtomicLongArray
|
||||
private final inner class IndexArrayElementGetterTest$AtomicArrayClass
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class IndexArrayElementGetterTest {
|
||||
// source: 'IndexArrayElementGetterTest.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field clazz: IndexArrayElementGetterTest$AtomicArrayClass
|
||||
public method <init>(): void
|
||||
public final method fib(p0: int): int
|
||||
public final method testIndexArrayElementGetting(): void
|
||||
private final inner class IndexArrayElementGetterTest$AtomicArrayClass
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class IndexArrayElementGetterTestKt {
|
||||
// source: 'IndexArrayElementGetterTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
private class AAA {
|
||||
private val _counter = atomic(5L)
|
||||
val counterValue: Long get() = _counter.value
|
||||
val delegateCounterValue by _counter
|
||||
val lateInitInt: AtomicInt
|
||||
val intArr: AtomicIntArray
|
||||
|
||||
// test ensures that transformation does not change the order of initialization
|
||||
init {
|
||||
lateInitInt = atomic(10)
|
||||
assertTrue(lateInitInt.compareAndSet(10, 100))
|
||||
assertEquals(100, lateInitInt.value)
|
||||
intArr = AtomicIntArray(10)
|
||||
intArr[0].value = 10
|
||||
assertTrue(intArr[0].compareAndSet(10, 100))
|
||||
intArr[1].value = 20
|
||||
}
|
||||
|
||||
init {
|
||||
assertEquals(5L, _counter.value)
|
||||
assertEquals(5L,counterValue)
|
||||
assertEquals(5L, delegateCounterValue)
|
||||
assertEquals(120, intArr[0].value + intArr[1].value)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val intClass = AAA()
|
||||
return "OK"
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
@kotlin.Metadata
|
||||
final class AAA {
|
||||
// source: 'InitializationOrderTest.kt'
|
||||
private synthetic final static field _counter$volatile$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic volatile field _counter$volatile: long
|
||||
private synthetic final field intArr: java.util.concurrent.atomic.AtomicIntegerArray
|
||||
private synthetic final static field lateInitInt$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field lateInitInt$volatile: int
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public final method getCounterValue(): long
|
||||
public final method getDelegateCounterValue(): long
|
||||
public synthetic final method getIntArr(): java.util.concurrent.atomic.AtomicIntegerArray
|
||||
private synthetic final static method getLateInitInt$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getLateInitInt$volatile(): int
|
||||
private synthetic final static method get_counter$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic final method get_counter$volatile(): long
|
||||
private synthetic final method setLateInitInt$volatile(p0: int): void
|
||||
private synthetic final method set_counter$volatile(p0: long): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class InitializationOrderTestKt {
|
||||
// source: 'InitializationOrderTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlinx.atomicfu.locks.*
|
||||
import kotlin.test.*
|
||||
|
||||
class LateinitPropertiesTest {
|
||||
private val a: AtomicInt
|
||||
private val head: AtomicRef<String>
|
||||
private val dataRef: AtomicRef<Data>
|
||||
private val lateIntArr: AtomicIntArray
|
||||
private val lateRefArr: AtomicArray<String?>
|
||||
|
||||
private class Data(val n: Int)
|
||||
|
||||
init {
|
||||
a = atomic(0)
|
||||
head = atomic("AAA")
|
||||
lateIntArr = AtomicIntArray(55)
|
||||
val data = Data(77)
|
||||
dataRef = atomic(data)
|
||||
val size = 10
|
||||
lateRefArr = atomicArrayOfNulls<String?>(size)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
assertEquals(0, a.value)
|
||||
assertTrue(head.compareAndSet("AAA", "BBB"))
|
||||
assertEquals("BBB", head.value)
|
||||
assertEquals(0, lateIntArr[35].value)
|
||||
assertEquals(77, dataRef.value.n)
|
||||
assertEquals(null, lateRefArr[5].value)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = LateinitPropertiesTest()
|
||||
testClass.test()
|
||||
return "OK"
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
@kotlin.Metadata
|
||||
final class LateinitPropertiesTest$Data {
|
||||
// source: 'LateinitPropertiesTest.kt'
|
||||
private final field n: int
|
||||
public method <init>(p0: int): void
|
||||
public final method getN(): int
|
||||
private final inner class LateinitPropertiesTest$Data
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LateinitPropertiesTest {
|
||||
// source: 'LateinitPropertiesTest.kt'
|
||||
private synthetic final static field a$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field a$volatile: int
|
||||
private synthetic final static field dataRef$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field dataRef$volatile: java.lang.Object
|
||||
private synthetic final static field head$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field head$volatile: java.lang.Object
|
||||
private synthetic final field lateIntArr: java.util.concurrent.atomic.AtomicIntegerArray
|
||||
private synthetic final field lateRefArr: java.util.concurrent.atomic.AtomicReferenceArray
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private synthetic final static method getA$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getA$volatile(): int
|
||||
private synthetic final static method getDataRef$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getDataRef$volatile(): java.lang.Object
|
||||
private synthetic final static method getHead$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getHead$volatile(): java.lang.Object
|
||||
private synthetic final method getLateIntArr(): java.util.concurrent.atomic.AtomicIntegerArray
|
||||
private synthetic final method getLateRefArr(): java.util.concurrent.atomic.AtomicReferenceArray
|
||||
private synthetic final method setA$volatile(p0: int): void
|
||||
private synthetic final method setDataRef$volatile(p0: java.lang.Object): void
|
||||
private synthetic final method setHead$volatile(p0: java.lang.Object): void
|
||||
public final method test(): void
|
||||
private final inner class LateinitPropertiesTest$Data
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LateinitPropertiesTestKt {
|
||||
// source: 'LateinitPropertiesTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class LockFreeLongCounterTest {
|
||||
private inline fun testWith(g: LockFreeLongCounter.() -> Long) {
|
||||
val c = LockFreeLongCounter()
|
||||
assertEquals(0L, c.g())
|
||||
assertEquals(1L, c.increment())
|
||||
assertEquals(1L, c.g())
|
||||
assertEquals(2L, c.increment())
|
||||
assertEquals(2L, c.g())
|
||||
}
|
||||
|
||||
fun testBasic() = testWith { get() }
|
||||
|
||||
fun testGetInner() = testWith { getInner() }
|
||||
|
||||
fun testAdd2() {
|
||||
val c = LockFreeLongCounter()
|
||||
c.add2()
|
||||
assertEquals(2L, c.get())
|
||||
c.add2()
|
||||
assertEquals(4L, c.get())
|
||||
}
|
||||
|
||||
fun testSetM2() {
|
||||
val c = LockFreeLongCounter()
|
||||
c.setM2()
|
||||
assertEquals(-2L, c.get())
|
||||
}
|
||||
}
|
||||
|
||||
class LockFreeLongCounter {
|
||||
private val counter = atomic(0L)
|
||||
|
||||
fun get(): Long = counter.value
|
||||
|
||||
fun increment(): Long = counter.incrementAndGet()
|
||||
|
||||
fun add2() = counter.getAndAdd(2)
|
||||
|
||||
fun setM2() {
|
||||
counter.value = -2L // LDC instruction here
|
||||
}
|
||||
|
||||
fun getInner(): Long = Inner().getFromOuter()
|
||||
|
||||
// testing how an inner class can get access to it
|
||||
private inner class Inner {
|
||||
fun getFromOuter(): Long = counter.value
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = LockFreeLongCounterTest()
|
||||
testClass.testBasic()
|
||||
testClass.testAdd2()
|
||||
testClass.testSetM2()
|
||||
testClass.testGetInner()
|
||||
return "OK"
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
@kotlin.Metadata
|
||||
final class LockFreeLongCounter$Inner {
|
||||
// source: 'LockFreeLongCounterTest.kt'
|
||||
synthetic final field this$0: LockFreeLongCounter
|
||||
public method <init>(p0: LockFreeLongCounter): void
|
||||
public final method getFromOuter(): long
|
||||
private final inner class LockFreeLongCounter$Inner
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeLongCounter {
|
||||
// source: 'LockFreeLongCounterTest.kt'
|
||||
private synthetic final static field counter$volatile$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic volatile field counter$volatile: long
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public synthetic final static method access$getCounter$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
public final method add2(): long
|
||||
public final method get(): long
|
||||
private synthetic final static method getCounter$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic final method getCounter$volatile(): long
|
||||
public final method getInner(): long
|
||||
public final method increment(): long
|
||||
private synthetic final method setCounter$volatile(p0: long): void
|
||||
public final method setM2(): void
|
||||
private final inner class LockFreeLongCounter$Inner
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeLongCounterTest {
|
||||
// source: 'LockFreeLongCounterTest.kt'
|
||||
public method <init>(): void
|
||||
public final method testAdd2(): void
|
||||
public final method testBasic(): void
|
||||
public final method testGetInner(): void
|
||||
public final method testSetM2(): void
|
||||
private final method testWith(p0: kotlin.jvm.functions.Function1): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeLongCounterTestKt {
|
||||
// source: 'LockFreeLongCounterTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class LockFreeQueueTest {
|
||||
fun testBasic() {
|
||||
val q = LockFreeQueue()
|
||||
assertEquals(-1, q.dequeue())
|
||||
q.enqueue(42)
|
||||
assertEquals(42, q.dequeue())
|
||||
assertEquals(-1, q.dequeue())
|
||||
q.enqueue(1)
|
||||
q.enqueue(2)
|
||||
assertEquals(1, q.dequeue())
|
||||
assertEquals(2, q.dequeue())
|
||||
assertEquals(-1, q.dequeue())
|
||||
}
|
||||
}
|
||||
|
||||
// MS-queue
|
||||
public class LockFreeQueue {
|
||||
private val head = atomic(Node(0))
|
||||
private val tail = atomic(head.value)
|
||||
|
||||
private class Node(val value: Int) {
|
||||
val next = atomic<Node?>(null)
|
||||
}
|
||||
|
||||
public fun enqueue(value: Int) {
|
||||
val node = Node(value)
|
||||
tail.loop { curTail ->
|
||||
val curNext = curTail.next.value
|
||||
if (curNext != null) {
|
||||
tail.compareAndSet(curTail, curNext)
|
||||
return@loop
|
||||
}
|
||||
if (curTail.next.compareAndSet(null, node)) {
|
||||
tail.compareAndSet(curTail, node)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public fun dequeue(): Int {
|
||||
head.loop { curHead ->
|
||||
val next = curHead.next.value ?: return -1
|
||||
if (head.compareAndSet(curHead, next)) return next.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = LockFreeQueueTest()
|
||||
testClass.testBasic()
|
||||
return "OK"
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
@kotlin.Metadata
|
||||
final class LockFreeQueue$Node {
|
||||
// source: 'LockFreeQueueTest.kt'
|
||||
private synthetic final static field next$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field next$volatile: java.lang.Object
|
||||
private final field value: int
|
||||
static method <clinit>(): void
|
||||
public method <init>(p0: int): void
|
||||
public synthetic final static method access$getNext$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final static method getNext$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getNext$volatile(): java.lang.Object
|
||||
public final method getValue(): int
|
||||
private synthetic final method setNext$volatile(p0: java.lang.Object): void
|
||||
private final inner class LockFreeQueue$Node
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeQueue {
|
||||
// source: 'LockFreeQueueTest.kt'
|
||||
private synthetic final static field head$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field head$volatile: java.lang.Object
|
||||
private synthetic final static field tail$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field tail$volatile: java.lang.Object
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public final method dequeue(): int
|
||||
public final method enqueue(p0: int): void
|
||||
private synthetic final static method getHead$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getHead$volatile(): java.lang.Object
|
||||
private synthetic final static method getTail$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getTail$volatile(): java.lang.Object
|
||||
private synthetic final method loop$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method setHead$volatile(p0: java.lang.Object): void
|
||||
private synthetic final method setTail$volatile(p0: java.lang.Object): void
|
||||
private final inner class LockFreeQueue$Node
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeQueueTest {
|
||||
// source: 'LockFreeQueueTest.kt'
|
||||
public method <init>(): void
|
||||
public final method testBasic(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeQueueTestKt {
|
||||
// source: 'LockFreeQueueTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class LockFreeStackTest {
|
||||
fun testClear() {
|
||||
val s = LockFreeStack<String>()
|
||||
assertTrue(s.isEmpty())
|
||||
s.pushLoop("A")
|
||||
assertTrue(!s.isEmpty())
|
||||
s.clear()
|
||||
assertTrue(s.isEmpty())
|
||||
}
|
||||
|
||||
fun testPushPopLoop() {
|
||||
val s = LockFreeStack<String>()
|
||||
assertTrue(s.isEmpty())
|
||||
s.pushLoop("A")
|
||||
assertTrue(!s.isEmpty())
|
||||
assertEquals("A", s.popLoop())
|
||||
assertTrue(s.isEmpty())
|
||||
}
|
||||
|
||||
fun testPushPopUpdate() {
|
||||
val s = LockFreeStack<String>()
|
||||
assertTrue(s.isEmpty())
|
||||
s.pushUpdate("A")
|
||||
assertTrue(!s.isEmpty())
|
||||
assertEquals("A", s.popUpdate())
|
||||
assertTrue(s.isEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
class LockFreeStack<T> {
|
||||
private val top = atomic<Node<T>?>(null)
|
||||
|
||||
private class Node<T>(val value: T, val next: Node<T>?)
|
||||
|
||||
fun isEmpty() = top.value == null
|
||||
|
||||
fun clear() { top.value = null }
|
||||
|
||||
fun pushLoop(value: T) {
|
||||
top.loop { cur ->
|
||||
val upd = Node(value, cur)
|
||||
if (top.compareAndSet(cur, upd)) return
|
||||
}
|
||||
}
|
||||
|
||||
fun popLoop(): T? {
|
||||
top.loop { cur ->
|
||||
if (cur == null) return null
|
||||
if (top.compareAndSet(cur, cur.next)) return cur.value
|
||||
}
|
||||
}
|
||||
|
||||
fun pushUpdate(value: T) {
|
||||
top.update { cur -> Node(value, cur) }
|
||||
}
|
||||
|
||||
fun popUpdate(): T? =
|
||||
top.getAndUpdate { cur -> cur?.next } ?.value
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = LockFreeStackTest()
|
||||
testClass.testClear()
|
||||
testClass.testPushPopLoop()
|
||||
testClass.testPushPopUpdate()
|
||||
return "OK"
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
@kotlin.Metadata
|
||||
final class LockFreeStack$Node {
|
||||
// source: 'LockFreeStackTest.kt'
|
||||
private final @org.jetbrains.annotations.Nullable field next: LockFreeStack$Node
|
||||
private final field value: java.lang.Object
|
||||
public method <init>(p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: LockFreeStack$Node): void
|
||||
public final @org.jetbrains.annotations.Nullable method getNext(): LockFreeStack$Node
|
||||
public final method getValue(): java.lang.Object
|
||||
private final inner class LockFreeStack$Node
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeStack {
|
||||
// source: 'LockFreeStackTest.kt'
|
||||
private synthetic final static field top$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field top$volatile: java.lang.Object
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public final method clear(): void
|
||||
private synthetic final method getAndUpdate$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): java.lang.Object
|
||||
private synthetic final static method getTop$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getTop$volatile(): java.lang.Object
|
||||
public final method isEmpty(): boolean
|
||||
private synthetic final method loop$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
public final @org.jetbrains.annotations.Nullable method popLoop(): java.lang.Object
|
||||
public final @org.jetbrains.annotations.Nullable method popUpdate(): java.lang.Object
|
||||
public final method pushLoop(p0: java.lang.Object): void
|
||||
public final method pushUpdate(p0: java.lang.Object): void
|
||||
private synthetic final method setTop$volatile(p0: java.lang.Object): void
|
||||
private synthetic final method update$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private final inner class LockFreeStack$Node
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeStackTest {
|
||||
// source: 'LockFreeStackTest.kt'
|
||||
public method <init>(): void
|
||||
public final method testClear(): void
|
||||
public final method testPushPopLoop(): void
|
||||
public final method testPushPopUpdate(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LockFreeStackTestKt {
|
||||
// source: 'LockFreeStackTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class LoopTest {
|
||||
private val a = atomic(0)
|
||||
private val a1 = atomic(1)
|
||||
private val b = atomic(true)
|
||||
private val l = atomic(5000000000)
|
||||
private val r = atomic<A>(A("aaaa"))
|
||||
private val rs = atomic<String>("bbbb")
|
||||
|
||||
class A(val s: String)
|
||||
|
||||
fun atomicfuIntLoopTest() {
|
||||
a.loop { value ->
|
||||
if (a.compareAndSet(value, 777)) {
|
||||
assertEquals(777, a.value)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun atomicfuBooleanLoopTest() {
|
||||
b.loop { value ->
|
||||
assertTrue(value)
|
||||
if (!b.value) return
|
||||
if (b.compareAndSet(value, false)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun atomicfuLongLoopTest() {
|
||||
l.loop { cur ->
|
||||
if (l.compareAndSet(5000000003, 9000000000)) {
|
||||
return
|
||||
} else {
|
||||
l.incrementAndGet()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun atomicfuRefLoopTest() {
|
||||
r.loop { cur ->
|
||||
assertEquals("aaaa", cur.s)
|
||||
if (r.compareAndSet(cur, A("bbbb"))) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun atomicfuLoopTest() {
|
||||
atomicfuIntLoopTest()
|
||||
assertEquals(777, a.value)
|
||||
atomicfuBooleanLoopTest()
|
||||
assertFalse(b.value)
|
||||
atomicfuLongLoopTest()
|
||||
assertEquals(9000000000, l.value)
|
||||
atomicfuRefLoopTest()
|
||||
assertEquals("bbbb", r.value.s)
|
||||
}
|
||||
|
||||
fun atomicfuUpdateTest() {
|
||||
a.value = 0
|
||||
a.update { value ->
|
||||
val newValue = value + 1000
|
||||
if (newValue >= 0) Int.MAX_VALUE else newValue
|
||||
}
|
||||
assertEquals(Int.MAX_VALUE, a.value)
|
||||
b.update { true }
|
||||
assertEquals(true, b.value)
|
||||
assertTrue(b.value)
|
||||
l.value = 0L
|
||||
l.update { cur ->
|
||||
val newValue = cur + 1000
|
||||
if (newValue >= 0L) Long.MAX_VALUE else newValue
|
||||
}
|
||||
assertEquals(Long.MAX_VALUE, l.value)
|
||||
r.lazySet(A("aaaa"))
|
||||
r.update { cur ->
|
||||
A("cccc${cur.s}")
|
||||
}
|
||||
assertEquals("ccccaaaa", r.value.s)
|
||||
}
|
||||
|
||||
fun atomicfuUpdateAndGetTest() {
|
||||
val res1 = a.updateAndGet { value ->
|
||||
if (value >= 0) Int.MAX_VALUE else value
|
||||
}
|
||||
assertEquals(Int.MAX_VALUE, res1)
|
||||
assertTrue(b.updateAndGet { true })
|
||||
val res2 = l.updateAndGet { cur ->
|
||||
if (cur >= 0L) Long.MAX_VALUE else cur
|
||||
}
|
||||
assertEquals(Long.MAX_VALUE, res2)
|
||||
r.lazySet(A("aaaa"))
|
||||
val res3 = r.updateAndGet { cur ->
|
||||
A("cccc${cur.s}")
|
||||
}
|
||||
assertEquals("ccccaaaa", res3.s)
|
||||
}
|
||||
|
||||
fun atomicfuGetAndUpdateTest() {
|
||||
a.getAndUpdate { value ->
|
||||
if (value >= 0) Int.MAX_VALUE else value
|
||||
}
|
||||
assertEquals(Int.MAX_VALUE, a.value)
|
||||
b.getAndUpdate { true }
|
||||
assertTrue(b.value)
|
||||
l.getAndUpdate { cur ->
|
||||
if (cur >= 0L) Long.MAX_VALUE else cur
|
||||
}
|
||||
assertEquals(Long.MAX_VALUE, l.value)
|
||||
r.lazySet(A("aaaa"))
|
||||
r.getAndUpdate { cur ->
|
||||
A("cccc${cur.s}")
|
||||
}
|
||||
assertEquals("ccccaaaa", r.value.s)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = LoopTest()
|
||||
testClass.atomicfuLoopTest()
|
||||
testClass.atomicfuUpdateTest()
|
||||
testClass.atomicfuUpdateAndGetTest()
|
||||
testClass.atomicfuGetAndUpdateTest()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
@kotlin.Metadata
|
||||
public final class LoopTest$A {
|
||||
// source: 'LoopTest.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field s: java.lang.String
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String
|
||||
public final inner class LoopTest$A
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LoopTest {
|
||||
// source: 'LoopTest.kt'
|
||||
private synthetic final static field a$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field a$volatile: int
|
||||
private synthetic final static field a1$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field a1$volatile: int
|
||||
private synthetic final static field b$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field b$volatile: int
|
||||
private synthetic final static field l$volatile$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic volatile field l$volatile: long
|
||||
private synthetic final static field r$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field r$volatile: java.lang.Object
|
||||
private synthetic final static field rs$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field rs$volatile: java.lang.Object
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public final method atomicfuBooleanLoopTest(): void
|
||||
public final method atomicfuGetAndUpdateTest(): void
|
||||
public final method atomicfuIntLoopTest(): void
|
||||
public final method atomicfuLongLoopTest(): void
|
||||
public final method atomicfuLoopTest(): void
|
||||
public final method atomicfuRefLoopTest(): void
|
||||
public final method atomicfuUpdateAndGetTest(): void
|
||||
public final method atomicfuUpdateTest(): void
|
||||
private synthetic final static method getA$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getA$volatile(): int
|
||||
private synthetic final static method getA1$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getA1$volatile(): int
|
||||
private synthetic final method getAndUpdate$atomicfu(p0: java.util.concurrent.atomic.AtomicIntegerFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): int
|
||||
private synthetic final method getAndUpdate$atomicfu(p0: java.util.concurrent.atomic.AtomicLongFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): long
|
||||
private synthetic final method getAndUpdate$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): java.lang.Object
|
||||
private synthetic final static method getB$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getB$volatile(): int
|
||||
private synthetic final static method getL$volatile$FU(): java.util.concurrent.atomic.AtomicLongFieldUpdater
|
||||
private synthetic final method getL$volatile(): long
|
||||
private synthetic final static method getR$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getR$volatile(): java.lang.Object
|
||||
private synthetic final static method getRs$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getRs$volatile(): java.lang.Object
|
||||
private synthetic final method loop$atomicfu(p0: java.util.concurrent.atomic.AtomicIntegerFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method loop$atomicfu(p0: java.util.concurrent.atomic.AtomicLongFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method loop$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method setA$volatile(p0: int): void
|
||||
private synthetic final method setA1$volatile(p0: int): void
|
||||
private synthetic final method setB$volatile(p0: int): void
|
||||
private synthetic final method setL$volatile(p0: long): void
|
||||
private synthetic final method setR$volatile(p0: java.lang.Object): void
|
||||
private synthetic final method setRs$volatile(p0: java.lang.Object): void
|
||||
private synthetic final method update$atomicfu(p0: java.util.concurrent.atomic.AtomicIntegerFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method update$atomicfu(p0: java.util.concurrent.atomic.AtomicLongFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method update$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method updateAndGet$atomicfu(p0: java.util.concurrent.atomic.AtomicIntegerFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): int
|
||||
private synthetic final method updateAndGet$atomicfu(p0: java.util.concurrent.atomic.AtomicLongFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): long
|
||||
private synthetic final method updateAndGet$atomicfu(p0: java.util.concurrent.atomic.AtomicReferenceFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): java.lang.Object
|
||||
public final inner class LoopTest$A
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class LoopTestKt {
|
||||
// source: 'LoopTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class MultiInitTest {
|
||||
fun testBasic() {
|
||||
val t = MultiInit()
|
||||
check(t.incA() == 1)
|
||||
check(t.incA() == 2)
|
||||
check(t.incB() == 1)
|
||||
check(t.incB() == 2)
|
||||
}
|
||||
}
|
||||
|
||||
class MultiInit {
|
||||
private val a = atomic(0)
|
||||
private val b = atomic(0)
|
||||
|
||||
fun incA() = a.incrementAndGet()
|
||||
fun incB() = b.incrementAndGet()
|
||||
|
||||
companion object {
|
||||
fun foo() {} // just to force some clinit in outer file
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = MultiInitTest()
|
||||
testClass.testBasic()
|
||||
return "OK"
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
@kotlin.Metadata
|
||||
public final class MultiInit$Companion {
|
||||
// source: 'MultiInitTest.kt'
|
||||
private method <init>(): void
|
||||
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public final method foo(): void
|
||||
public final inner class MultiInit$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MultiInit {
|
||||
// source: 'MultiInitTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: MultiInit$Companion
|
||||
private synthetic final static field a$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field a$volatile: int
|
||||
private synthetic final static field b$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field b$volatile: int
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private synthetic final static method getA$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getA$volatile(): int
|
||||
private synthetic final static method getB$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method getB$volatile(): int
|
||||
public final method incA(): int
|
||||
public final method incB(): int
|
||||
private synthetic final method setA$volatile(p0: int): void
|
||||
private synthetic final method setB$volatile(p0: int): void
|
||||
public final inner class MultiInit$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MultiInitTest {
|
||||
// source: 'MultiInitTest.kt'
|
||||
public method <init>(): void
|
||||
public final method testBasic(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MultiInitTestKt {
|
||||
// source: 'MultiInitTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class AA(val value: Int) {
|
||||
val b = B(value + 1)
|
||||
val c = C(D(E(value + 1)))
|
||||
|
||||
fun updateToB(affected: Any): Boolean {
|
||||
(affected as AtomicState).state.compareAndSet(this, b)
|
||||
return (affected.state.value is B && (affected.state.value as B).value == value + 1)
|
||||
}
|
||||
|
||||
fun manyProperties(affected: Any): Boolean {
|
||||
(affected as AtomicState).state.compareAndSet(this, c.d.e)
|
||||
return (affected.state.value is E && (affected.state.value as E).x == value + 1)
|
||||
}
|
||||
}
|
||||
|
||||
class B (val value: Int)
|
||||
|
||||
class C (val d: D)
|
||||
class D (val e: E)
|
||||
class E (val x: Int)
|
||||
|
||||
|
||||
private class AtomicState(value: Any) {
|
||||
val state = atomic<Any?>(value)
|
||||
}
|
||||
|
||||
class ScopeTest {
|
||||
fun scopeTest() {
|
||||
val a = AA(0)
|
||||
val affected: Any = AtomicState(a)
|
||||
check(a.updateToB(affected))
|
||||
val a1 = AA(0)
|
||||
val affected1: Any = AtomicState(a1)
|
||||
check(a1.manyProperties(affected1))
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = ScopeTest()
|
||||
testClass.scopeTest()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
@kotlin.Metadata
|
||||
public final class AA {
|
||||
// source: 'ScopeTest.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field b: B
|
||||
private final @org.jetbrains.annotations.NotNull field c: C
|
||||
private final field value: int
|
||||
public method <init>(p0: int): void
|
||||
public final @org.jetbrains.annotations.NotNull method getB(): B
|
||||
public final @org.jetbrains.annotations.NotNull method getC(): C
|
||||
public final method getValue(): int
|
||||
public final method manyProperties(@org.jetbrains.annotations.NotNull p0: java.lang.Object): boolean
|
||||
public final method updateToB(@org.jetbrains.annotations.NotNull p0: java.lang.Object): boolean
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
final class AtomicState {
|
||||
// source: 'ScopeTest.kt'
|
||||
private synthetic final static field state$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field state$volatile: java.lang.Object
|
||||
static method <clinit>(): void
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void
|
||||
public synthetic final static method access$getState$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final static method getState$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getState$volatile(): java.lang.Object
|
||||
private synthetic final method setState$volatile(p0: java.lang.Object): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class B {
|
||||
// source: 'ScopeTest.kt'
|
||||
private final field value: int
|
||||
public method <init>(p0: int): void
|
||||
public final method getValue(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class C {
|
||||
// source: 'ScopeTest.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field d: D
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: D): void
|
||||
public final @org.jetbrains.annotations.NotNull method getD(): D
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class D {
|
||||
// source: 'ScopeTest.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field e: E
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: E): void
|
||||
public final @org.jetbrains.annotations.NotNull method getE(): E
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class E {
|
||||
// source: 'ScopeTest.kt'
|
||||
private final field x: int
|
||||
public method <init>(p0: int): void
|
||||
public final method getX(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class ScopeTest {
|
||||
// source: 'ScopeTest.kt'
|
||||
public method <init>(): void
|
||||
public final method scopeTest(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class ScopeTestKt {
|
||||
// source: 'ScopeTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class SimpleLockTest {
|
||||
fun withLock() {
|
||||
val lock = SimpleLock()
|
||||
val result = lock.withLock {
|
||||
"OK"
|
||||
}
|
||||
assertEquals("OK", result)
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleLock {
|
||||
private val _locked = atomic(0)
|
||||
|
||||
fun <T> withLock(block: () -> T): T {
|
||||
// this contrieves construct triggers Kotlin compiler to reuse local variable slot #2 for
|
||||
// the exception in `finally` clause
|
||||
try {
|
||||
_locked.loop { locked ->
|
||||
check(locked == 0)
|
||||
if (!_locked.compareAndSet(0, 1)) return@loop // continue
|
||||
return block()
|
||||
}
|
||||
} finally {
|
||||
_locked.value = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = SimpleLockTest()
|
||||
testClass.withLock()
|
||||
return "OK"
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
@kotlin.Metadata
|
||||
public final class SimpleLock {
|
||||
// source: 'SimpleLockTest.kt'
|
||||
private synthetic final static field _locked$volatile$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic volatile field _locked$volatile: int
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private synthetic final static method get_locked$volatile$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater
|
||||
private synthetic final method get_locked$volatile(): int
|
||||
private synthetic final method loop$atomicfu(p0: java.util.concurrent.atomic.AtomicIntegerFieldUpdater, p1: kotlin.jvm.functions.Function1, p2: java.lang.Object): void
|
||||
private synthetic final method set_locked$volatile(p0: int): void
|
||||
public final method withLock(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
final class SimpleLockTest$withLock$result$1 {
|
||||
// source: 'SimpleLockTest.kt'
|
||||
enclosing method SimpleLockTest.withLock()V
|
||||
public final static field INSTANCE: SimpleLockTest$withLock$result$1
|
||||
inner (anonymous) class SimpleLockTest$withLock$result$1
|
||||
static method <clinit>(): void
|
||||
method <init>(): void
|
||||
public synthetic bridge method invoke(): java.lang.Object
|
||||
public final @org.jetbrains.annotations.NotNull method invoke(): java.lang.String
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class SimpleLockTest {
|
||||
// source: 'SimpleLockTest.kt'
|
||||
inner (anonymous) class SimpleLockTest$withLock$result$1
|
||||
public method <init>(): void
|
||||
public final method withLock(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class SimpleLockTestKt {
|
||||
// source: 'SimpleLockTest.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
private val topLevelS = atomic<Any>(arrayOf("A", "B"))
|
||||
|
||||
class UncheckedCastTest {
|
||||
private val s = atomic<Any>("AAA")
|
||||
private val bs = atomic<Any?>(null)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun testAtomicValUncheckedCast() {
|
||||
assertEquals((s as AtomicRef<String>).value, "AAA")
|
||||
bs.lazySet(arrayOf(arrayOf(Box(1), Box(2))))
|
||||
assertEquals((bs as AtomicRef<Array<Array<Box>>>).value[0]!![0].b * 10, 10)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun testTopLevelValUnchekedCast() {
|
||||
assertEquals((topLevelS as AtomicRef<Array<String>>).value[1], "B")
|
||||
}
|
||||
|
||||
private data class Box(val b: Int)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "UNCHECKED_CAST")
|
||||
private inline fun <T> AtomicRef<T>.getString(): String =
|
||||
(this as AtomicRef<String>).value
|
||||
|
||||
fun testInlineFunc() {
|
||||
assertEquals("AAA", s.getString())
|
||||
}
|
||||
|
||||
private val a = atomicArrayOfNulls<Any?>(10)
|
||||
|
||||
fun testArrayValueUncheckedCast() {
|
||||
a[0].value = "OK"
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
assertEquals("OK", (a[0] as AtomicRef<String>).value)
|
||||
}
|
||||
|
||||
fun testArrayValueUncheckedCastInlineFunc() {
|
||||
a[0].value = "OK"
|
||||
assertEquals("OK", a[0].getString())
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = UncheckedCastTest()
|
||||
testClass.testAtomicValUncheckedCast()
|
||||
testClass.testTopLevelValUnchekedCast()
|
||||
testClass.testArrayValueUncheckedCast()
|
||||
testClass.testArrayValueUncheckedCastInlineFunc()
|
||||
testClass.testInlineFunc()
|
||||
return "OK"
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
@kotlin.Metadata
|
||||
final class UncheckedCastTest$Box {
|
||||
// source: 'UncheckedCastTest.kt'
|
||||
private final field b: int
|
||||
public method <init>(p0: int): void
|
||||
public final method component1(): int
|
||||
public synthetic static method copy$default(p0: UncheckedCastTest$Box, p1: int, p2: int, p3: java.lang.Object): UncheckedCastTest$Box
|
||||
public final @org.jetbrains.annotations.NotNull method copy(p0: int): UncheckedCastTest$Box
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public final method getB(): int
|
||||
public method hashCode(): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
private final inner class UncheckedCastTest$Box
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
synthetic final class UncheckedCastTest$VolatileWrapper$atomicfu$private {
|
||||
// source: 'UncheckedCastTest.kt'
|
||||
private synthetic final static field topLevelS$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field topLevelS$volatile: java.lang.Object
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public synthetic final static method access$getTopLevelS$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final static method getTopLevelS$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getTopLevelS$volatile(): java.lang.Object
|
||||
private synthetic final method setTopLevelS$volatile(p0: java.lang.Object): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class UncheckedCastTest {
|
||||
// source: 'UncheckedCastTest.kt'
|
||||
private synthetic final field a: java.util.concurrent.atomic.AtomicReferenceArray
|
||||
private synthetic final static field bs$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field bs$volatile: java.lang.Object
|
||||
private synthetic final static field s$volatile$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic volatile field s$volatile: java.lang.Object
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private synthetic final method getA(): java.util.concurrent.atomic.AtomicReferenceArray
|
||||
private synthetic final static method getBs$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getBs$volatile(): java.lang.Object
|
||||
private synthetic final static method getS$volatile$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater
|
||||
private synthetic final method getS$volatile(): java.lang.Object
|
||||
private synthetic final method getString$atomicfu$array(p0: java.lang.Object, p1: java.util.concurrent.atomic.AtomicReferenceArray, p2: int): java.lang.String
|
||||
private synthetic final method getString$atomicfu(p0: java.lang.Object, p1: java.util.concurrent.atomic.AtomicReferenceFieldUpdater): java.lang.String
|
||||
private synthetic final method setBs$volatile(p0: java.lang.Object): void
|
||||
private synthetic final method setS$volatile(p0: java.lang.Object): void
|
||||
public final method testArrayValueUncheckedCast(): void
|
||||
public final method testArrayValueUncheckedCastInlineFunc(): void
|
||||
public final method testAtomicValUncheckedCast(): void
|
||||
public final method testInlineFunc(): void
|
||||
public final method testTopLevelValUnchekedCast(): void
|
||||
private final inner class UncheckedCastTest$Box
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class UncheckedCastTestKt {
|
||||
// source: 'UncheckedCastTest.kt'
|
||||
private synthetic final static field uncheckedCastTest$VolatileWrapper$atomicfu$private: UncheckedCastTest$VolatileWrapper$atomicfu$private
|
||||
static method <clinit>(): void
|
||||
public synthetic final static method access$getUncheckedCastTest$VolatileWrapper$atomicfu$private(): UncheckedCastTest$VolatileWrapper$atomicfu$private
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
private synthetic final static method getUncheckedCastTest$VolatileWrapper$atomicfu$private(): UncheckedCastTest$VolatileWrapper$atomicfu$private
|
||||
}
|
||||
Reference in New Issue
Block a user