What is meant by "immutable data"?

I might be wrong, but I thought true immutability is impossible on the JVM. I mean I could always use reflection to access the backing fields of any property. Also this would basically prohibit java interop as there is no guarantee what the java side of the code is doing.
That being said immutable data structures like the one in GitHub - Kotlin/kotlinx.collections.immutable: Immutable persistent collections for Kotlin have their advantages.
I’m just not sure something like the immutable keyword discussed above would work well in Kotlin.


Yes. Depends on the return value of Collections.unmodifiableList. As long as the data structure returned is properly implemented there should be no way of modifying your returned list.

1 Like