From 1053d9a067ab4db4e11dd65c038c171dbad30fcc Mon Sep 17 00:00:00 2001 From: Ivan Ristovic Date: Fri, 22 Nov 2024 13:28:22 +0100 Subject: [PATCH 1/2] Clear runtime module mappings after prototype boot layer is synthesized --- .../src/com/oracle/svm/hosted/ModuleLayerFeature.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java index d42553a6112f..6c1d8a483e47 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java @@ -195,6 +195,10 @@ private void scanRuntimeBootLayerPrototype(BeforeAnalysisAccessImpl accessImpl) ModuleLayer runtimeBootLayer = synthesizeRuntimeModuleLayer(new ArrayList<>(List.of(ModuleLayer.empty())), accessImpl, accessImpl.imageClassLoader, baseModules, Set.of(), clf, null); /* Only scan the value if module support is enabled and bootLayer field is reachable. */ accessImpl.registerReachabilityHandler((a) -> accessImpl.rescanObject(runtimeBootLayer), ReflectionUtil.lookupField(RuntimeModuleSupport.class, "bootLayer")); + /* + * Reset the runtime module table for the proper boot module layer synthesis after analysis. + */ + moduleLayerFeatureUtils.resetRuntimeModuleTable(); } @Override @@ -797,6 +801,12 @@ public Module getRuntimeModuleForHostedModule(ClassLoader loader, String hostedM } } + public void resetRuntimeModuleTable() { + synchronized (runtimeModules) { + runtimeModules.clear(); + } + } + public Module getOrCreateRuntimeModuleForHostedModule(Module hostedModule) { /* * Special module instances such as ALL_UNNAMED and EVERYONE_MODULE are not replicated From e5790a206dad198cefbed412be6ca47655ae349f Mon Sep 17 00:00:00 2001 From: Ivan Ristovic Date: Tue, 26 Nov 2024 19:03:42 +0100 Subject: [PATCH 2/2] Experiment: filter CLVs --- .../com/oracle/svm/core/jdk/JavaLangSubstitutions.java | 7 ++++--- .../src/com/oracle/svm/hosted/ModuleLayerFeature.java | 10 ---------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java index 7f5466dd8213..8a871e8ea110 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java @@ -726,9 +726,10 @@ public Object transform(Object receiver, Object originalValue) { } ConcurrentHashMap original = (ConcurrentHashMap) originalValue; - List> clvs = Arrays.asList( - ReflectionUtil.readField(ServicesCatalog.class, "CLV", null), - ReflectionUtil.readField(ModuleLayer.class, "CLV", null)); + + ClassLoaderValue x = ReflectionUtil.readField(ServicesCatalog.class, "CLV", null); + List> clvs = Arrays.asList(x); +// ReflectionUtil.readField(ModuleLayer.class, "CLV", null)); var res = new ConcurrentHashMap<>(); for (ClassLoaderValue clv : clvs) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java index 6c1d8a483e47..d42553a6112f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java @@ -195,10 +195,6 @@ private void scanRuntimeBootLayerPrototype(BeforeAnalysisAccessImpl accessImpl) ModuleLayer runtimeBootLayer = synthesizeRuntimeModuleLayer(new ArrayList<>(List.of(ModuleLayer.empty())), accessImpl, accessImpl.imageClassLoader, baseModules, Set.of(), clf, null); /* Only scan the value if module support is enabled and bootLayer field is reachable. */ accessImpl.registerReachabilityHandler((a) -> accessImpl.rescanObject(runtimeBootLayer), ReflectionUtil.lookupField(RuntimeModuleSupport.class, "bootLayer")); - /* - * Reset the runtime module table for the proper boot module layer synthesis after analysis. - */ - moduleLayerFeatureUtils.resetRuntimeModuleTable(); } @Override @@ -801,12 +797,6 @@ public Module getRuntimeModuleForHostedModule(ClassLoader loader, String hostedM } } - public void resetRuntimeModuleTable() { - synchronized (runtimeModules) { - runtimeModules.clear(); - } - } - public Module getOrCreateRuntimeModuleForHostedModule(Module hostedModule) { /* * Special module instances such as ALL_UNNAMED and EVERYONE_MODULE are not replicated