aspose file tools*
The moose likes Java in General and the fly likes The serializable class does not declare a static final serialVersionUID field  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "The serializable class does not declare a static final serialVersionUID field  " Watch "The serializable class does not declare a static final serialVersionUID field  " New topic
Author

The serializable class does not declare a static final serialVersionUID field

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 376
What the heck is eclipse 3.2 talking about when it gives me the following warning:

"The serializable class XYZ does not declare a static final serialVersionUID field of type long"

Eclipse will generate such a field for me. I'm just creating a descendant of class Applet.

thanks,
siegfried
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

If you explicitly put such a field into a serializable class, then you can use it to provide versioning for serialized data files containing this class. Class versions with the same SerialVersionUID have compatible serialized data, by definition, even if the class changes.

But if this doesn't matter to you, then just ignore the warning.


[Jess in Action][AskingGoodQuestions]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
For your information: in Eclipse you can change the importance of compile errors/warnings to your taste by Window - Preferences - Java - Compiler - Errors/Warnings. Specific this one can be found in the group called "Potential programming problems".
Robert Hill
Ranch Hand

Joined: Feb 24, 2006
Posts: 94
Disabling it might cause trouble down the road. If you mean to serialize an object the warnings will help you remember.

You can keep the warning turned on and either ignore it or get it out of sight by placing this line above public class ... : @SuppressWarnings("serial")
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 376
Does someone have a favorite URL/tutorial that describes how one uses this unique value for versioning with serialization?

Thanks,
Siegfried
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The serializable class does not declare a static final serialVersionUID field
 
Similar Threads
Compiler Warning when you implement Serializable interface
Eclipse Servlet Warning
Almost ready to hand up: Just cleaning up and have a few questions
serializable
eclipse error