• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

version Java classes ?

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
My pie came with a little toothpic holding up this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic