• Post Reply Bookmark Topic Watch Topic
  • New Topic

Ensure an object can be serialized safely

 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is implementation of Serilizable interface enough?
How to test it using junit?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!