Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdi-dev] This is StillDI

So, there are 2 "builds" at play when we talk about native image compilation: first, we compile Java source code (producing bytecode), and second, we compile bytecode (producing a native binary). During source code compilation [1], we run bean discovery (including extensions). But during native image compilation, thanks to native image's capacity to snapshot the Java heap, we can actually execute some initialization code [2]. This is when we boot the CDI container, create the application context and fire the `@Initialized(ApplicationScoped.class) Object` event.
 
[1] Actually during subsequent bytecode manipulation in our (Quarkus) case, but the Micronaut folks actually do it during source code compilation, as they use annotation processors.
[2] Specifically, we can run static initializers. See also https://www.graalvm.org/reference-manual/native-image/ClassInitialization/.
 
I think this should be an implementation detail, and I think it's a valid implementation strategy. But it also means that application context initialization no longer coincides with application startup.
 
Makes sense?
Ah! Yes, that was really helpful, thank you.
 
Andrew
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Back to the top