20 lines
418 B
Kotlin
20 lines
418 B
Kotlin
import kotlin.reflect.*
|
|
import kotlin.reflect.jvm.*
|
|
|
|
class K(private val value: String)
|
|
|
|
fun box(): String {
|
|
val p = javaClass<K>().kotlin.properties.single() as KMemberProperty<K, String>
|
|
|
|
try {
|
|
return p.get(K("Fail: private property should not be accessible by default"))
|
|
}
|
|
catch (e: IllegalPropertyAccessException) {
|
|
// OK
|
|
}
|
|
|
|
p.accessible = true
|
|
|
|
return p.get(K("OK"))
|
|
}
|