Quick revision
The short answer
For published libraries, the public API must be something we design and review, not something a tool generates: generated constructors, builders and accessors can change with field order or with the Lombok version, and those changes are invisible in code review. So the rules are hand-written or delomboked public surfaces, explicit builders or static factories with stable method names, no exposed all-args constructors, binary compatibility checks such as japicmp or Revapi in CI on every release, and semantic versioning with deprecation periods. Lombok stays fine for internal code where all callers compile together.
What to remember
In this answer, we saw that Lombok-generated constructors, builders and accessors tie a published API to field order and tool versions, so customers saw NoSuchMethodError or silently swapped arguments after upgrades that looked harmless in review. The rules for published libraries are hand-written or delomboked public surfaces, explicit builders and factories instead of all-args constructors, japicmp or Revapi checks in CI on every release, semantic versioning with deprecation periods, and Lombok only behind the boundary where all callers compile together.
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.
For published libraries, the public API must be something we design and review, not something a tool generates: generated constructors, builders and accessors can change with field order or with the Lombok version, and those changes are invisible in code review. So the rules are hand-written or delomboked public surfaces, explicit builders or static factories with stable method names, no exposed all-args constructors, binary compatibility checks such as japicmp or Revapi in CI on every release, and semantic versioning with deprecation periods. Lombok stays fine for internal code where all callers compile together.
Why this question is asked
An SDK is a promise to customers: if they upgrade within a major version, their compiled code keeps working. Breaking that promise means their builds fail or, worse, their running applications throw NoSuchMethodError after a dependency update. Interviewers ask this design question at senior levels because it requires knowing the difference between source and binary compatibility and turning it into rules a whole company can follow. In this answer, we will recap binary compatibility, see how Lombok-generated code broke it, set rules for the public surface, add automated checks, and place it in a versioning policy.
1A Quick Recap of Binary Compatibility
Source compatibility means a customer's code still compiles against our new version. Binary compatibility means their already compiled code still links and runs against it, without recompiling. Java links method calls by exact signature: class name, method name, parameter types and return type. If any of those change, an old class file that calls the method fails at run time with NoSuchMethodError, even if the source would compile fine against the new version.
This matters for SDKs because customers often get our new version transitively, through another library, and never recompile the code that calls us.
2How Lombok-Generated Code Broke Customers
Lombok generates public API from field declarations. That couples the public surface to things nobody thinks of as API. The all-args constructor's parameters follow the order of the fields. If a developer reorders fields for readability or adds a field in the middle, the constructor's signature changes. When the types differ, old callers fail with NoSuchMethodError. When two adjacent fields have the same type, it is worse: the signature is identical, so nothing fails, but the arguments silently swap meaning.
| Generated by Lombok | What changes it | Effect on customers |
|---|---|---|
| All-args constructor | field order, added field | NoSuchMethodError, or swapped arguments |
| Builder methods | field rename, @Singular name | NoSuchMethodError on old builder calls |
| Getters and setters | field rename, boolean naming | missing methods, changed JSON names |
| Annotations on members | Lombok version, lombok.config | framework behaviour changes |
Tool upgrades cause breaks too. Lombok has changed generated output across versions; a well-known example is that Lombok 1.16.20 stopped adding @ConstructorProperties to generated constructors by default, which broke deserialisation for users who relied on it. Builder class names, @Singular method names and toBuilder() are also generated, and none of these changes appear in the diff a reviewer reads, because the source did not change.
3Rules for the Public Surface
The first rule is that the public API of a published library is written, or at least reviewed, as Java source. Either we write constructors, factories, builders and accessors by hand for public types, or we run delombok as part of the build and review and publish the expanded source, so the API we ship is the API we reviewed.
The second rule is about shapes that age well. We do not expose all-args constructors on public types; we expose static factories with names (Address.of(street, city, postalCode) is still positional, so for more than two or three fields, a builder is better) and explicit builders with stable method names, because builder calls name each value and adding a new optional field adds a method without changing existing ones. Value types are final, so customers cannot subclass and depend on internals.
It is more code, but it is code we own. Reordering fields inside the class now changes nothing customers can see.
4Automated Compatibility Checks in CI
Rules need a machine to enforce them, because humans cannot see generated changes. Tools such as japicmp and Revapi compare the compiled jar of the new release with the last published release and report every binary and source incompatible change: removed methods, changed signatures, changed class modifiers. We run them in CI on every pull request against the latest release, and the build fails on a breaking change unless the version is a new major version.
- Compile the release candidate
- Compare with last releasejapicmp or Revapi on the jars
- Breaking change found?YesIs this a new major version?NoPublish
- Is this a new major version?YesPublish with migration notesNoFail the build
4 steps in order. Play them, or step through them one at a time.
Notice that this also catches the Lombok upgrade case, because the check compares compiled output, not source. The swapped-argument case with identical types is the one thing it cannot see, which is another reason to avoid positional constructors in public APIs.
5Versioning, Deprecation, and Where Lombok Still Fits
The checks only mean something within a versioning policy. We follow semantic versioning: patch and minor releases are binary compatible, breaking changes only in major releases. Removals go through deprecation first: mark with @Deprecated(since = "2.4", forRemoval = true), keep it working for at least one minor release or a published period, document the replacement, and remove it in the next major version.
None of this means Lombok is banned. Inside services and internal libraries, where all callers are compiled together in the same build or monorepo, a changed constructor is a compile error we fix immediately. The rule is about the boundary: anything customers compile against is designed and checked by hand; everything behind it may use whatever makes us productive.
6Follow-up questions
Is delombok enough on its own?
It makes the generated API visible, which helps reviews, but it does not stop a field reorder from changing a constructor. It should be combined with the shape rules (no public all-args constructors) and the automated compatibility check.
What about records in a public API?
Records have the same issue: the canonical constructor and accessors follow the component list, so reordering components is a breaking change. Records are fine in public APIs if we treat the component list as frozen and check it with the same tools.
How do you handle a necessary breaking change?
We batch it into a major release, provide the new API alongside the old one in the previous minor release with deprecation, publish migration notes, and keep the old major version on security fixes for an agreed period.
7Conclusion
In this answer, we saw that Lombok-generated constructors, builders and accessors tie a published API to field order and tool versions, so customers saw NoSuchMethodError or silently swapped arguments after upgrades that looked harmless in review. The rules for published libraries are hand-written or delomboked public surfaces, explicit builders and factories instead of all-args constructors, japicmp or Revapi checks in CI on every release, semantic versioning with deprecation periods, and Lombok only behind the boundary where all callers compile together.
Open with
The core issue is binary compatibility. Java links calls by exact signature, so a customer's compiled code breaks with NoSuchMethodError if a constructor or method signature changes, even if their source would still compile.
Then, if they want more
Lombok generates public API from field declarations, so moving or adding a field changes the all-args constructor, and if two adjacent fields have the same type the arguments silently swap, which is worse than an error. Lombok upgrades have also changed generated output, for example 1.16.20 stopped adding @ConstructorProperties by default. And none of that appears in a source review.
So my rules for anything we publish: the public surface is designed as source, hand-written or delomboked and reviewed. No public all-args constructors; explicit builders with stable method names, or static factories for two or three arguments, and final value classes.
Every pull request runs japicmp or Revapi against the last release and fails on a binary-incompatible change unless it is a major version. We follow semantic versioning with deprecation periods, marking members forRemoval and removing them only in the next major release.
Lombok remains fine for internal code and services, where all callers compile together and a changed signature is just a compile error we fix immediately.
About this answer
- Last updated
- 12 November 2026
- 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 "Public SDKs your company ships to customers use Lombok-generated builders, and changes...": https://scrivio-interview-library.netlify.app/java/lombok/40359994e9/