Penalty to implement Serializable in Java?

There is no performance impact unless you perform serialization/deserialization but there are trade offs in terms of api design.

From Effective java by Joshua Bloch

  • A major cost of implementing Serializable is that it decreases the flexibility to change a class’s implementation once it has been
    released
  • A second cost of implementing Serializable is that it increases the likelihood of bugs and security holes
  • A third cost of implementing Serializable is that it increases the testing burden associated with releasing a new version of a class

Upto what extent these are applicable to you depend of your usecase.

Leave a Comment