So the Serializable interface is empty, but you get a warning if you dont add the serialVersionUID variable into the class. Is it possible to create an interface that does this same thing?
Printable View
So the Serializable interface is empty, but you get a warning if you dont add the serialVersionUID variable into the class. Is it possible to create an interface that does this same thing?
I think that there's some behind the scenes magic with Serializable that mere mortals cannot create by simply creating a marker interface.
if you wanna create an interface, that marks a class with exactly this warning, then just let your own interface extends the Serialzable.
for your own warnings I am afraid that you must write your own validator(if you use eclipse for example)
BTW the Serializable is a marker interface. It is use by the output and especially the input streams with reflection to find out which fields in an inheritance hierarchy are initialized from disc and which via optional constructors.
the serialVersionUID there is to find out the version of a class if you deserialize an older class version object, I think