Hello ranchers,
I am trying to understand the overriding of writeObject() and readObject() to manually serialize non-serializable members of a class.
I am writing the class instance into a file in one
java program and then reading it using a different java program. I have overridden the writeObject() and readObject(). Overridden writeObject() works fine, but when I try to read the saved object, the overridden readObject() is not called at all. I am unable to see why it is not working. Could you please identify where is the problem in the following code?
1. SerTest.java - serializes the object. I am overriding wireObject() to manually serialize a static variable in the class.
2. ReadSerTest.java - de-serialize the object. The problem is here - overridden readObject() is not being called at all.
I can not see the output "Reading static variable manually...", it means it is not going to the overridden readobject() method.