KT-11645 properly handle private property getter name mangling in reflection

This commit is contained in:
Dmitry Petrov
2016-04-13 15:59:42 +03:00
parent 511a7e0072
commit 583733be8d
5 changed files with 56 additions and 25 deletions
@@ -36,9 +36,26 @@ fun testY() {
assertEquals("I am const y", field.get(null))
}
fun testZ() {
val field = refZ.javaField ?: throw AssertionError("No java field for ${refZ.name}")
try {
field.get(null)
throw AssertionError("IllegalAccessError expected")
}
catch (e: IllegalAccessException) {
// OK
}
field.setAccessible(true)
assertEquals("I am private const val Z", field.get(null))
}
fun box(): String {
testX()
testY()
testZ()
return x
}
@@ -50,3 +67,6 @@ package test
var x = "I am x"
const val y = "I am const y"
private const val z = "I am private const val Z"
val refZ = ::z