On Wed, 4 Oct 2023 15:59:54 GMT, Calvin Cheung <[email protected]> wrote:
>> src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java line
>> 239:
>>
>>> 237: // only consider modules from JDK
>>> 238: (mainModule.startsWith("jdk.") ||
>>> mainModule.startsWith("java."))) {
>>> 239: canArchive = true;
>>
>> This will require discussion as there may be modules in the run-time image
>> that start with other names.
>
> It would be nice if there's another way to find out if a module is from JDK.
When a named module is created, we know its location, which is also passed to
the C code and stored inside the C++ `ModuleEntry` data structure.
https://github.com/openjdk/jdk/blob/a1c9587c27538bda3b0f6745d9c80ff4e1b9a77e/src/java.base/share/classes/java/lang/Module.java#L128-L150
Maybe we can add a new native method
`jdk.internal.misc.CDS.isBuiltinModule(Module m)` which tests if
`ModuleEntry::_location` starts with `"jrt:"`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16016#discussion_r1347681387