Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

The JDK is known for long-term backward compatibility, using practices such as deprecation for removal, preview and incubator features, and strong encapsulation of internals. Which of these practices should guide your company's internal platform APIs over many years?

Most of them, adapted to our scale. We should treat compatibility as a feature, because every breaking change costs every consumer; deprecate for removal with long, announced lead times; release new APIs as preview or incubating first so feedback arrives before they are frozen; and encapsulate internals from the start, since the JDK's long struggle to retire sun.misc.Unsafe shows what exposed internals cost. We should prefer additive changes, align support windows with consumers' upgrade cycles, and measure usage so removals are based on data. The part we should not copy is the JDK's near-permanent compatibility, because our consumers are known and can be helped to migrate.

Why this question is asked

An internal platform API, whether it is a set of shared libraries, an event schema or a service contract, will outlive most of the teams that build on it. Over ten years it collects hundreds of consumers and every design mistake becomes expensive to fix. The JDK has faced this problem at the largest scale for almost thirty years, with millions of consumers it cannot even list, and has developed practices worth studying. Interviewers ask this to see whether we can learn from them without copying blindly. In this answer, we will recap the JDK's practices, then go through each one, what it costs, how it translates to an internal platform, and where our situation is different.

1A Quick Recap of How the JDK Evolves

The JDK evolves through JEPs, JDK Enhancement Proposals, and a release every six months, with a long-term support release every two years. A few practices stand out. New language features and APIs usually appear first as preview features, which must be switched on with --enable-preview and may still change, or as incubator modules, named jdk.incubator.something, which are explicitly temporary. Record classes and pattern matching, for example, went through previews before being finalised.

Old features are removed slowly. An API is first deprecated, then deprecated for removal with @Deprecated(forRemoval = true), which produces stronger compiler warnings, and only removed several releases later. The Security Manager, for instance, was deprecated for removal in Java 17 and permanently disabled in Java 24. Since Java 9 the module system has strongly encapsulated JDK internals, so code can no longer reach them by accident.

Step throughLifecycle of an API, JDK style
  1. Incubating or previewopt-in, may change, no compatibility promise
  2. Stablecompatible changes only; additions preferred
  3. Deprecatedstill works; replacement documented
  4. Deprecated for removalloud warnings, announced removal release
  5. Usage low enough?
    YesRemove in the announced releaseNoExtend the window, help remaining users

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

Each stage tells consumers how much they can rely on the API.

2Compatibility Is a Feature Consumers Depend On

The JDK's core belief is that code written against it should keep working, and that belief is the reason organisations dare to upgrade. For an internal platform, the same applies: teams build on the platform because they trust it will not break them. Each breaking change spends some of that trust, and its cost is paid by every consumer, not by the platform team.

So we treat compatibility explicitly as a product requirement, with numbers. If a change forces 200 services to spend half a day each, that is 100 engineer-days; the platform team should be able to state that cost and justify it, just as it would justify a new feature. That shifts design discussions from 'is the new API nicer?' to 'is it nicer enough to be worth 100 days of other teams' time?'

3Preview First, Freeze Later

Preview and incubator releases solve a hard problem: we only learn whether an API is right when people use it, but once people use it, we cannot change it. The JDK breaks the cycle by letting people use an API without a compatibility promise. Internally we can do the same. New APIs are marked experimental, for example with an @Incubating annotation, a separate artifact or an opt-in flag, used by two or three pilot teams, and changed freely based on their feedback. Only then are they declared stable.

The discipline lies in keeping the promise both ways. Experimental really must mean 'may change', so we do change it when needed, and stable really must mean 'will not break'. A platform that leaves APIs in an experimental state forever, or breaks stable ones casually, teaches teams to ignore both labels.

4Encapsulate Internals From the Start

sun.misc.Unsafe is the JDK's cautionary tale. It was an internal class, never meant for applications, but it was technically reachable, and it offered fast low-level memory access. Major libraries came to depend on it. Replacing it took many years: supported alternatives such as VarHandles in Java 9 and the Foreign Function and Memory API, finalised in Java 22, had to be built first, and only then could its memory-access methods be deprecated for removal, around Java 23, with runtime warnings following. Strong encapsulation through the module system, which became the default in Java 16 and 17, closed many other internals that libraries had reached into.

The lesson for a platform is cheap to apply on day one and very expensive to apply later: anything not deliberately public must be impossible, not just discouraged, to use. Export only API packages from modules, keep implementation classes package-private, enforce boundaries with ArchUnit where modules are not used, and for services, expose only documented endpoints and events, never a shared database table. Once a consumer depends on an internal, it is no longer internal.

