Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

The JDK used default methods to evolve Collection without breaking a vast ecosystem. What lessons does that offer for governing APIs inside a company with hundreds of services and libraries?

The JDK lesson is that published interfaces are almost impossible to change, so compatibility has to be designed in from the start rather than rescued with tricks later. Inside a company, that means separating interfaces clients call from interfaces clients implement, keeping APIs small, making compatibility checks and semantic versioning required gates, and planning deprecation and removal using telemetry on real usage, the way the JDK uses deprecation for removal.

Background to this question

A company with hundreds of services and shared libraries has the same problem the JDK has, at a smaller scale but with less discipline: thousands of places depend on interfaces that their owners would like to change. When the JDK needed lambdas to work with collections, it could not add abstract methods to Collection without breaking every implementation in the world, so Java 8 invented default methods. That story is a good lens for API governance. In this answer, we will look at what the JDK actually did and what it cost, then turn each part of it into a rule for an internal platform, and finish with how a senior engineer would introduce those rules without stopping everyone's work.

1What the JDK Actually Did

Java 8 needed methods such as stream(), forEach() and removeIf() on collections. Collection and Iterable are implemented by a huge number of classes outside the JDK, in libraries and applications. An abstract method would have broken all of them. Default methods let the JDK add a body in the interface itself, so every existing implementation got a working version automatically, while the JDK's own collections overrode them with faster ones.

It was not free. Defaults can clash with methods that implementations already had, and later additions show this clearly: when Java 21 added sequenced collections, with methods such as reversed() and getFirst() on List and Deque, some existing classes that already had methods with those names, or implemented both interfaces, had compatibility problems that the release notes had to call out (check the JDK 21 release notes for the details). The lesson is not "default methods solve evolution"; it is that evolving a widely implemented interface is so hard that a language feature was needed, and even that only mostly works.

2Lesson 1: Design Compatibility In, Because Adding It Later Is Expensive

The JDK could change collections only because its team treats every published interface as permanent and checks compatibility constantly. Inside a company, we usually discover an interface is "published" only after forty services depend on it. So the first rule is to decide, when a library is created, which of its types are public API and which are internal, and to make that visible: separate packages, module exports, or an internal package that build rules forbid others to import.

A small amount of design up front buys a lot later. Interfaces that take a request object instead of five parameters can grow a field without a signature change. Results that are records or small classes can gain information without breaking callers. Using these shapes from the start is cheaper than any migration.

3Lesson 2: Separate What Clients Call From What Clients Implement

Adding a method to an interface is free for code that calls it and costly for code that implements it. The JDK knows this well: JDBC's interfaces are implemented by driver vendors and called by everyone, and they evolve very carefully. Inside a company, the same split appears as API, the interfaces services call, and SPI, a service provider interface, the interfaces teams implement to plug into a platform.

We should keep the two apart and govern them differently. A call-only interface can gain methods in any minor release. An implemented interface gets stricter rules: new capabilities arrive as new small interfaces or as defaults with real behaviour, never as abstract methods outside a major version, and the number of implementers is tracked so the owner knows the cost of every change.

Rules for the two kinds of interface
ChangeCalled-only interface (API)Implemented interface (SPI)
Add a methodAllowed in a minor releaseOnly as default with real behaviour, or new interface
Add an abstract methodAllowed in a minor releaseMajor version only, with migration window
Remove or change a methodMajor version after deprecationMajor version after deprecation
Who must approveLibrary ownerLibrary owner plus implementer review
The direction of dependency decides how strict the rule must be.

4Lesson 3: Make Compatibility Checks and Semantic Versioning Gates

The JDK runs extensive compatibility checks for every change. The internal equivalent is cheap: add japicmp or Revapi to the shared build template so every library compares its API against its last release, and fail any minor or patch release that contains an incompatible change. Semantic versioning then means something, because the tool, not the author's memory, enforces it.

The important word is required. An optional check is turned off the first time it is inconvenient. Putting it in the shared build plugin, with an explicit, reviewed way to accept a break in a major release, makes the safe path the default path.

