• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting serialVersionUID  RSS feed

 
Robert Hill
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the warning about a serialiable class not having an id, Eclipse offers 3 quick fixes:

Add default serial version ID
Add generated serial version ID
Add @SuppressWarnings to class

Of the first 2, is one always better, if not when is one better?

About the last option, it seems wrong to me to ignore any warning. Ia this not the case?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of these three is "better" -- each has an appropriate use. The third one is perfectly appropriate if you choose not to worry about versioning for the class -- i.e., if the serialized data will never be stored in a file or shared with some other revision of this same program. Otherwise the first one is perfectly fine; I can't imagine any situation where the second one would be preferable, but it's also not worse in any way.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!