Giorgi
07/21/2026, 12:49 PMGiorgi
07/21/2026, 12:50 PMfun main() {
val list = listOfString("asdf", "asdf", "asdf")
println(list::class)
println(" Multiplatform CLI: ${getWorld()}")
}
prints class kotlin.collections.asList$1. what is that asList? is it really a class?Giorgi
07/21/2026, 12:52 PMCLOVIS
07/21/2026, 1:29 PMjava.util.ArrayList because that's a Java class, and Java classes are not available on Native. It could however be kotlin.collections.ArrayList .
The implementation of listOf is:
fun <T> listOf(vararg elements: T): List<T> =
if (elements.size > 0) elements.asList() else emptyList()
and asList is platform-dependent (it's a Java ArrayList on the JVM, and some other kinds of list on other platforms).CLOVIS
07/21/2026, 1:30 PMGiorgi
07/21/2026, 1:31 PMGiorgi
07/21/2026, 1:33 PMkotlin.collections.ArrayList ?ephemient
07/21/2026, 1:45 PMjava.util.ArrayList on JVM and an actual class on other platformsEdgar Avuzi
07/22/2026, 7:03 AMAlso why it is not directly class java.util.ArrayList instead of class java.util.Arrays$ArrayList on JVM?
java.util.ArrayList and java.util.Arrays$ArrayList are two entirely different classes on the JVM. They just happen to share the same simple name (ArrayList) which causes a confusion