To obtain a Java's Class
object from Kotlin's KClass
use the .java
extension property:
val stringKClass: KClass<String> = String::class
val c1: Class<String> = stringKClass.java
val c2: Class<MyClass> = MyClass::class.java
The latter example will be optimized by the compiler to not allocate an intermediate KClass
instance.