Quick revision
The short answer
We treat a library that fills a gap in the language as temporary: once the standard feature is stable and our tools support it, it becomes the default for new code. We do not rewrite working code for fashion; we migrate when we touch the code anyway or when the old library creates real risk, and we make migration cheap with published recipes such as OpenRewrite. We track usage until the library can leave the platform BOM, and we apply the same thinking to Guava, Joda-Time and every similar library.
What to remember
In this answer, we saw that libraries such as Lombok, Guava and Joda-Time fill gaps that the language later closes, so we should treat them as temporary for those uses. We set the standard feature as the default for new code once it is stable and supported, migrate old code when we touch it or when the library creates real risk, make migration cheap with OpenRewrite recipes, and track usage until the library can leave the platform BOM. The same playbook applies to every library the JDK eventually replaces.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We treat a library that fills a gap in the language as temporary: once the standard feature is stable and our tools support it, it becomes the default for new code. We do not rewrite working code for fashion; we migrate when we touch the code anyway or when the old library creates real risk, and we make migration cheap with published recipes such as OpenRewrite. We track usage until the library can leave the platform BOM, and we apply the same thinking to Guava, Joda-Time and every similar library.
Why this question is asked
Every long-lived codebase collects libraries that were added to cover something the language could not do at the time: Joda-Time before java.time, Guava's Optional and immutable collections before Java 8 and 9, Lombok before records. Years later the language catches up, and the organisation has to decide what to do with thousands of files written the old way. Interviewers ask this at a senior level because the answer shows how we balance consistency, cost and risk across many teams. In this answer, we will look at why these libraries become temporary, decide when a migration is worth it, set defaults and recipes for teams, measure progress, and apply the same playbook beyond Lombok.
1Why Gap-Filling Libraries Are Temporary
Lombok, Guava and Joda-Time were good choices when they arrived. Each one solved a real problem the JDK did not: boilerplate for value classes, useful collection types, a date and time API that was not broken. But each also has a cost that grows over time. Lombok hooks into the compiler's internals, so every new JDK release must be supported by a new Lombok release before we can upgrade, and every IDE and static analysis tool needs a plugin to understand the generated code. Joda-Time is in maintenance mode, and its own authors point users to java.time.
Once the language offers an equivalent that is stable, which for records means final since Java 16, and supported by our frameworks, the library stops adding value for that use case and keeps only its cost. So the senior position is to expect this from the start: when we adopt a gap-filling library, we already assume that one day we will move off it for the parts the language covers.
2Deciding When a Migration Is Worth It
The tempting response is a big rewrite: convert every @Value class to a record this quarter. That is rarely a good use of the organisation's time. Working code that is rarely touched gains almost nothing from being converted, and each conversion carries some risk, as we see with accessor names changing from getName() to name() in templates and mappers.
Instead we migrate for one of two reasons. The first is that we are changing the code anyway: a team adding a field to a DTO converts that DTO at the same time, because it is already being reviewed and tested. The second is real risk. If Lombok blocks a JDK upgrade, if a library has an unpatched security issue, or if new hires increasingly do not know it, the cost of staying has become concrete and a planned migration is justified. Notice that both reasons are about the code and the business, not about what is fashionable.
- Is it new code?YesUse the standard feature by defaultNoCheck the next question
- Are we changing this code anyway?YesMigrate it in the same changeNoCheck the next question
- Does the library create real risk?YesPlan a targeted migrationNoLeave it; revisit at the next review
- Measure usage every quarterdecide when the library can leave the BOM
4 steps in order. Play them, or step through them one at a time.
New code follows the default; old code moves when touched or when the risk is real.
Lombok itself is a good example of mixed cases. Records replace @Value cleanly, but nothing in the language replaces @Getter and @Setter on JPA entities or @Builder for objects with many optional fields. So the realistic target is not zero Lombok; it is Lombok only where it still pays for itself.
3Setting Defaults and Publishing Recipes
Teams need a clear, written default, because otherwise each team debates the same question. A short engineering guideline can say: on Java 17 and later, new data carriers are records; Lombok is allowed for builders with many optional fields and for JPA entities; @Value is not used in new code. We back the guideline with automation, such as an ArchUnit test or a static analysis rule that flags new @Value classes in pull requests, so the default holds without a reviewer remembering it.
Then we make the migration cheap. OpenRewrite is a tool that applies automated, tested refactoring recipes to source code, and it has recipes for common Lombok and JDK migrations. A platform team can wrap the right recipes into one company recipe, run it on a pilot service, document what it cannot handle (templates, string expressions, inheritance), and publish a page explaining how to run it. A team that was going to spend two weeks converting by hand can now do it in an afternoon plus review.
4Tracking Usage and Retiring the Library
We cannot manage what we do not measure. A simple scheduled job that scans every repository and counts imports of lombok.Value, lombok.Builder, com.google.common and org.joda.time gives a trend line per team. When @Value usage drops from 4,000 classes to 300, and the remaining ones sit in two legacy services, we can see that removing it is close.
The platform BOM, the bill of materials that pins the versions of shared libraries for every service, is where a library's life ends. Keeping a library in the BOM is a promise that the platform team will keep it patched and compatible. Once usage is low enough, we announce a date, help the last teams move, and remove it from the BOM so new services cannot pick it up by accident.
| Library | Replaced by | What usually stays |
|---|---|---|
Lombok @Value | Records (Java 16) | @Builder, entity getters and setters |
| Joda-Time | java.time (Java 8) | Nothing; it is in maintenance mode |
| Guava Optional | java.util.Optional (Java 8) | Nothing |
| Guava immutable lists | List.of, List.copyOf (Java 9, 10) | ImmutableList as a documenting type |
| Guava cache | Caffeine (a library, not the JDK) | Nothing; Guava points to Caffeine |
Guava Multimap, RangeMap | No JDK equivalent | Keep using Guava |
5Applying It Beyond Lombok
The same thinking works for every library in the table. Joda-Time is the clearest case: java.time was designed by the same author, covers everything, and Joda-Time receives only maintenance, so new code uses java.time and old code moves when touched, with adapters at the boundaries. Guava is a mixed case: some parts are replaced by the JDK, some by other libraries such as Caffeine, and some, such as Multimap and RangeMap, have no replacement and remain good choices.
So the lesson is not about Lombok. It is a policy: watch each JDK release for features that cover what our libraries do, set the new default once the feature and our tools are ready, migrate on touch or on risk, provide recipes, and measure until the old library can go.
6Follow-up questions
What if teams resist the change because they like Lombok?
We separate taste from cost. Nobody is asked to rewrite working code, and Lombok stays where it still adds value. We only ask that new data carriers use records, and we explain the concrete reasons: JDK upgrades that waited for Lombok releases, tool plugins, and hiring. Teams accept a default much more easily when it does not create work for them.
How long should a library stay in the BOM after it is discouraged?
Until usage is low enough that the last users can be helped directly, which usually takes several release cycles. Removing it too early breaks builds and pushes teams into unplanned work; keeping it forever means patching it forever. A published end date, a few months ahead, gives everyone time to plan.
Who owns this kind of decision?
Usually a platform or architecture group proposes it, but it works best when respected engineers from product teams help write the guideline and try the recipes on their own services first. That way the default reflects real code, and teams hear it from peers.
7Conclusion
In this answer, we saw that libraries such as Lombok, Guava and Joda-Time fill gaps that the language later closes, so we should treat them as temporary for those uses. We set the standard feature as the default for new code once it is stable and supported, migrate old code when we touch it or when the library creates real risk, make migration cheap with OpenRewrite recipes, and track usage until the library can leave the platform BOM. The same playbook applies to every library the JDK eventually replaces.
Open with
I treat libraries that fill language gaps as temporary for those uses. Lombok's @Value was the right choice before records, but now records are final in the language, our frameworks support them, and Lombok adds a compiler plugin that every JDK upgrade and every tool has to support.
Then, if they want more
I would not rewrite working code for fashion, though. I would set a written default that new data carriers are records, back it with a static analysis rule, and keep Lombok where it still pays off, such as builders with many optional fields and JPA entities.
Existing code moves when a team changes it anyway, or when the library creates real risk, for example blocking a JDK upgrade. To make that cheap, the platform team would publish an OpenRewrite recipe, try it on a pilot service and document what it misses, like templates and inheritance.
I would track usage across repositories with a scheduled scan, and once it is low, announce a date and remove the library from the platform BOM. I would apply exactly the same policy to Joda-Time, which java.time replaces, and to the parts of Guava the JDK now covers.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 16, Java 17, Java 8
- 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 "Java added records, pattern matching and other features that cover much of what Lombok...": https://scrivio-interview-library.netlify.app/java/lombok/50a7ea0eee/