Files
kotlin-fork/compiler/testData/codegen/box/objects/kt42758.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

23 lines
603 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// FULL_JDK
// WITH_STDLIB
import java.io.*
object Thing : Serializable {
private fun readResolve(): Any = Thing
}
private inline fun <reified T : Serializable> roundTrip(value: T): T {
val outputStream = ByteArrayOutputStream()
ObjectOutputStream(outputStream).use { it.writeObject(value) }
val inputStream = ByteArrayInputStream(outputStream.toByteArray())
return ObjectInputStream(inputStream).use { it.readObject() } as T
}
fun box(): String {
if (Thing !== roundTrip(Thing))
throw Exception("Thing !== roundTrip(Thing)")
return "OK"
}