[jigsaw] Rules for modules added by the JVM

ioi.lam at oracle.com ioi.lam at oracle.com
Fri Dec 13 05:52:28 UTC 2024


I have some questions regarding an RFE that I filed about adding some 
modules
when CDS is enabled [1].

 From https://openjdk.org/jeps/261

     It is occasionally necessary to add modules to the default root set
     in order to ensure that specific platform, library, or service-provider
     modules will be present in the resulting module graph. In any phase 
the option

         --add-modules <module>(,<module>)*

     where <module> is a module name, adds the indicated modules to the 
default
     set of root modules.

I am not sure if this language governs the current behavior of HotSpot, 
where
modules are added when certain JVM flags are specified. For example, when
-XX:+StartFlightRecording is specified, the jdk.jfr module is added [2]

     if (status && (FlightRecorderOptions || StartFlightRecording)) {
       if (!create_numbered_module_property("jdk.module.addmods",
                                            "jdk.jfr", _addmods_count++)) {
         return false;
       }
     }

What are the rules for the JVM to decide whether it can add a certain module
or not?

For a compatibility/behavioral perspective, it seems that in the case of 
JFR, the
decision by the JVM to add "jdk.jfr" hasn't been a problem. Otherwise it 
would
be pretty surprising to see application starting failing once JFR is used.

As far as I can guess, the reasons against adding unneeded modules are:

- start up performance: time spent to load the information for the extra 
modules
- runtime memory footprint
- unnecessary exposure of the APIs (apps could latch onto APIs exposed 
by JFR, and
   will break when jdk.jfr is changed or removed in the future)

What other reasons are there?

[1] https://bugs.openjdk.org/browse/JDK-8345969
[2] 
https://github.com/openjdk/jdk/blob/09c29d1d4274d9c36e1af98f02e6fc5b3f35133f/src/hotspot/share/runtime/arguments.cpp#L1807-L1810


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20241212/3f3d5306/attachment.htm>


More information about the jigsaw-dev mailing list