Ensure an object can be serialized safely
author and iconoclast
posted 12 years ago
Implementing Serializable will tell you if an individual object can be serialized, but unfortunately, it's possible that that object has non-serializable members or member containers that contain non-serializable objects. I think actually serializing the object is the only way to say for sure. Serializing to a ByteArrayOutputStream and watching for exceptions would be the way I'd test this in JUnit.