File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is transient allowed with static?

 
Louie van Bommel
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Can a variable be transient if it is static?
2. If so, why? As far as I know java.io Object writing routines only write out instance variables, and not class variables. Aren't objects serialized without their static variables?
 
Thomas De Vos
stable boy
Ranch Hand
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very interesting question.

Class variables (static) can be declared as transient, however class variables are not serialized and de-serialized. Only the persistence state of the object will be serialized, class variables will be re-created or intialized when the object is constructed after the de-serialisation process.

I recommend using the keyword transient for class variables, this makes it very clear to the programmer of the class that this variable will not be serialized.
 
Tom Tolman
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you IO the class itself?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic