Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's ServialVersionUID use for ?

 
Ryan Chiu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I install new version eclipse 3.1, it found out some codes I wrote before didn't have ServialVersionUID ? It's ask me tho add "use default servial version ID" or "generated serial version ID". It's will create coding like this:
private static final long serialVersionUID = 1L;
or
private static final long serialVersionUID = 6594051617034005804L;
Could anyone tell me, what's ServialVersionUID use for ? and what's difference between default ServialVersionUID and other ?
Thank you so much !
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan,
Welcome to JavaRanch!

If you have an object that implements the Serializable interface, you should have the serial version uid. In general, you want to have Eclipse generate it for you (not use the default).

See this thread in the IDEs forum for more details.
 
Ryan Chiu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear Jeanne:

Thanks for your response. I have seen the thread.
WOW, so that mean when JVM need use a serializable object, it will calculate this serialVersionUID?(I didn't know that, sorry!).And if I write it in my code, the JVM will use it directly, so it can save the time, and like you say:

"In other words using the serialVersionUID will make your code faster and more uniform across platforms."

Is it right ?

Thank you.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ryan Chiu:
"In other words using the serialVersionUID will make your code faster and more uniform across platforms."

Is it right ?

Exactly!

This isn't the most common piece of Java knowledge, so it's not a big deal for not knowing it. In fact, it's nice of Eclipse to call it to our attention.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic