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,15 @@
fun box(): String {
val l: Any = {}
val javaClass = l.javaClass
val enclosingMethod = javaClass.getEnclosingMethod()
if (enclosingMethod?.getName() != "box") return "method: $enclosingMethod"
val enclosingClass = javaClass.getEnclosingClass()
if (!enclosingClass!!.getName().startsWith("_DefaultPackage-lambdaInFunction-")) return "enclosing class: $enclosingClass"
val declaringClass = javaClass.getDeclaringClass()
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
return "OK"
}