Skip to content

Commit 23a58e6

Browse files
committed
Skip ModuleFinder#ofSystem usage on native
spring-projectsgh-28506 introduces a big footprint regression on native, so it should for now be skipped when compiling to native images. Such support could potentially be re-introduced via spring-projectsgh-29081. Closes spring-projectsgh-29183
1 parent 39208ea commit 23a58e6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.apache.commons.logging.Log;
4949
import org.apache.commons.logging.LogFactory;
5050

51+
import org.springframework.core.NativeDetector;
5152
import org.springframework.core.io.DefaultResourceLoader;
5253
import org.springframework.core.io.FileSystemResource;
5354
import org.springframework.core.io.Resource;
@@ -191,6 +192,7 @@
191192
* @author Costin Leau
192193
* @author Phillip Webb
193194
* @author Sam Brannen
195+
* @author Sebastien Deleuze
194196
* @since 1.0.2
195197
* @see #CLASSPATH_ALL_URL_PREFIX
196198
* @see org.springframework.util.AntPathMatcher
@@ -206,8 +208,10 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
206208
* @since 6.0
207209
* @see #isNotSystemModule
208210
*/
209-
private static final Set<String> systemModuleNames = ModuleFinder.ofSystem().findAll().stream()
210-
.map(moduleReference -> moduleReference.descriptor().name()).collect(Collectors.toSet());
211+
private static final Set<String> systemModuleNames = NativeDetector.inNativeImage() ? Collections.emptySet() :
212+
ModuleFinder.ofSystem().findAll().stream()
213+
.map(moduleReference -> moduleReference.descriptor().name())
214+
.collect(Collectors.toSet());
211215

212216
/**
213217
* {@link Predicate} that tests whether the supplied {@link ResolvedModule}

0 commit comments

Comments
 (0)