Table of Contents

Specify Class Initialization Explicitly

Two command line flags explicitly specify when a class should be initialized: --initialize-at-build-time and --initialize-at-run-time. You can use the flags to specify whole packages or individual classes. For example, if you have the classes p.C1, p.C2, … ,p.Cn, you can specify that all the classes in the package p are initialized at build time by passing the following argument to native-image on the command line:


If you want only one of the classes in package p to be initialized at runtime, use:


The whole class hierarchy can be initialized at build time by passing --initialize-at-build-time on the command line.

Class initialization can also be specified programmatically using RuntimeClassInitialization from the Native Image feature.