Hyphen icon indicating copy to clipboard operation
Hyphen copied to clipboard

Allow SubClass types to still allow subclass of the types

Open Kroppeb opened this issue 4 years ago • 0 comments

Without a @SerSubclasses a variable can be any subtype, (it will just get deserialized to the subclass unless we implement #14) but once the annotation is added, equality checks are done on the field.getClass() meaning subclasses will fail to get serialized properly.

This could be solved by using instanceof checks instead (or even use the java 17 preview feature to pattern match, if available). However this means we do need to sort the the classes (*) so that super classes are always checked before sub classes.

(*) This could however form a problem with #14 and #15, but even with custom serializers registered for interfaces, one could provide two interfaces as possible subclasses, and an object might implement both interfaces, which would complicate the sorting process.

Kroppeb avatar Sep 25 '21 00:09 Kroppeb