| Author |
serialVersionUID question
|
Abhimanyu Kumar
Greenhorn
Joined: Nov 05, 2004
Posts: 12
|
|
Hi, I came to know that " The identifier that is part of all classes is maintained in a field called serialVersionUID." But I am not able to access this field directly (say through a print statement, like System.out.println(serialVersionUID); ). So where is this value stored ? Also, i didnt find it in the class file when i opened it with decompiler. Thanks in advance. Abhimanyu.
|
"Where there's a will, I want to be in it."
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12267
|
|
According to the documentation I found, if you do not define a static final long serialVersionUID in your Serializable class, the ObjectOutputStream will compute one. The purpose being to avoid incompatible versions of a class being created by object serialization. Bill
|
Java Resources at www.wbrogden.com
|
 |
Mihai Radulescu
Ranch Hand
Joined: Sep 18, 2003
Posts: 912
|
|
Hallo I got a similar problem with this (but with an other flavor), the non static inner classes can not be serializated (as long the content class is not serializable). The explication was that a non static inner can not have a static member and if the content class is serializable its serialUID member can be access by the inner class. I hope I was right ? What you think ?
|
SCJP, SCJD, SCWCD
|
 |
Abhimanyu Kumar
Greenhorn
Joined: Nov 05, 2004
Posts: 12
|
|
Originally posted by Mihai Radulescu: Hallo The explication was that a non static inner can not have a static member.
Just one sidenote. Non static inner class can have static final variables (as they are constants). For ex. -Abhimanyu.
|
 |
Mihai Radulescu
Ranch Hand
Joined: Sep 18, 2003
Posts: 912
|
|
|
Yeep It seamns that you have right Abhimanyu, a inner calss can have constants (final static). Good point!
|
 |
 |
|
|
subject: serialVersionUID question
|
|
|