Skip to content

Commit 0e3788b

Browse files
Zeaveeloicottet
authored andcommitted
Ensure the list of forbidden modules for layered images is always complete when accessed
1 parent 04b8dc3 commit 0e3788b

File tree

1 file changed

+5
-2
lines changed
  • substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted

1 file changed

+5
-2
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.util.concurrent.ConcurrentHashMap;
4444
import java.util.concurrent.ConcurrentMap;
4545
import java.util.concurrent.CopyOnWriteArrayList;
46+
import java.util.concurrent.atomic.AtomicBoolean;
4647
import java.util.function.BiPredicate;
4748
import java.util.function.BooleanSupplier;
4849
import java.util.function.Predicate;
@@ -265,7 +266,8 @@ public enum UsageKind {
265266
* Some modules contain native methods that should never be in the image, as they are either
266267
* hosted only, or currently unsupported in layered images.
267268
*/
268-
private final Set<Module> forbiddenModules = new HashSet<>();
269+
protected final Set<Module> forbiddenModules = new HashSet<>();
270+
protected final AtomicBoolean initializedForbiddenModules = new AtomicBoolean();
269271

270272
@SuppressWarnings("this-escape")
271273
public SVMHost(OptionValues options, ImageClassLoader loader, ClassInitializationSupport classInitializationSupport, AnnotationSubstitutionProcessor annotationSubstitutions,
@@ -1550,7 +1552,7 @@ public ConstantExpressionRegistry getConstantExpressionRegistry() {
15501552

15511553
@Override
15521554
public Set<Module> getForbiddenModules() {
1553-
if (forbiddenModules.isEmpty()) {
1555+
if (!initializedForbiddenModules.get()) {
15541556
forbiddenModules.add(JVMCI.class.getModule());
15551557
Class<?> llvm = ReflectionUtil.lookupClass(true, "com.oracle.svm.shadowed.org.bytedeco.llvm.global.LLVM");
15561558
if (llvm != null) {
@@ -1569,6 +1571,7 @@ public Set<Module> getForbiddenModules() {
15691571
forbiddenModules.add(libGraal.getModule());
15701572
}
15711573
}
1574+
initializedForbiddenModules.set(true);
15721575
return forbiddenModules;
15731576
}
15741577
}

0 commit comments

Comments
 (0)