The javadoc as well as this question both emphasize on
Enum sets are represented internally as bit vectors.
Now I am wondering - what is the behaviour when sending (standard Java serialized) EnumSet objects over the wire to some other JVM that might have a different version of the underlying Enum class?
In other words: when I sent some Set<MyEnum>
it is very well possible that an exception is thrown during de-serialization on the other JVM (in cases where my JVM is using some MyEnum.NEW_GUY
that the other JVM doesn't know about). In that situation, the deserialization tries to instantiate an enum constant that doesn't exist in the class on the other JVM.
But assuming that EnumSet doesn't transport enum constant instances (but just a bit set with some bits true, some false) - what happens when the serialized EnumSet included MyEnum.NEW_GUY
?
I tried to identify a specification that tells me what should happen ( versus assuming that this is an implementation detail ), but no luck so far.