5Lesson 4: Keep APIs Small, Because Every Method Is a Commitment

Every public method in the JDK is, in practice, supported forever. That is why JDK APIs are reviewed slowly and why convenience methods are added reluctantly. Internally, the cost is smaller but real: each public method is something we must keep working, test, document and eventually migrate people off.

So library owners should prefer fewer, more general methods, keep helper code package-private, and resist adding a method for a single caller. A useful review question is: if we had to support this method for five years, would we still add it?

6Lesson 5: Plan Deprecation and Removal With Telemetry

Since Java 9, the JDK marks APIs with @Deprecated(forRemoval = true, since = "..."), ships a tool, jdeprscan, that finds uses of deprecated APIs in compiled code, and removes them only after several releases of warning. Removal is a plan with dates, not a hope.

Inside a company we can do better than the JDK, because we can see our users. A scan of the artifact repository or monorepo tells us which services still compile against a deprecated method, and a counter or log line in the method tells us who still calls it at run time. With that data, removal becomes a list of owners and a date, and we remove the method when the counter has been zero for a release cycle.

Step throughLifecycle of an internal API method
  1. Mark deprecated for removalwith the replacement in the Javadoc
  2. Measure userepository scan plus a run-time counter
  3. Contact remaining ownerswith a date and migration help
  4. Still in use?
    YesExtend the date for named ownersNoRemove in the next major version

4 steps in order. Play them, or step through them one at a time.

Removal is driven by data about real use, not by the calendar alone.

7Follow-up questions

How would you introduce these rules without blocking every team?

Start with the libraries that have the most dependants and enable the compatibility check in reporting mode for a month, so owners see what it would have caught. Then make it blocking for those libraries, and add it to the template for new ones. Rules that arrive with tooling and data are accepted much faster than rules announced in a document.

What do you do when a breaking change is genuinely needed?

Make it deliberately: a major version, a migration guide, an overlap period where both versions are supported, and telemetry that shows who still uses the old one. If possible, provide an adapter or automated rewrite, such as an OpenRewrite recipe, so each team's cost is minutes, not days.

How do you know the governance is working?

Track the number of breaking incidents caused by library upgrades, the number of rejected releases that would have broken consumers, the time services take to adopt new library versions, and the count of deprecated methods still in use. If incidents fall and adoption speeds up, the rules are doing their job.

8Conclusion

In this answer, we used the JDK's use of default methods as a lens on API governance. The JDK shows that published interfaces are hard to change, so compatibility must be designed in. From it we took five rules for a company: decide what is public, separate called interfaces from implemented ones, make compatibility checks and semantic versioning required gates, keep APIs small, and remove deprecated methods using telemetry on real use rather than guesses.

What to say in the interviewAbout 80 seconds aloud

Open with

The main lesson I take from default methods is that the JDK needed a language feature just to add methods to Collection, which tells you how hard it is to change a widely implemented interface after the fact.

Then, if they want more

Even then, later additions like the sequenced collection methods in Java 21 caused clashes in some libraries. So inside a company I would design compatibility in rather than rely on rescue later. First, decide early what is public API and enforce it with packages or module exports. Second, separate interfaces that services call from interfaces they implement.

Adding a method is free for callers and expensive for implementers, so implemented interfaces get stricter rules: new capabilities as new small interfaces or real defaults, abstract methods only in a major version. Third, make japicmp or Revapi part of the shared build and fail minor releases with incompatible changes, so semantic versioning is enforced by a tool.

Fourth, keep APIs small, because every public method is a commitment. And fifth, plan removal like the JDK does with deprecation for removal, but use our advantage: we can scan our repositories and count run-time calls, so we remove a method when the data says nobody uses it, and we measure success by fewer upgrade incidents and faster adoption.

About this answer

Last updated
12 November 2026
Versions it names
Java 21, Java 8, Java 9
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "The JDK used default methods to evolve Collection without breaking a vast ecosystem....": https://scrivio-interview-library.netlify.app/java/interfaces-and-abstract-classes/1505798cc3/