oSumAtrIX
04/11/2024, 10:53 PMkotlinx.serialization.SerializationException: Class 'LinkedHashSet' is not registered for polymorphic serialization in the scope of 'Set'.
To be registered automatically, class 'LinkedHashSet' has to be '@Serializable', and the base class 'Set' has to be sealed and '@Serializable'.
Alternatively, register the serializer for 'LinkedHashSet' explicitly in a corresponding SerializersModule.
at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:102)
at kotlinx.serialization.internal.AbstractPolymorphicSerializerKt.throwSubtypeNotRegistered(AbstractPolymorphicSerializer.kt:114)
at kotlinx.serialization.PolymorphicSerializerKt.findPolymorphicSerializer(PolymorphicSerializer.kt:109)
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:233)
at kotlinx.serialization.json.internal.JsonStreamsKt.encodeByWriter(JsonStreams.kt:28)
at kotlinx.serialization.json.Json.encodeToString(Json.kt:81)
But the docs suggest that a Set is serializableAhmed Riyadh
04/13/2024, 7:06 PMLinkedHashSet
is custom class from Kotlin/JVM and it's not serializable like Set
While Set is supported by Kotlin internally
You can see in Kotlin source code:
@SinceKotlin("1.1") public actual typealias LinkedHashSet<E> = java.util.LinkedHashSet<E>
Ahmed Riyadh
04/13/2024, 7:09 PMSet
is fully supported by Kotlin which mean you can use it also in Kotlin/NativeoSumAtrIX
04/14/2024, 3:53 AMoSumAtrIX
04/14/2024, 3:53 AMAhmed Riyadh
04/15/2024, 12:57 AMLinkedHashSet
from kotlin.collections
By manually use it, the IDE will use the one from java.util.*
Example:
private val rooms = Collections.synchronizedMap<String, Room>(kotlin.collections.LinkedHashMap())
I don't think that will solve the issue though since (since it's typealias
)oSumAtrIX
04/15/2024, 9:33 PMoSumAtrIX
04/15/2024, 9:33 PMoSumAtrIX
04/15/2024, 9:34 PMoSumAtrIX
04/15/2024, 9:34 PM