@@ -1503,7 +1503,7 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
15031503 Function <Path , Path > substituteModulePath = useBundle () ? bundleSupport ::substituteModulePath : Function .identity ();
15041504 List <Path > substitutedImageModulePath = imagemp .stream ().map (substituteModulePath ).toList ();
15051505
1506- Map <String , Path > modules = listModulesFromPath (javaExecutable , Stream .concat (mp .stream (), imagemp .stream ()).distinct ().toList ());
1506+ Map <String , Path > modules = listModulesFromPath (javaExecutable , javaArgs , Stream .concat (mp .stream (), imagemp .stream ()).distinct ().toList ());
15071507 if (!addModules .isEmpty ()) {
15081508
15091509 arguments .add ("-D" + ModuleSupport .PROPERTY_IMAGE_EXPLICITLY_ADDED_MODULES + "=" +
@@ -1630,16 +1630,16 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
16301630 /**
16311631 * Resolves and lists all modules given a module path.
16321632 *
1633- * @see #callListModules(String, List)
1633+ * @see #callListModules(String, List, List )
16341634 */
1635- private Map <String , Path > listModulesFromPath (String javaExecutable , Collection <Path > modulePath ) {
1635+ private Map <String , Path > listModulesFromPath (String javaExecutable , List < String > javaArgs , List <Path > modulePath ) {
16361636 if (modulePath .isEmpty () || !config .modulePathBuild ) {
16371637 return Map .of ();
16381638 }
16391639 String modulePathEntries = modulePath .stream ()
16401640 .map (Path ::toString )
16411641 .collect (Collectors .joining (File .pathSeparator ));
1642- return callListModules (javaExecutable , List .of ("-p" , modulePathEntries ));
1642+ return callListModules (javaExecutable , javaArgs , List .of ("-p" , modulePathEntries ));
16431643 }
16441644
16451645 /**
@@ -1650,11 +1650,12 @@ private Map<String, Path> listModulesFromPath(String javaExecutable, Collection<
16501650 * <p>
16511651 * This is a much more robust solution then trying to parse the JDK file structure manually.
16521652 */
1653- private static Map <String , Path > callListModules (String javaExecutable , List <String > arguments ) {
1653+ private static Map <String , Path > callListModules (String javaExecutable , List <String > javaArgs , List < String > arguments ) {
16541654 Process listModulesProcess = null ;
16551655 Map <String , Path > result = new LinkedHashMap <>();
16561656 try {
16571657 var pb = new ProcessBuilder (javaExecutable );
1658+ pb .command ().addAll (javaArgs );
16581659 pb .command ().addAll (arguments );
16591660 pb .command ().add ("--list-modules" );
16601661 pb .environment ().clear ();
0 commit comments