Skip to content

Commit d9131d2

Browse files
committed
[GR-32505] Make NativeImageClassLoaderSupport#initAllClasses take jdk.module.upgrade.path into account.
PullRequest: graal/9302
2 parents 83aa8e9 + 1b482ba commit d9131d2

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

substratevm/ci_includes/gate.hocon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ builds += [
5757
timelimit: "45:00"
5858
environment : {
5959
MAVEN_REPO_LOCAL : "$BUILD_DIR/.m2"
60+
MX_BUILD_EXPLODED : "true"
6061
}
6162
run: [
6263
${svm-cmd-gate} ["style,fullbuild,helloworld,test,svmjunit,maven"]

substratevm/src/com.oracle.svm.hosted.jdk11/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,41 @@ public ClassLoader getClassLoader() {
248248
return classLoader;
249249
}
250250

251+
private static ModuleFinder upgradeAndSystemModuleFinder;
252+
253+
/**
254+
* Creates a finder from a module path specified by the {@code prop} system property.
255+
*/
256+
private static ModuleFinder finderFor(String prop) {
257+
String s = System.getProperty(prop);
258+
if (s == null || s.isEmpty()) {
259+
return null;
260+
} else {
261+
String[] dirs = s.split(File.pathSeparator);
262+
Path[] paths = new Path[dirs.length];
263+
int i = 0;
264+
for (String dir : dirs) {
265+
paths[i++] = Path.of(dir);
266+
}
267+
return ModuleFinder.of(paths);
268+
}
269+
}
270+
271+
/**
272+
* Gets a finder that locates the upgrade modules and the system modules, in that order.
273+
*/
274+
private static ModuleFinder getUpgradeAndSystemModuleFinder() {
275+
if (upgradeAndSystemModuleFinder == null) {
276+
ModuleFinder finder = ModuleFinder.ofSystem();
277+
ModuleFinder upgradeModulePath = finderFor("jdk.module.upgrade.path");
278+
if (upgradeModulePath != null) {
279+
finder = ModuleFinder.compose(upgradeModulePath, finder);
280+
}
281+
upgradeAndSystemModuleFinder = finder;
282+
}
283+
return upgradeAndSystemModuleFinder;
284+
}
285+
251286
private class ClassInitWithModules extends ClassInit {
252287

253288
ClassInitWithModules(ForkJoinPool executor, ImageClassLoader imageClassLoader) {
@@ -260,7 +295,7 @@ protected void init() {
260295
"jdk.internal.vm.ci", "jdk.internal.vm.compiler", "com.oracle.graal.graal_enterprise",
261296
"org.graalvm.sdk", "org.graalvm.truffle");
262297

263-
for (ModuleReference moduleReference : ModuleFinder.ofSystem().findAll()) {
298+
for (ModuleReference moduleReference : getUpgradeAndSystemModuleFinder().findAll()) {
264299
if (requiresInit.contains(moduleReference.descriptor().name())) {
265300
initModule(moduleReference);
266301
}

0 commit comments

Comments
 (0)