Code example for InvalidObjectException

0
    private static final long serialVersionUID = 0; 
  } 
 
  private void readObject(ObjectInputStream stream) 
      throws InvalidObjectException { 
    throw new InvalidObjectException("Use SerializedForm"); 
  } 
 
  @Override Object writeReplace() { 
    return new SerializedForm(collection); 
  } 
}