diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java index 19417c1f40..47e14aba1d 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java @@ -48,6 +48,7 @@ import java.util.zip.ZipException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.NativeDetector; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; @@ -191,6 +192,7 @@ import org.springframework.util.StringUtils; * @author Costin Leau * @author Phillip Webb * @author Sam Brannen + * @author Sebastien Deleuze * @since 1.0.2 * @see #CLASSPATH_ALL_URL_PREFIX * @see org.springframework.util.AntPathMatcher @@ -206,8 +208,10 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol * @since 6.0 * @see #isNotSystemModule */ - private static final Set systemModuleNames = ModuleFinder.ofSystem().findAll().stream() - .map(moduleReference -> moduleReference.descriptor().name()).collect(Collectors.toSet()); + private static final Set systemModuleNames = NativeDetector.inNativeImage() ? Collections.emptySet() : + ModuleFinder.ofSystem().findAll().stream() + .map(moduleReference -> moduleReference.descriptor().name()) + .collect(Collectors.toSet()); /** * {@link Predicate} that tests whether the supplied {@link ResolvedModule}