Support mapping between Java and Kotlin reflection objects

This commit is contained in:
Alexander Udalov
2014-06-20 19:22:02 +04:00
parent c575ad9fb0
commit 704de8992e
33 changed files with 434 additions and 93 deletions

View File

@@ -0,0 +1,20 @@
class C {
fun foo(): Any {
return {}
}
}
fun box(): String {
val javaClass = C().foo().javaClass
val enclosingMethod = javaClass.getEnclosingMethod()
if (enclosingMethod?.getName() != "foo") return "method: $enclosingMethod"
val enclosingClass = javaClass.getEnclosingClass()
if (enclosingClass?.getName() != "C") return "enclosing class: $enclosingClass"
val declaringClass = javaClass.getDeclaringClass()
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
return "OK"
}