From 8ecf1132b617721d9bf224191430fb31786b5f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20W=C3=B6gerer?= Date: Mon, 24 Mar 2025 16:33:48 +0100 Subject: [PATCH] Remove pointless parallel stream processing for classpath entries. Since we already execute all calls to NativeImageClassLoaderSupport.LoadClassHandler#handleClassFileName via the ForkJoinPool.commonPool(), the use of parallelStream() here does not further increase parallel execution and can be replaced with a simple forEach without increasing class initialization time. Additionally, avoiding parallelStream() fixes a deadlock that was observable when only one CPU core is available (parallel streams also use the commonPool() and this can lead to a deadlock with our own use on single core systems). --- .../com/oracle/svm/hosted/NativeImageClassLoaderSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java index ad037ff15cf2..51de70aee099 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageClassLoaderSupport.java @@ -817,7 +817,7 @@ private void run() { initModule(moduleReference, true); } - classpath().parallelStream().forEach(this::loadClassesFromPath); + classpath().forEach(this::loadClassesFromPath); } finally { scheduledExecutor.shutdown(); }