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)
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
russhwolf
05/25/2021, 1:46 PM
kotlinx-datetime also added built-in serializers in 0.2.0 so you could consider moving to those instead of defining your own.
z
zeugederunity
05/25/2021, 1:55 PM
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 ^^
zeugederunity
05/25/2021, 1:59 PM
Therefore we wait until all these "Instant"-class things become stable. Before that we don't want to mess around with our data. 🙂