Classes loaded to diffrent class-loaders have equal serial descriptor
Describe the bug
If one loads the same serializable class in two different class-loaders, corresponding serial descriptors are equal (in sense desctiptor1 == descritor2 returns true, while they are different.
Attach a code snippet or test data if possible.
test-kotlinx-serialization-with-classloaders.zip
Expected behavior
Different descriptors of different serializers are not equal.
Actully, I'm not sure if it is a problem with classloaders, or with any two serial descriptors with same serial name. But that looks like a reasonable way of having such a clash.
Actully, I'm not sure if it is a problem with classloaders, or with any two serial descriptors with same serial name. But that looks like a reasonable way of having such a clash.
Yep, serial names have to be unique: https://github.com/Kotlin/kotlinx.serialization/pull/3098
The question is whether it is reasonable to handle this case in the equals of a descriptor (for the few cases this matters). The biggest actual issue would be a case where two different implementations are loaded, and then attempted to be serialized by the same format instance (where the instance caches some of its operations). Ensuring unique names would not really be feasible in this context though.
I'm not sure we can deliver a meaningful fix here. Contract for SerialDescriptor equality is fixed and will likely be too hard to change at this points. Besides, there' really nothing else we can compare in equals besides maybe this::class.classLoader