In some circumstances, for instance if you want to transfere objects via GWT RPC, it makes sense to assert Objects can be serialized and deserialized without problems. Further there might be some differences between the original object and the deserialized object – for instance some hash tags might have changed and of course the object references.
The following code snippet can be a useful addition to JUnit test cases, which need to test the serialization of complex objects:
http://gist.github.com/650417
Hi,
Just to add while writing Serializable class , its good practice to put a Seriazlizable alert in file so that when some one else add a new field in the class he must ensure that field is either transient or Serializable , so that Serializability of class should not break.
Thanks
Javin
Why String is immutable in Java
Findbugs checks automatically for non-serializable fields in serializable classes.