Open abhishiv opened 2 years ago
Why do you need @Polymorphic
on val items
at all? Sealed classes should be polymorphic automatically.
Hey @sandwwraith If I remove the annotation on items, it still doesn't run and throws the same errror. I think it's because it's an ArrayList of a sealed class?
@Serializable
class Library2(val name: String ) {
constructor() : this("Unnamed Library")
val items: MutableCollection<Item2> = mutableListOf()
}
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project functions-kotlin-hello-background: An exception occured while executing the Java class. null: InvocationTargetException: Class 'ArrayList' is not registered for polymorphic serialization in the scope of 'Collection'.
It seems there's a confusion somewhere in the plugin that it doesn't recognize mutable collection. Try use MutableList
instead
That works! Thanks a lot!
But it does not work if its immutable? Still? tf?
Describe the bug
Hey all, I have been stuck on this for hours. Apparently whenever I try to serialise a polymorphic type inside of a MutableList it fails with
I just can't figure out the what a serializer for Arraylist in the scope of Collection would look like. I found #1341 but that doesn't look related since I'm trying to serialize an ArrayList of classes not primitives so that should be possible.
To Reproduce Attach a code snippet or test data if possible.
Expected behavior
Environment