Skip ModuleFinder#ofSystem usage on native

gh-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 gh-29081.

Closes gh-29183
This commit is contained in:
Sébastien Deleuze 2022-09-21 15:52:37 +02:00
parent 39208eaccd
commit 23a58e6bab
1 changed files with 6 additions and 2 deletions

View File

@ -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<String> systemModuleNames = ModuleFinder.ofSystem().findAll().stream()
.map(moduleReference -> moduleReference.descriptor().name()).collect(Collectors.toSet());
private static final Set<String> 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}