javaClass
is an extension property that returns the Java class of the runtime of an instance of an object . In your case, it is used as a reference to a property that will give you KProperty1<Foo, Class<Foo>>
an extension function:
val T.javaClass: java.lang.Class<T>
You can use this in combination with a receiver, for example. if Foo
provided a default constructor, you could say:
Foo::javaClass.get(Foo())
which can be simplified to:
Foo().javaClass
::class.java
, Java Class<?>
, " " . :
val kProperty1: KProperty1<Foo, Class<Foo>> = Foo::javaClass
kProperty1.get(Foo()) //class de.swirtz.kotlin.misc.Foo
Foo::class.java //class de.swirtz.kotlin.misc.Foo
Foo().javaClass //class de.swirtz.kotlin.misc.Foo