aspose file tools
The moose likes Beginning Java and the fly likes version Java classes ? 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 » Beginning Java
Reply Bookmark "version Java classes ?" Watch "version Java classes ?" New topic
Author

version Java classes ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 758
why we need to version Java classes, only for serialization ? if yes, when the java code is in production, it will not be changed at all, why need version ?

Thanks.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3036
    
    4

Are you talking about the 'serialVersionUID?' Then yes, that is really only necessary for Serializable classes.

Why do we need it when the code is 'stable' and goes to production? The problem with a good program is that it is never finished being written. The code can be updated and changed over time. Now, if you have Serializable classes and you have Serialized objects that may live for some time then you could have versions of the class that come from different versions of the application. Some of those versions may be incompatible with other version, and having a real version ID is important for tracking that.

This becomes an issue because you can store the Serialized Object to disk, to a database, or across a network. Then when you de-serialize the Object you could be de-serializing it in a newer or older iteration of the program. You might need to apply different conditions when re-building an older-version Object into a newer-version application, or you might not be able to properly de-serialze an Object created in a newer-version application in an older-version application.


Steve
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: version Java classes ?
 
Similar Threads
Why String class is immutable?
Unsuccessfull build due to wrong version 49.0
primitive types in java
Linux vs. Windows jar file - cannot find main class
about InnerClasses