The java.io.ObjectInputStream.enableResolveObject(boolean enable) method enable the stream to allow objects read from the stream to be replaced. When enabled, the resolveObject method is called for every object being deserialized.
If enable is true, and there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubstitution") permission to ensure it's ok to enable the stream to allow objects read from the stream to be replaced.
Following is the declaration for java.io.ObjectInputStream.enableResolveObject() method
protected boolean enableResolveObject(boolean enable)
enable -- true for enabling use of resolveObject for every object being deserialized
This method returns the previous setting before this method was invoked
SecurityException -- if a security manager exists and its checkPermission method denies enabling the stream to allow objects read from the stream to be replaced.
The following example shows the usage of java.io.ObjectInputStream.enableResolveObject() method.
Let us compile and run the above program, this will produce the following result: