Created
March 25, 2018 06:50
-
-
Save ruwanka/326ffaf51c2b461c7b743adf63be1879 to your computer and use it in GitHub Desktop.
kotlin java reflection interoperability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ruwanka.kotlin.reflections | |
import kotlin.reflect.jvm.javaField | |
import kotlin.reflect.jvm.javaGetter | |
import kotlin.reflect.jvm.javaSetter | |
fun main(args: Array<String>) { | |
// get access to java field | |
println(Student::school.javaField) | |
// get access to java getter and setter | |
println(Student::school.javaGetter) | |
println(Student::school.javaSetter) | |
// get kotlin class (KClass) corresponding to java class | |
println(Student::class.java.kotlin) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment