Java 8 default methods enable gradual interface evolution without breaking client code. The post defines a three-phase process (new version → client transition → final version) for adding, replacing, and removing interface methods. For adding methods, it distinguishes between cases where a reasonable default exists versus using a temporary UnsupportedOperationException stub. For replacing methods, circular default calls between old and new methods allow either to be implemented during transition. For removal, a deprecation with a throwing default implementation gives clients time to stop using the method before it disappears. Proper use of @Deprecated and @apiNote Javadoc tags is recommended to communicate the migration path to clients.

8m read timeFrom nipafx.dev
Post cover image
Table of contents
▚ Terminology▚ Interface Evolution - Methods▚ Reflection

Sort: