• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serilizable problem  RSS feed

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every body I have a query related to serialization :

I have made one class say Test as Serializable for saving the object state.

But is it giving one waring like this :
The serializable class does not declare a static final serialVersionUID field of type long.

For that reason I have written a small code like this :


Now the waring is not comming .

Could any body give me the explanation why it was coming and after ading the assertion , it gone out ?


regards,

S
 
Devaka Cooray
Marshal
Posts: 5650
765
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That warning was because you didn't include an appropriate serialVersionUID attribute.

Later, the @SuppressWarnings("serial") annotation is used to ignore that warning.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which compiler are you using? I have only seen that warning on Eclipse.
 
Devaka Cooray
Marshal
Posts: 5650
765
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Which compiler are you using? I have only seen that warning on Eclipse.

You can see that when -Xlint parameter is used with javac
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,

Can you just tell what is serialVersionUID attribute and how should I use it on my class ?

regards,
S
 
Devaka Cooray
Marshal
Posts: 5650
765
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s begri wrote:Can you just tell what is serialVersionUID attribute and how should I use it on my class ?

Please have a look at the link I provided with my first post.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I only seem to use -Xlint when it is "unchecked"; that is obviously why I never see that warning.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!