Files
kotlin/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt
Alexander Udalov a8046020fb Rename kotlin.reflect.IllegalAccessException -> IllegalPropertyAccessException
The former name clashes with java.lang.IllegalAccessException and proved to be
inconvenient because it should always be qualified in the source.

Also use java.lang exception's message as kotlin.reflect exception's message
2015-03-07 02:32:15 +03:00

30 lines
670 B
Kotlin

import kotlin.reflect.IllegalPropertyAccessException
import kotlin.reflect.KMemberProperty
import kotlin.reflect.jvm.accessible
class Result {
private val value = "OK"
fun ref(): KMemberProperty<Result, String> = ::value
}
fun box(): String {
val p = Result().ref()
try {
p.get(Result())
return "Fail: private property is accessible by default"
} catch(e: IllegalPropertyAccessException) { }
p.accessible = true
val r = p.get(Result())
p.accessible = false
try {
p.get(Result())
return "Fail: setAccessible(false) had no effect"
} catch(e: IllegalPropertyAccessException) { }
return r
}