File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Serializable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serializable" Watch "Serializable" New topic
Author

Serializable

thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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?


[Jess in Action][AskingGoodQuestions]
David Miranda
Ranch Hand

Joined: Mar 14, 2005
Posts: 34
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by David Miranda:

Is this correct?


Yep.
David Miranda
Ranch Hand

Joined: Mar 14, 2005
Posts: 34
Great! thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serializable