Hello everyone, after upgrading to Kotlin 1.5.10 ...
# serialization
z
Hello everyone, after upgrading to Kotlin 1.5.10 with kotlinx-serialization-Version 1.2.0 (from Kotlin 1.4.30 and kotlinx-serialization 1.0.1) my code throws the following error:
Copy code
java.lang.IllegalStateException: Class Instant have constructor parameters which are not properties and therefore it is not serializable automatically
	at org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen.checkSerializability(SerializerCodegen.kt:28)
	at org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen.generateSerializableClassPropertyIfNeeded(SerializerCodegen.kt:101)
	at org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen.generate(SerializerCodegen.kt:34)
I allready created a minimal Example at: https://github.com/FelixEngl/FailingInstantSerialisation Does anyone know how to fix this?
Never mind, a colleague found a "fix". We just have to remove the
@Serializer(forClass = Instant::class)
from the
InstantSerializer
. If someone is already looking into the error, thank you.
r
kotlinx-datetime also added built-in serializers in 0.2.0 so you could consider moving to those instead of defining your own.
z
Thank you! That is already in the migration pipeline, but before we can use the new Serializer we have to migrate a lot of data because we store our Timestamps with a Long ^^
Therefore we wait until all these "Instant"-class things become stable. Before that we don't want to mess around with our data. 🙂