Scrivio Interview library
LeadershipPrincipal5 min read · updated 12 November 2026

Spring Framework 7 adopts JSpecify null annotations across its APIs. How would you decide whether your organisation adopts null-checking tools across all Java code, and what is the long-term value?

I would decide with evidence: null dereferences are one of the most common causes of production failures in Java, and static checking catches them at build time, when they are cheapest to fix. JSpecify gives us a shared annotation standard across libraries, including Spring 7, so the investment does not lock us into one tool, and it improves Kotlin interop as a bonus. Because adoption costs engineering time, I would start with new modules and public APIs, spread gradually, and judge the long-term value by tracking null-related incidents and escaped defects before and after.

Why this question is asked

A decision to adopt null checking across all Java code touches every team, every build and every code review, so it is a strategy question rather than a tooling question. Spring Framework 7 adopting JSpecify makes the timing interesting: the most used framework in our codebase now declares nullness in a standard way, so the information our tools need is suddenly there. Interviewers ask this at the staff or principal level to see whether we can weigh a real cost against a real benefit, choose a rollout that does not stall delivery, and define how we will know whether it worked. In this answer, we will look at the size of the problem, what JSpecify changes, the cost of adoption, a rollout plan, and how to measure the long-term value.

1How Big Is the Null Problem for Us?

Before deciding, we look at our own data. In most Java organisations, NullPointerException is among the most frequent exception types in production logs, and a share of incidents trace back to a value that someone assumed could never be null: a missing optional field in an upstream response, a repository lookup that found nothing, a configuration value not set in one environment. We can measure this in a week by grouping error logs and incident reports by root cause.

Static checking moves the discovery of these bugs to the build. A null-checking tool reads nullness annotations and reports any place where a value that may be null is dereferenced or passed where null is not allowed. The bug costs a minute to fix while the developer is still in the code, instead of an incident, a rollback and a postmortem.

2What JSpecify Changes in the Decision

The old obstacle to null checking was fragmentation. JSR 305, JetBrains, Checker Framework, Android and Spring each had their own annotations with subtly different meanings, so a library annotated for one tool was opaque to another, and choosing a tool meant betting on its annotations. JSpecify is a standard agreed by those vendors, with precise semantics such as @NullMarked for non-null by default and @Nullable for exceptions.

So the bet becomes safer. Our annotations are portable between NullAway, IntelliJ IDEA and other checkers, and the libraries we use, starting with Spring Framework 7, describe their APIs in the same language. Kotlin teams benefit too: Java APIs that declare nullness appear in Kotlin as proper nullable or non-null types, which removes a common class of interop bugs.

3Weighing the Cost

Adoption is not free. Each package that is marked needs its nullness decisions made explicit, and existing code produces warnings that must be fixed or suppressed. From experience, a mature module may take a few days per 10,000 lines the first time, mostly spent on genuine questions such as whether a method can really return null. The build also gets slightly slower with Error Prone and NullAway, typically a modest percentage of compile time.

Against that, we put the incidents avoided and the faster reviews, since reviewers stop asking can this be null. The table summarises the trade, and it is the kind of table I would bring to the architecture board.

Null checking: cost against value
ItemCost or valueNotes
Marking existing codecost: days per large modulepays for itself on high-traffic code first
Build timecost: small compile overheadonly the compiler, no runtime effect
Learning curvecost: a few hours per developergenerics and arrays need care
Null incidentsvalue: fewer escaped defectsmeasure before and after
Kotlin interopvalue: real types instead of platform typesmatters if teams use Kotlin
Review effortvalue: nullness is explicitfewer questions in code review

4A Rollout That Does Not Stall Delivery

The rollout should start where value is highest and cost lowest. New modules are marked @NullMarked from day one, which costs almost nothing. Public APIs of shared libraries come next, because many teams depend on them and a wrong assumption there spreads widely. Then services with a history of null incidents. Legacy modules that rarely change can stay unmarked; the checker in a mode that only checks marked code leaves them alone.

Step throughRolling out null checking
  1. Add NullAway to the build templatechecks only @NullMarked code
  2. Mark all new modulesno legacy cost
  3. Mark shared library public APIshighest reach
  4. Does a service have null incidents?
    YesMark it nextNoMark it when it is next changed heavily
  5. Make NullAway an error for marked codeso marked code stays clean
  6. Review incident numbers each quartercontinue, adjust or stop

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

Notice that no step requires a freeze or a big migration. Each team adopts it in small pull requests alongside normal work, and the platform team owns the build configuration so nobody configures Error Prone by hand.

5Measuring the Long-Term Value

A strategy without a measure becomes a belief. We record a baseline before the rollout: the number of production incidents and escaped defects whose root cause was an unexpected null, and the count of NullPointerException occurrences per million requests from our error tracking. Each quarter we compare marked and unmarked code. If marked modules show clearly fewer null failures, we keep going and widen the scope; if the difference is small, we stop at public APIs and new code, where the cost is lowest.

The long-term value goes beyond incidents. Code with explicit nullness is easier to read, refactor and hand over, and the investment is durable because the annotations are a standard rather than a vendor's choice.

6Follow-up questions

Why not just use Optional and good tests instead?

Optional helps for return values, but it does not cover fields, parameters or generic type arguments, and it does nothing for the thousands of existing APIs that return null. Tests only find the null paths someone thought to test. A checker examines every path the compiler sees, so it finds the cases nobody imagined.

What if developers just suppress every warning?

That is a real risk, so we make suppressions visible: they need a short reason, and the number of suppressions per module is shown on the same dashboard as adoption. A rising count is a signal to help that team, not to blame it, since it usually means the code has genuinely unclear contracts.

Would you require it for every repository?

Not on day one. I would require it in the service template and for shared libraries, encourage it elsewhere, and decide on a wider requirement after a year of incident data. Mandating it everywhere before we have evidence tends to produce suppressions rather than safety.

7Conclusion

In this answer, we treated organisation-wide null checking as a strategic investment. Null failures are common and static checks catch them early and cheaply, while JSpecify, now used by Spring 7, gives a shared standard that reduces tool lock-in and improves Kotlin interop. Because adoption costs time, we start with new modules and public APIs, use a checker that only examines marked code, and judge the value by tracking null-related incidents before and after.

What to say in the interviewAbout 80 seconds aloud

Open with

I would decide with data rather than enthusiasm. First I would measure how much nulls hurt us today, by grouping incidents and production errors by root cause; in most Java shops NullPointerException is near the top.

Then, if they want more

Static checking with a tool like NullAway catches those at compile time, when a fix takes a minute instead of an incident. What makes the decision easier now is JSpecify.

It is a standard agreed between the tool vendors and libraries, Spring Framework 7 uses it across its APIs, so our annotations are portable between checkers and IDEs and we are not betting on one vendor. It also improves Kotlin interop, because Java APIs that declare nullness show up as real nullable or non-null types.

The cost is real: marking an existing module takes days, and builds get a little slower. So I would roll out gradually.

NullAway goes into the build template in a mode that checks only @NullMarked code, every new module is marked from the start, then shared library public APIs, then services with a history of null incidents, while stable legacy code can stay unmarked.

Each quarter I would compare null-related incidents in marked and unmarked code, and widen, keep or narrow the scope based on what that shows.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 7
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 "Spring Framework 7 adopts JSpecify null annotations across its APIs. How would you...": https://scrivio-interview-library.netlify.app/spring-boot/spring-framework-evolution/f5e03b4499/