This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


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: 18570
    
    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?