User Tools

Site Tools


This is an old revision of the document!

Des Rivières, J. Evolving Java-based APIs. 2007


This document is about how to evolve Java-based APIs while maintaining compatibility with existing client code.


Yann-Gaël Guéhéneuc, 2014/02/06

This document is very interesting because it tells all about Java-based API evolution in one document (okay, in three separate pages) without wasting space but going straight to the point. It starts by defining some basic concepts, such as Component, Component API, and Client and different levels of compatibility between an old and a new version of the Component API wrt. Clients:

  • Contract compatibility: API changes must not invalidate formerly legal Client binaries;
  • Source code compatibility: API changes must not prevent Client code to compile against the new release of the Component;
  • Binary code compatibility: pre-existing Client binaries must link and run with the new release of the Component without recompiling;
  • Data compatibility: Component new implementation must contain readers for current and all past versions of the data format.

The document emphasises that source code compatibility is not necessary, because it argues that most API changes can be caught by the compiler and corrected by the developers. It is correct if the documentation regarding the transition between old and new API is sufficiently explicit for developers to easily find how to change their code.

Then, the document put forward the assumptions that “every aspect of the API matters to some Client” and that, therefore, the API must be compatible in principle and in practice: in principle, “all pre-existing Clients must still be legal according to the contracts spelled out in the [new] Component API specification”; in practice, “[p]re-existing Client binaries must link and run with the new release of the Component without recompiling”.

Contract compatibility is the highest form of compatibility and the one that must be sought when evolving a Component. Contract compatibility depends on the role played by the Component and the Client and what kind of changes occurred between the two versions of the API. The roles are “caller” and “implementor”:

  • a Component can offer an API and its implementation, it is the implementor; the Client access the API, it is the caller;
  • a Component can offer a “callback” API, it is the caller; the Client must implement the API, it is the implementaor.

and the question is “For roles played by Clients, would the […] API change render invalid a hypothetical Client making legal usage of the existing API?”

evolving_java-based_apis.1391670928.txt.gz · Last modified: 2018/03/04 02:53 (external edit)