JVM_IR additional tests for indy lambda serialization
This commit is contained in:
committed by
teamcityserver
parent
6e9cbf52b1
commit
b03c9b6fc6
compiler/testData/codegen/box/invokedynamic/serializable/sameInterfaceDifferentCapturedValueTypes.kt
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FULL_JDK
|
||||
|
||||
// CHECK_BYTECODE_TEXT
|
||||
// JVM_IR_TEMPLATES
|
||||
// 4 java/lang/invoke/LambdaMetafactory
|
||||
|
||||
// FILE: sameInterfaceDifferentCapturedValueTypes.kt
|
||||
import java.io.*
|
||||
|
||||
fun box(): String {
|
||||
val vks = "K"
|
||||
val vkc = 'K'
|
||||
|
||||
val t1 = roundtrip(Sam { s -> s + vks }).get("O")
|
||||
if (t1 != "OK") return "Failed: t1='$t1'"
|
||||
|
||||
val t2 = roundtrip(Sam { s -> s + vkc }).get("O")
|
||||
if (t2 != "OK") return "Failed: t2='$t2'"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun <T> roundtrip(x: T): T {
|
||||
val out1 = ByteArrayOutputStream()
|
||||
ObjectOutputStream(out1).writeObject(x)
|
||||
return ObjectInputStream(ByteArrayInputStream(out1.toByteArray())).readObject() as T
|
||||
}
|
||||
|
||||
// FILE: Sam.java
|
||||
import java.io.*;
|
||||
|
||||
public interface Sam extends Serializable {
|
||||
String get(String s);
|
||||
}
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FULL_JDK
|
||||
|
||||
// CHECK_BYTECODE_TEXT
|
||||
// JVM_IR_TEMPLATES
|
||||
// 4 java/lang/invoke/LambdaMetafactory
|
||||
|
||||
// FILE: sameInterfaceDifferentCapturedValues.kt
|
||||
import java.io.*
|
||||
|
||||
fun box(): String {
|
||||
val vo = "O"
|
||||
val vk = "K"
|
||||
|
||||
val t1 = roundtrip(Sam { s -> s + vk }).get("O")
|
||||
if (t1 != "OK") return "Failed: t1='$t1'"
|
||||
|
||||
val t2 = roundtrip(Sam { s -> vo + s + vk }).get("")
|
||||
if (t2 != "OK") return "Failed: t2='$t2'"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun <T> roundtrip(x: T): T {
|
||||
val out1 = ByteArrayOutputStream()
|
||||
ObjectOutputStream(out1).writeObject(x)
|
||||
return ObjectInputStream(ByteArrayInputStream(out1.toByteArray())).readObject() as T
|
||||
}
|
||||
|
||||
// FILE: Sam.java
|
||||
import java.io.*;
|
||||
|
||||
public interface Sam extends Serializable {
|
||||
String get(String s);
|
||||
}
|
||||
Vendored
+14
-4
@@ -5,7 +5,7 @@
|
||||
|
||||
// CHECK_BYTECODE_TEXT
|
||||
// JVM_IR_TEMPLATES
|
||||
// 2 java/lang/invoke/LambdaMetafactory
|
||||
// 3 java/lang/invoke/LambdaMetafactory
|
||||
|
||||
// FILE: serializableBoundInterfaceMemberFunRef.kt
|
||||
import java.io.*
|
||||
@@ -18,10 +18,20 @@ class C(val s: String) : Plus, Serializable {
|
||||
override fun plus(ss: String) = ss + s
|
||||
}
|
||||
|
||||
class K : Plus, Serializable {
|
||||
override fun plus(ss: String) = ss + "K"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val p: Plus = C("K")
|
||||
return roundtrip(Sam(p::plus))
|
||||
.get("O")
|
||||
val p1: Plus = C("K")
|
||||
val t1 = roundtrip(Sam(p1::plus)).get("O")
|
||||
if (t1 != "OK") return "Failed: t1='$t1'"
|
||||
|
||||
val p2: Plus = K()
|
||||
val t2 = roundtrip(Sam(p2::plus)).get("O")
|
||||
if (t2 != "OK") return "Failed: t2='$t2'"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun <T> roundtrip(x: T): T {
|
||||
|
||||
Reference in New Issue
Block a user