This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Does deserializing an object in another JVM call the static initializer? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Does deserializing an object in another JVM call the static initializer?" Watch "Does deserializing an object in another JVM call the static initializer?" New topic
Author

Does deserializing an object in another JVM call the static initializer?

Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

Hi everybody,

Does deserializing an object in another JVM call the static initializer?
It does not within the same JVM as the class is already loaded while serializing it, however what about in another jvm? Would the static initializer get called?

Thanks in advance.



OCAJP 7, OCPJP 7
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Objects don't have static initializers. Classes have static initializers. And those static initializers are called when the class is loaded.

And there's no reason why a JVM, when deciding whether to load a class, would pay any attention to any other JVMs which happen to be running elsewhere. If it needs the class then it's going to load the class.

As you can see this has very little to do with serialization of objects.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does deserializing an object in another JVM call the static initializer?
 
Similar Threads
serialization and VM
Static variables are never saved during Serialization, yet my code seems to do the opposite
Serialization
Serialization
serialize a static variable?