Penalty to implement Serializable in Java? Penalty to implement Serializable in Java? java java

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.


The cost is close to zero, not worth being concerned about.

Some further details:

  • There is no increase in the size of each object instance
  • There is a small increase in the size of the class itself, but as this is a one-off cost it is trivial when amortised over a large number of instances
  • There may be a slight additional runtime cost for anything that needs to do interface checks at runtime (reflection, instancof lookups, extra pressure on inline caches etc.). Again, this is likely to be negligible for most purposes.
  • Serializable is a marker interface, there are no methods that require to be implemented. Other marker interface examples are: Clonable, SingleThreadModel, Event listener.


Unless you / someone else actually serializes / deserializes, there won't be any impact. Serializable is just a marker interface.

It probably will only increase the size of the generated bytecode by a few bytes.