Skip to content

Commit 38ce936

Browse files
committed
Add upgrade-module-path to the list-modules invocation
1 parent 22974bd commit 38ce936

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ private int completeImageBuild() {
12501250

12511251
List<String> finalImageBuilderJavaArgs = Stream.concat(config.getBuilderJavaArgs().stream(), imageBuilderJavaArgs.stream()).collect(Collectors.toList());
12521252
try {
1253-
return buildImage(finalImageBuilderJavaArgs, imageBuilderClasspath, imageBuilderModulePath, imageBuilderArgs, finalImageClasspath, finalImageModulePath);
1253+
return buildImage(finalImageBuilderJavaArgs, imageBuilderClasspath, imageBuilderModulePath, imageBuilderArgs, finalImageClasspath, finalImageModulePath, upgradeModulePath);
12541254
} finally {
12551255
if (useColorfulOutput) {
12561256
performANSIReset();
@@ -1476,7 +1476,7 @@ protected static String createImageBuilderArgumentFile(List<String> imageBuilder
14761476
}
14771477

14781478
protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHashSet<Path> mp, ArrayList<String> imageArgs, LinkedHashSet<Path> imagecp,
1479-
LinkedHashSet<Path> imagemp) {
1479+
LinkedHashSet<Path> imagemp, String upgradeModulePath) {
14801480
List<String> arguments = new ArrayList<>();
14811481
arguments.addAll(javaArgs);
14821482

@@ -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, Stream.concat(mp.stream(), imagemp.stream()).distinct().toList(), upgradeModulePath);
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, String)
16341634
*/
1635-
private Map<String, Path> listModulesFromPath(String javaExecutable, Collection<Path> modulePath) {
1635+
private Map<String, Path> listModulesFromPath(String javaExecutable, Collection<Path> modulePath, String upgradeModulePath) {
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, List.of("-p", modulePathEntries), upgradeModulePath);
16431643
}
16441644

16451645
/**
@@ -1650,13 +1650,19 @@ 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> arguments, String upgradeModulePath) {
16541654
Process listModulesProcess = null;
16551655
Map<String, Path> result = new LinkedHashMap<>();
16561656
try {
16571657
var pb = new ProcessBuilder(javaExecutable);
16581658
pb.command().addAll(arguments);
16591659
pb.command().add("--list-modules");
1660+
if (!upgradeModulePath.isEmpty()) {
1661+
// non jlinked JDK need the jdk.internal.vm.compiler (graal.jar) in the
1662+
// upgrade-module-path directive
1663+
pb.command().add("--upgrade-module-path");
1664+
pb.command().add(upgradeModulePath);
1665+
}
16601666
pb.environment().clear();
16611667
listModulesProcess = pb.start();
16621668

0 commit comments

Comments
 (0)