public interface Feature
Features have several advantages over static class initializers (which also run during native image generation):
access
parameter that allows callbacks into the native image
generator.
ImageSingletons
is already set up, which allows features
to prepare data structures that are then used at run time by querying the ImageSingletons
.
Implementation classes must have a no-argument constructor, which is used to instantiate a singleton instance for each feature using reflection. The following features are included during native image generation:
required
by another included feature.
Required features are added transitively, and initialization methods of required features are
called after invoking the constructor and Feature.isInConfiguration(org.graalvm.nativeimage.hosted.Feature.IsInConfigurationAccess)
of the requiring features
(unless the feature dependencies are cyclic).
Modifier and Type | Method and Description |
---|---|
default void |
afterAnalysis(Feature.AfterAnalysisAccess access)
Handler for initializations after analysis and before universe creation.
|
default void |
afterCompilation(Feature.AfterCompilationAccess access)
Handler for initializations after compilation, i.e., before the native image is written.
|
default void |
afterHeapLayout(Feature.AfterHeapLayoutAccess access)
Handler for initializations after the native image heap and code layout.
|
default void |
afterImageWrite(Feature.AfterImageWriteAccess access)
Handler for altering the image (or shared object) that the linker command produced.
|
default void |
afterRegistration(Feature.AfterRegistrationAccess access)
Handler for initializations after all features have been registered and all options have been
parsed; but before any initializations for the static analysis have happened.
|
default void |
beforeAnalysis(Feature.BeforeAnalysisAccess access)
Handler for initializations before the static analysis.
|
default void |
beforeCompilation(Feature.BeforeCompilationAccess access)
Handler for initializations before compilation.
|
default void |
beforeImageWrite(Feature.BeforeImageWriteAccess access)
Handler for altering the linker command after the native image has been built and before it
is written.
|
default void |
beforeUniverseBuilding(Feature.BeforeUniverseBuildingAccess access)
Handler for code that needs to run before universe building, but after hosted meta-access has
been created.
|
default void |
cleanup()
Handler for cleanup.
|
default void |
duringAnalysis(Feature.DuringAnalysisAccess access)
Handler for performing operations during the static analysis.
|
default void |
duringSetup(Feature.DuringSetupAccess access)
Handler for initializations at startup time.
|
default String |
getDescription()
A short description of the feature (e.g., "Enables Truffle support").
|
default List<Class<? extends Feature>> |
getRequiredFeatures()
Returns the list of features that this feature depends on.
|
default String |
getURL()
A URL to documentation or the sources of the feature.
|
default boolean |
isInConfiguration(Feature.IsInConfigurationAccess access)
This method is called immediately after the constructor, to check whether the feature is part
of the configuration or not.
|
default void |
onAnalysisExit(Feature.OnAnalysisExitAccess access)
Handler for code that needs to run after the analysis, even if an error has occurred, e.g.,
like reporting code.
|
default String getURL()
default String getDescription()
default boolean isInConfiguration(Feature.IsInConfigurationAccess access)
required features
are not processed).access
- The supported operations that the feature can perform at this timedefault List<Class<? extends Feature>> getRequiredFeatures()
default void afterRegistration(Feature.AfterRegistrationAccess access)
access
- The supported operations that the feature can perform at this timedefault void duringSetup(Feature.DuringSetupAccess access)
access
- The supported operations that the feature can perform at this timedefault void beforeAnalysis(Feature.BeforeAnalysisAccess access)
access
- The supported operations that the feature can perform at this timedefault void duringAnalysis(Feature.DuringAnalysisAccess access)
Feature.DuringAnalysisAccess.requireAnalysisIteration()
. This triggers a new iteration:
analysis is performed again and the handler is called again.access
- The supported operations that the feature can perform at this timedefault void afterAnalysis(Feature.AfterAnalysisAccess access)
access
- The supported operations that the feature can perform at this timedefault void onAnalysisExit(Feature.OnAnalysisExitAccess access)
access
- The supported operations that the feature can perform at this timedefault void beforeUniverseBuilding(Feature.BeforeUniverseBuildingAccess access)
access
- The supported operations that the feature can perform at this timedefault void beforeCompilation(Feature.BeforeCompilationAccess access)
access
- The supported operations that the feature can perform at this timedefault void afterCompilation(Feature.AfterCompilationAccess access)
access
- The supported operations that the feature can perform at this timedefault void afterHeapLayout(Feature.AfterHeapLayoutAccess access)
access
- The supported operations that the feature can perform at this timedefault void beforeImageWrite(Feature.BeforeImageWriteAccess access)
access
- The supported operations that the feature can perform at this time.default void afterImageWrite(Feature.AfterImageWriteAccess access)
access
- The supported operations that the feature can perform at this time.default void cleanup()
Usually, overriding this method can be avoided by putting a configuration object into the
ImageSingletons
.