What is the difference between ::class and ::class.java in Kotlin?

By using ::class, you get an instance of KClass. It is Kotlin Reflection API, that can handle Kotlin features like properties, data classes, etc.

By using ::class.java, you get an instance of Class. It is Java Reflection API, that interops with any Java reflection code, but can’t work with some Kotlin features.

Leave a Comment