JVM_IR serializable indy method references

This commit is contained in:
Dmitry Petrov
2021-10-18 12:46:58 +03:00
committed by teamcityserver
parent eec16b83c6
commit 1dbbe22c8c
38 changed files with 1960 additions and 221 deletions
@@ -0,0 +1,36 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FULL_JDK
// CHECK_BYTECODE_TEXT
// JVM_IR_TEMPLATES
// 2 java/lang/invoke/LambdaMetafactory
// FILE: serializableJavaStaticMethodRef.kt
import java.io.*
fun box(): String {
return roundtrip(Sam(J::plusK))
.get("O")
}
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);
}
// FILE: J.java
public class J {
public static String plusK(String s) {
return s + "K";
}
}