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

Serializable

 
thomas davis
Ranch Hand
Posts: 207
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of variables are not serialized?
Is static variable can be serialized?Is static method can be serialized?Is method can be serialized?
I know that if I mark transient keyword that variable will not get serialized.
Please explain it ..
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you serialize an object, static variables are not serialized. No methods, static or otherwise, are serialized -- only data is. Yes, by default, any members not marked transient will be serialized (or at least, the serialization machinery will try to do so.
What else do you want to know?
 
David Miranda
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting...

Let me see if I got this right.

When you serialize an object, you serialize the object's non-static class-level properties?

The object itself is just a pile of property data in memory. Methods are not stored in the object. That's why an object can be serialized, because its just property data?

For instance, when a reference variable is declared as a type of class, eg:
String myString; //step 1
Im guessing the runtime environment knows that the myString reference can invoke methods of class String...but at this point there is no data to manipulate with this reference.

When this is called:
myString = new String("asdf"); //step2
The reference variable now points to a pile of data in memory. The data can now be manipulated by invoking methods of the reference class used in step 1 (String).

Is this correct?

Thanks

David
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David Miranda:

Is this correct?


Yep.
 
David Miranda
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic