Kotlin types such as List, MutableList, String, CharSequence etc. are all compiled to their java equivalents, and thus any runtime checks will not be able to distinguish between them. At compile-time, however, they are distinct types with different sets of members. In particular, the Kotlin types do not have all members that the corresponding Java types have. They have those listed in the Kotlin std lib reference, as well as a few extra JVM specific ones (such as Collection.stream()
). I have not been able to find any documentation on which JVM specific members are included.
In addition, when working with a class C written in Java, any occurrence of a mapped class within C will appear as the Kotlin version of that class. This, among others, includes base classes and interfaces. This also holds true when C is a class built into Java, and even holds true when C itself is one of the mapped classes. This means, for instance, that java.lang.String
is considered a subclass of kotlin.CharSequence
. Thus, it supports all operations also supported by kotlin.CharSequence
such length
(as a property, not just a method).