This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how could java store serialVersionUID, however it is static  RSS feed

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the book OCP_ Oracle Certified Professional Java SE 8 Programmer II Study Guide, it is said that :

...static class members will also be ignored during
the serialization and deserialization process....

, there for I thought that the serialVersionUID will be ignored, however, in the same book it is said  that :

...serialVersionUID is stored with the serialized object...

which makes no sens !!!.
 
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you think about how serialization works, you can see that the version UID must be stored with the serialized data. Otherwise, how could the deserialization process tell whether the data was originally produced by the same version of the class?
 
yas sine
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep I know, but how you can explain what static members are not stored, however, UID is stored !!!
 
Paul Clapham
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

yas sine wrote:yep I know, but how you can explain what static members are not stored, however, UID is stored !!!



I don't have to explain that, because it isn't a correct description of what happens. What happens is, the UID is stored but other static members aren't.

What requires explanation is why the books you quoted don't have a correct description.
 
yas sine
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I see now, so you said that, it is correct that static members are ignored, except UID ??
 
Paul Clapham
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find it's better not to make assumptions about how things are implemented. However, it's true that if you serialize an object using serialVersionUID = 42 and then try to deserialize it using serialVersionUID = 86, an exception will occur. That means the deserialization process knows what serialVersionUID was at the time of serialization.

This is what you need to know about serialVersionUID.

Now, the only way I can see to implement that rule is by storing the serialVersionUID in every serialized object. But Java implementers are very smart people and for all I know they have implemented that rule in a very smart way which I didn't think of. So nitpicking about whether the serialVersionUID is actually written out is, to me, counterproductive. Whether the documentation actually says that serialVersionUID is actually stored, I don't know.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!