Should I add the serialVersionUID
field when creating an interface that extends Serializable?
My IDE (Netbeans 8.2) complains that the field is missing. However, to my understanding, serialVersionUID
is only applicable to non-abstract classes (the specific classes that will be instantiated during deserialization).
If serialVersionUID
is necessary, what should I do about interfaces that extend interfaces? Normally, this field is declared in every class down the class heirarchy. While this is also possible for interfaces, it leads to a different IDE warning that fields hide fields.
No you should not. The serialVersionUID
of an interface is nowhere taken into account during the serialization or deserialization process. It is pointless. serialVersionUID
is for Serializable
classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With