Files
kotlin/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaMethods.kt
Alexander Udalov 2564a2f91f Do not include kotlin-reflect at runtime by default in codegen tests
Change some tests to either include reflection or to avoid using it
2016-03-09 10:25:38 +03:00

34 lines
766 B
Kotlin
Vendored

// WITH_REFLECT
// FILE: J.java
public class J {
public String f(String s) {
return s;
}
public static String g(String s) {
return s;
}
}
// FILE: 1.kt
import kotlin.reflect.*
import kotlin.reflect.jvm.*
fun box(): String {
val f = J::f
val fm = f.javaMethod ?: return "Fail: no Method for f"
if (fm.invoke(J(), "abc") != "abc") return "Fail fm"
val ff = fm.kotlinFunction ?: return "Fail: no KFunction for fm"
if (f != ff) return "Fail f != ff"
val g = J::g
val gm = g.javaMethod ?: return "Fail: no Method for g"
if (gm.invoke(null, "ghi") != "ghi") return "Fail gm"
val gg = gm.kotlinFunction ?: return "Fail: no KFunction for gm"
if (g != gg) return "Fail g != gg"
return "OK"
}