Java / Lombok Interview questions
Describe how Lombok works under the hood (annotation processing)?
Lombok hooks into the Java compilation process as an annotation processor, a standard extension
point the javac compiler supports for running code during compilation that can inspect and modify
the program being compiled. Unlike most annotation processors, which are restricted to only generating new,
separate source files, Lombok uses (officially unsupported, internal) compiler APIs to directly modify the
in-memory abstract syntax tree (AST) of the class being compiled.
flowchart LR
A[Source .java file with annotations] --> B[javac parses to AST]
B --> C[Lombok annotation processor runs, modifies AST in place]
C --> D[javac continues compiling the modified AST]
D --> E[Generated .class bytecode includes Lombok's additions]
This is why Lombok can add whole new methods to an existing class (something standard annotation processors can't do) — it directly edits the parsed representation of your class before the compiler finishes turning it into bytecode, rather than generating a separate file alongside it.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
