substratevm/docs/module-system/ModuleSystemSupportRuntime.md
The core of the runtime module system support consists of a set of substitutions and a feature (com.oracle.svm.hosted.ModuleLayerFeature) that provides runtime module-graphs.
The purpose of the runtime module support:
Module and ModuleLayer instances at runtimecom.oracle.svm.core.jdk.Target_java_lang_Module:
addReads0(), addExports0(), etc - module graph modificationsdefineModule0() - crucial for dynamic module supportcom.oracle.svm.core.jdk.Target_java_lang_ModuleLayer:
boot() - replaces the hosted boot module layer with our ownSome data structures also need to be substituted/reset as to not pull in hosted modules (see runtime module synthesizing):
com.oracle.svm.core.jdk.Target_java_lang_Module_ReflectionDataSynthesizes the runtime boot module layer and all reachable module layers initialized at image-build time. It also replicates build-time module relations at runtime (i.e., reads, opens and exports).
Why don't we reuse build-time modules/layers?
Synthesizing runtime module layers and modules (com.oracle.svm.hosted.ModuleLayerFeature#afterAnalysis):
Calculating root modules – done in the same way as in jdk.internal.module.ModuleBootstrap#boot2, for compatibility.
Substitution for ModuleLayer#boot2 returns the synthesized boot module layer from the com.oracle.svm.core.jdk.RuntimeModuleSupport
An object replacer makes sure that hosted module instances are replaced with their runtime counterparts.
mx hellomodule - smoke testvm-enterprise/tests/native-image/module-graph - test compatibility and correctness of the runtime module graph