Files
kotlin-fork/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt
T
Alexander Udalov 401f0ac583 Use TARGET_BACKEND instead of DONT_TARGET_EXACT_BACKEND in box against Java tests
"// TARGET_BACKEND: JVM" more clearly says that the test is
JVM-specific, rather than DONT_TARGET_EXACT_BACKEND which excludes all
other backends.
2021-02-11 13:50:08 +01:00

29 lines
665 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
// MODULE: lib
// FILE: J.java
public class J {
public final String result;
public J(String result) {
this.result = result;
}
}
// MODULE: main(lib)
// FILE: 1.kt
import kotlin.reflect.*
import kotlin.reflect.jvm.*
fun box(): String {
val reference = ::J
val javaConstructor = reference.javaConstructor ?: return "Fail: no Constructor for reference"
val j = javaConstructor.newInstance("OK")
val kotlinConstructor = javaConstructor.kotlinFunction
if (reference != kotlinConstructor) return "Fail: reference != kotlinConstructor"
return j.result
}