5Additive Changes, Aligned Support Windows and Usage Data

The JDK grows mostly by addition: new methods, new classes, new overloads, while old ones keep working. Additive changes cost consumers nothing, so we prefer them. When something must change, we add the new form alongside the old and deprecate the old, rather than changing it in place.

The JDK also aligns its support with how users upgrade: most organisations move between LTS releases, so LTS versions get long support. An internal platform should do the same with its consumers' cycles, for example supporting the current and previous major version for at least two quarterly planning cycles, so no team is forced into an unplanned upgrade.

Finally, the JDK team studies how APIs are used, for example by scanning large bodies of open-source code, before deciding to remove something. Inside a company we can do far better, because we can see all our consumers. Dependency data and usage metrics tell us exactly which services still call a deprecated API, so removal becomes a decision based on data rather than a guess.

JDK practice and its internal equivalent
JDK practiceInternal platform equivalent
@Deprecated(forRemoval = true)same annotation, plus a removal date and a migration recipe
Preview features and incubator modules@Incubating APIs, separate artifacts, pilot teams
Strong encapsulation of internalsexported API packages only, ArchUnit rules, no shared tables
LTS releasessupport windows matched to consumers' planning cycles
Corpus analysis before removalexact per-service usage from dependency data and metrics

6Where We Should Not Copy the JDK

The JDK keeps some deprecated APIs for decades because it cannot know or contact its users. We can. Our consumers are a finite list of services with owners, and we can give them automated migrations, such as OpenRewrite recipes, and direct help. So our deprecation windows can be measured in months rather than years, and we can actually finish removals. Copying the JDK's extreme caution would leave us maintaining every mistake forever, which slows the platform down for everyone.

The balance I would aim for is the JDK's discipline with a shorter clock: the same stages and the same honesty about what is stable, but with data and tooling that let us move through the stages much faster.

7Follow-up questions

How do you stop teams from using an incubating API in critical production paths?

Make the opt-in explicit and visible, for example a separate artifact or a compiler warning, and track which services use it. Teams may use it, but they accept that it can change, and the platform team commits to notifying them and helping them migrate when it does. Visibility is more effective than a ban.

What if a consumer depends on an internal that was accidentally exposed?

Treat it like the JDK treated Unsafe, at a smaller scale: find out what the consumer needs, provide a supported API for that need, deprecate the accidental exposure with a timeline, and then close it. Removing it without an alternative just pushes the consumer to fork or copy the code.

Does this apply to service APIs and events as well as libraries?

Yes, often more so. A REST endpoint or an event schema has the same lifecycle: experimental versions for pilots, additive changes such as new optional fields, deprecation with a timeline, and removal based on measured traffic. Consumer-driven contract tests add a useful check that a change does not break any known consumer.

8Conclusion

In this answer, we looked at how the JDK evolves and which of its practices fit an internal platform over many years. Compatibility should be treated as a feature with a measurable cost, removal should go through deprecation for removal with long, announced lead times, new APIs should start as preview or incubating with pilot users, internals should be encapsulated from day one as the Unsafe story shows, changes should be additive with support windows matched to consumers' cycles, and removal should be driven by usage data. Because we know our consumers, we can move through these stages faster than the JDK.

What to say in the interviewAbout 90 seconds aloud

Open with

I would adopt almost all of them, but on a shorter clock. First, treat compatibility as a feature. Teams build on a platform because they trust it won't break them, and every breaking change costs every consumer, so I'd make that cost explicit, like 200 services times half a day, before approving one.

Then, if they want more

Second, deprecation for removal with announced lead times: the same @Deprecated with forRemoval, a removal date and a migration recipe. Third, preview and incubating releases. New APIs go to two or three pilot teams marked as incubating, we change them freely based on feedback, and only then declare them stable.

Fourth, and the most important to do early, encapsulate internals. sun.misc.Unsafe was never meant to be public, but because it was reachable, major libraries depended on it, and the JDK needed years and new APIs like VarHandles and the Foreign Function and Memory API before it could start removing it.

So I'd export only API packages, enforce boundaries with ArchUnit, and never let services share database tables. Fifth, prefer additive changes and keep support windows aligned with consumers' upgrade cycles. And sixth, measure usage, which we can do much better than the JDK because we can see every consumer through dependency data and metrics.

The one thing I wouldn't copy is keeping deprecated APIs for decades; since we know our consumers and can automate migrations, we can actually finish removals within months.

About this answer

Last updated
12 November 2026
Versions it names
Java 9, Java 16, Java 17, Java 22
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. 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 is known for long-term backward compatibility, using practices such as...": https://scrivio-interview-library.netlify.app/java/clean-code/1f906ae6d6/