Quick revision
The short answer
CDI Lite, introduced in CDI 4.0 with Jakarta EE 10, is a subset of CDI designed so that bean discovery and wiring can be done at build time instead of at startup. Frameworks such as Quarkus do this because it cuts startup time and memory and makes native images possible, at the price of leaving out features such as portable extensions that change beans at runtime, which stay in CDI Full. Spring AOT follows a similar idea by generating bean definitions ahead of time.
What to remember
In this answer, we saw that CDI Lite is the subset of CDI from version 4.0 that a container can implement entirely at build time. Quarkus indexes classes, resolves injection points and generates bean and proxy classes during the build, which cuts startup time and memory and enables native images. Portable extensions and other dynamic features stay in CDI Full, and Spring AOT applies the same idea by generating bean definitions ahead of time, with the same trade-off that the bean set is fixed at build time.
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.
CDI Lite, introduced in CDI 4.0 with Jakarta EE 10, is a subset of CDI designed so that bean discovery and wiring can be done at build time instead of at startup. Frameworks such as Quarkus do this because it cuts startup time and memory and makes native images possible, at the price of leaving out features such as portable extensions that change beans at runtime, which stay in CDI Full. Spring AOT follows a similar idea by generating bean definitions ahead of time.
Why this question is asked
For most of its life, CDI did all its work when the application started: it scanned every class on the classpath, read annotations through reflection, built a model of beans and injection points, and let extensions modify that model on the fly. That worked on application servers that started once a month. It works poorly for containers that scale from zero in a second, or for GraalVM native images where reflection is restricted. Interviewers ask about CDI Lite because it shows whether we understand where the startup cost of a dependency injection container comes from and how modern frameworks remove it. In this answer, we will recap what a CDI container does at startup, see what CDI Lite keeps and drops, follow how Quarkus processes beans at build time, and compare it with Spring AOT.
1A Quick Recap of What a CDI Container Does at Startup
CDI, Contexts and Dependency Injection, is the Jakarta EE standard for creating beans and injecting them into each other. In CDI Full, the container starts by discovering beans: it scans the archives, loads classes and reads their annotations using reflection. Then it fires lifecycle events to portable extensions, plug-ins that may add, remove or change beans and annotations at this point. Next it validates the result, for example that every injection point has exactly one matching bean, and finally creates proxies and starts serving requests.
Every one of these steps happens on every start, and most give the same answer every time, because the classes in the application do not change between starts. Reflection also keeps a lot of metadata in memory. A large application server deployment could spend many seconds and hundreds of megabytes just on this model.
2What CDI Lite Keeps and What It Leaves Out
CDI 4.0 split the specification into CDI Lite and CDI Full. CDI Lite keeps what most applications use: @Inject, qualifiers, the application, request and dependent scopes, producer methods, events and observers, and interceptors bound with annotations. Bean discovery in Lite uses the annotated mode, so only classes with a bean-defining annotation such as @ApplicationScoped are beans.
It leaves out the features that need a fully dynamic runtime model. Portable extensions, which observe container events and can rewrite bean metadata while the application starts, are only in CDI Full. Lite replaces them with build compatible extensions, an API designed to run during the build. Decorators, specialization, the session and conversation scopes and passivation are also CDI Full features (check the specification for the exact list). The Jakarta EE Core Profile, aimed at small cloud services, requires only CDI Lite.
| Feature | CDI Lite | CDI Full |
|---|---|---|
@Inject, qualifiers, producers | Yes | Yes |
@ApplicationScoped, @RequestScoped | Yes | Yes |
| Events and observers | Yes | Yes |
| Interceptors via bindings | Yes | Yes |
| Build compatible extensions | Yes | Yes |
| Portable extensions | No | Yes |
| Decorators, specialization | No | Yes |
@SessionScoped, @ConversationScoped | No | Yes |
3How Quarkus Processes CDI at Build Time
Quarkus implements CDI through its own container, ArC, which targets CDI Lite plus some extras. During the Maven or Gradle build, Quarkus indexes all classes with Jandex, a fast bytecode indexer, instead of loading them with reflection. It resolves every injection point, checks for ambiguous or missing beans, and fails the build if the wiring is wrong. Then it generates plain Java classes: a bean class for each bean that knows how to create it and inject its dependencies with direct constructor and field calls, and client proxy classes for normal scopes. At runtime the application just runs these generated classes.
The reason this helps is that the expensive work is done once, by the build, instead of on every start. No class scanning, no reflection over annotations, no dynamic proxy generation at runtime. Startup drops from seconds to tens of milliseconds for a typical service, and the memory that held the reflective model is never used.
- Compile sourcesjavac produces classes
- Index classesJandex reads bytecode, no reflection
- Resolve beansMatch every
@Inject; fail build if ambiguous - Generate codeBean factories and client proxies as classes
- PackageJVM jar or GraalVM native image
- StartRun generated code; no scanning
6 steps in order. Play them, or step through them one at a time.
The expensive steps move from every start to one build.
4Why Build Time Matters for Native Images
GraalVM native image compiles a Java application ahead of time into a standalone executable. It works under a closed-world assumption: it must know at build time every class, method and field that the program may reach. Reflection, dynamic class loading and runtime proxy generation all break that assumption unless they are declared in configuration files.
A traditional CDI container depends on exactly those features. A container that wires everything at build time and generates normal classes fits the closed world naturally. That is why CDI Lite matters: it defines a portable subset that a build-time container can implement, and why portable extensions, which rewrite beans at runtime, could not be part of it. A Quarkus service compiled to a native image commonly starts in tens of milliseconds and uses a fraction of the JVM's memory.
5Spring AOT Follows a Similar Idea
Spring Framework 6 introduced ahead-of-time (AOT) processing. During the build, Spring starts the application context in a special mode, evaluates configuration classes and conditions, and generates Java source that registers each bean definition directly, plus hints that tell GraalVM which classes need reflection. At runtime Spring loads these generated definitions instead of scanning and parsing configuration.
But there is a trade-off, the same one CDI Lite makes. Because conditions are evaluated at build time, the bean set is fixed: a profile or @ConditionalOnProperty that would change which beans exist cannot change at runtime in an AOT-processed application. Spring keeps the regular runtime model as the default on the JVM and uses AOT mainly for native images, while Quarkus does build-time wiring in every mode.
6Follow-up questions
Can an existing CDI Full extension run on Quarkus?
Not directly. Portable extensions rely on runtime container events. Quarkus offers its own build-time extension model, and CDI 4 defines build compatible extensions as the portable replacement, so an extension usually has to be rewritten for build-time processing.
Does build-time processing make applications less flexible?
Somewhat. Anything decided at build time, such as which beans exist, cannot change through runtime configuration. Values like URLs and pool sizes can still come from configuration at runtime. For most services this is an acceptable trade, since the bean graph rarely needs to change after deployment.
Is CDI Lite only for Quarkus?
No. It is part of the Jakarta EE specification and the Core Profile, so any runtime can implement it. Weld, the reference implementation, supports both Lite and Full, while build-time oriented runtimes such as Quarkus and Helidon benefit most from the Lite subset.
7Conclusion
In this answer, we saw that CDI Lite is the subset of CDI from version 4.0 that a container can implement entirely at build time. Quarkus indexes classes, resolves injection points and generates bean and proxy classes during the build, which cuts startup time and memory and enables native images. Portable extensions and other dynamic features stay in CDI Full, and Spring AOT applies the same idea by generating bean definitions ahead of time, with the same trade-off that the bean set is fixed at build time.
Open with
CDI Lite came with CDI 4.0 in Jakarta EE 10. It is a subset of CDI chosen so that all the bean discovery and wiring can happen at build time instead of at startup.
Then, if they want more
A classic CDI container scans the classpath at every start, reads annotations by reflection, lets portable extensions modify beans, validates the injection points and generates proxies. That costs seconds and memory and does not fit GraalVM native images, which need to know everything at build time.
So Lite keeps the common features, @Inject, qualifiers, application and request scopes, producers, events and interceptors, and leaves out things that need a dynamic runtime, mainly portable extensions, plus decorators, specialization and session and conversation scopes, which stay in CDI Full. Lite has build compatible extensions instead.
Quarkus's container, ArC, indexes classes with Jandex during the build, resolves every injection point, fails the build if something is ambiguous, and generates plain classes for bean creation and client proxies. At runtime there is no scanning, so startup is very fast and memory is lower, and native images work.
Spring AOT has the same idea: it generates bean definition code during the build, with the trade-off that conditions and profiles are fixed at build time.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Jakarta EE 10, Spring Framework 6
- 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.
- Official documentation
- Jakarta EE specifications
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 "What is CDI Lite, and why do frameworks such as Quarkus process CDI at build time?": https://scrivio-interview-library.netlify.app/java/jakarta-ee-platform/e66b289fbf/