Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Class and Object Compatibility

The binary compatibility rules are somewhat similar to those for serialization of Java objects, and for the same reasons. When a Java object is serialized, the name of the class and the names of the fields are written to a binary output stream. You can read the serialized object with a different version of the class, as long as the classes and fields you expected to find are still there and haven't changed type. The following table summarizes some of the differences.

Some Differences Between Serialization and Binary Compatibility

 

Object Serialization Compatibility

Java Binary Compatibility

Applies to

Objects

Classes

Examines

Classes and fields

Classes, fields, and methods

Deletions cause incompatibilities

Always

Sometimes

Access (public, etc.) changes are compatible

Yes

No


Both deal with the idea that classes generally grow over time; you add methods and fields, and purely additive behavior like that shouldn't change the semantics of the program as it runs. Purely structural changes, such as rearranging fields and methods, shouldn't cause any problems.

  • + Share This
  • 🔖 Save To Your Account