On Tue, 9 Jan 2024 00:17:48 GMT, Mandy Chung <mch...@openjdk.org> wrote:

> One optimization of Jlink SystemModulesPlugin pre-resolves the module graph 
> for modules with a main class.  It stores the name of the initial module and 
> the generated `SystemModules` class name in two arrays that can be obtained 
> from `SystemModulesMap::moduleNames` and `SystemModulesMap::classNames`.   
> The elements in the array returned by `classNames()` are supposed to 
> correspond to the elements in the array returned by `moduleNames()`.    
> However, the implementation sorts both arrays by the value of the elements. 
> 
> This fix is simple and write the correct class names and not to sort the 
> values separately.

Looks good, surprising we didn't notice this before now but perhaps not too 
common to have several modules in the run-time image with a main class. I 
assume you'll bump the copyright header of SystemModulesPlugin before 
integrating.

test/jdk/tools/jlink/plugins/SystemModuleDescriptors/ModuleMainClassTest.java 
line 59:

> 57:     private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
> 58:     private static final Path MODS_DIR = Paths.get("mods");
> 59:     private static final Path JMODS_DIR = Paths.get("jmods");

In passing, these can use Path.of if you want.

test/jdk/tools/jlink/plugins/SystemModuleDescriptors/src/com.foo/module-info.java
 line 25:

> 23: 
> 24: module com.foo {
> 25:     requires jdk.httpserver;

This `requires` means the run-time image created by the test will have 3 
modules with main classes. It needs a minimum of 2 so this dependency is okay.

-------------

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17316#pullrequestreview-1810822187
PR Review Comment: https://git.openjdk.org/jdk/pull/17316#discussion_r1445883006
PR Review Comment: https://git.openjdk.org/jdk/pull/17316#discussion_r1445882416

Reply via email to