Files
kotlin/compiler/testData/codegen/box/reflection/properties/javaStaticField.kt
Alexander Udalov fc043c6e66 Drop KPropertyNFromReferenceImpl classes
The only place where their get/set methods were used was in
KPropertyNImpl.Getter.invoke, and it's fine if that results in a reflective
call instead (KPropertyN#getter is not available without kotlin-reflect.jar
anyway). The test data has been changed because a package local Java field is
not accessible via reflection
2016-09-13 14:12:29 +03:00

34 lines
579 B
Kotlin
Vendored

// WITH_REFLECT
// FILE: J.java
public class J {
public static String x;
static String packageLocalField;
}
// FILE: K.kt
import kotlin.test.assertEquals
fun box(): String {
val f = J::x
assertEquals("x", f.name)
assertEquals(f, J::class.members.single { it.name == "x" })
f.set("OK")
assertEquals("OK", J.x)
assertEquals("OK", f.getter())
val pl = J::packageLocalField.getter
try {
pl()
return "Fail: package local field must be inaccessible"
} catch (e: Exception) {
// OK
}
return f.get()
}