Open hrkfdn opened 1 day ago
I've confirmed the issue. It is a caching issue. To get it to work you can disable the cache using (or with whatever policy configuration you use):
XML {
indent = 4
defaultPolicy {
formatCache = FormatCache.Dummy
}
}
I've analysed it. And the key reason is that Element
and OtherElement
have the same serial name, and as such their types can not be distinguished (and their descriptors are effectively identical). If you instead use @XmlSerialName
it will work correctly as that annotation is not transparent.
Note that this is a fundamental limitation of the serialization library. Looking at the implementation of PluginGeneratedSerialDescriptor
(and the debugger) the serialDescriptors of both are equal (despite the element names being different).
This needs "fixing" in the serialization library itself. In the meantime consider that having two types with equal @SerialName
annotation in the same serialization context is not supported.
Makes sense, thanks for investigating!
This problem occurs with 0.90.2 and 0.90.3. See the following example:
This will print the following XML:
Note how in
OtherParent
/element
the tag is<a>
, even though it should be<b>
.