Fix NPE in KCallable.isAccessible for interfaces loaded by boot class loader

Class.getClassLoader returns null for classes loaded by the system class
loader (the one used to start the application). In this case we need to
use ClassLoader.getSystemClassLoader. We already have an extension
`safeClassLoader` specifically for this purpose in reflection.jvm, but
forgot to use it in d59f2bcc80.

 #KT-37707 Fixed
This commit is contained in:
Alexander Udalov
2020-04-08 20:20:50 +02:00
parent a7b959b88b
commit 683489687e
6 changed files with 41 additions and 1 deletions
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_REFLECT
import kotlin.reflect.jvm.isAccessible
fun box(): String {
val members = Observer::class.members
for (member in members) {
member.isAccessible = true
}
return members.single { it.name == "result" }.call(Observer()) as String
}
class Observer : AutoCloseable {
override fun close() {
}
private fun result() = "OK"
}