Home > Software design >  How JPMS decide root modules at runtime
How JPMS decide root modules at runtime

Time:06-07

I am new to java module system. I am trying to understand how JPMS decide the root modules to build the module graph at runtime.

What I understand is that all modules in the module path will be added to the set of root modules. JPMS start build the module graph from the root module set and add-modules option can add more modules to the root modules set. When build the module graph if there is a class not found in all modules then JPMS will search for it in the classpath, if it's found then this class will be add to unnamed module.

CodePudding user response:

The default root module set depends whether you your main class is located on the class path or the module path.

In any case, the modules on the module path are not automatically added to the set of root modules, unless you explicitly specify --add-modules ALL-MODULE-PATH.

If running from the classpath, most of the system modules are root modules. See JEP 261 for more details.

If running from the modulepath, only the module of the main application (as specified by --module is root by default. Others may be added with --add-modules.

  • Related