Thread
#serialization
    j

    jw

    2 months ago
    i have a public interface with properties in module A, a private data class implementing the interface in module B, and in module C (the only one I control) i need to create a serializer for the interface type (for encoding only). Are my only options a manually-written serializer for the interface or a surrogate? i really would like to avoid having to maintain a hand-written serializer but also would like the serialize without extra allocation of surrogates for every instance in the outgoing tree. My dream would be external seriazation generation through
    @Serializer(forClass=)
    but for an interface where the generated decoder throws UOE, or I could manually override decode and throw UOE
    Dominaezzz

    Dominaezzz

    2 months ago
    At the moment those are your only options yes.
    @Serializer(forClass=)
    doesn't even work for public sealed classes yet. It's got a long way to go.
    j

    jw

    2 months ago
    I went with surrogate for now. It's all codegen so it doesn't really matter, but allocation just to turn around and unpack it hurts me to see. But it's 3 LOC vs lots of code and lots of logic. Oh well.
    Dominaezzz

    Dominaezzz

    2 months ago
    Well, if you have no concurrency you could cache the surrogate but I reckon that'll hurt to see as well.