File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Setting serialVersionUID Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Setting serialVersionUID" Watch "Setting serialVersionUID" New topic
Author

Setting serialVersionUID

Robert Hill
Ranch Hand

Joined: Feb 24, 2006
Posts: 94
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
Marshal

Joined: Jul 08, 2003
Posts: 24051
    
  13

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.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: Setting serialVersionUID
 
Similar Threads
SerialsUID
Configure Eclipse's serialVersionUid Quick Fix
(De)Serialization question
Serialization SCJP KS && BB
warnig when creating my own Exception