Introduce experimental kotlin.concurrent.Volatile annotation KT-55268, KT-55609

Use this annotation in tests to ensure it works the same at least on JVM
This commit is contained in:
Ilya Gorbunov
2022-12-21 22:43:20 +01:00
parent 58d6d7b9ad
commit e2d96da396
10 changed files with 176 additions and 9 deletions
@@ -1,5 +1,8 @@
// TARGET_BACKEND: JVM
// due to KT-55615
// IGNORE_BACKEND_K2: JVM_IR
// WITH_STDLIB
// FULL_JDK
@@ -12,6 +15,8 @@ class CustomDelegate {
class C {
@Volatile var vol = 1
@OptIn(ExperimentalStdlibApi::class)
@kotlin.concurrent.Volatile var vol2 = 1
@Transient val tra = 1
@delegate:Transient val del: String by CustomDelegate()
@@ -38,6 +43,7 @@ fun box(): String {
val c = C::class.java
if (c.getDeclaredField("vol").getModifiers() and Modifier.VOLATILE == 0) return "Fail: volatile"
if (c.getDeclaredField("vol2").getModifiers() and Modifier.VOLATILE == 0) return "Fail: volatile from kotlin.concurrent"
if (c.getDeclaredField("tra").getModifiers() and Modifier.TRANSIENT == 0) return "Fail: transient"
if (c.getDeclaredField("del\$delegate").getModifiers() and Modifier.TRANSIENT == 0) return "Fail: delegate transient"
@@ -1,10 +1,13 @@
@Volatile var vol = 1
@OptIn(ExperimentalStdlibApi::class)
@kotlin.concurrent.Volatile var vol2 = 1
@Transient val tra = 1
@Strictfp fun str() {}
@Synchronized fun sync() {}
// 0 kotlin/jvm/Volatile
// 0 kotlin/concurrent/Volatile
// 0 kotlin/jvm/Transient
// 0 kotlin/jvm/Strictfp
// 0 kotlin/jvm/Synchronized