Be "static blocks" do you mean "Static Initialization Blocks"?During deserialization, the constructor of the class (or any static or instance blocks) is not executed.
Aren't "Static Initialization Blocks" a part of class initialization? Ah, now I think I understand what you mean. In the code below "Static Initialization Blocks" whould be executed if the class Moo is used for the first time but it whould not be executed as a part of the deserialization. Is that correct?
Code: Select all
FileInputStream fis = new FileInputStream("c:\\temp\\moo1.ser");
ObjectInputStream is = new ObjectInputStream(fis);
Moo moo = (Moo) is.readObject();