- Java’s equivalent of resolving a variable's name is with the .getClass() method, for example, something.getClass(). In Kotlin, we can achieve the same thing with something.javaClass.
- To get a reference to the reflection class, we used to do something.class in Java, whose Kotlin equivalent is something::class. This returns a KClass. The special features of this KClass is that it provides introspection capabilities quite similar to the abilities provided to Java’s reflection class.
Note that the KClass is different from Java’s Class object. If you want to obtain a Java Class object from Kotlin's KClass, use the .java extension property:
val somethingKClass: KClass<Something> = Something::classval a: Class<Something> = somethingKClass.java ...