Merge branch '4.0.x' into 4.1.x

Closes gh-51104
This commit is contained in:
Stéphane Nicoll
2026-07-23 12:25:25 +02:00
2 changed files with 7 additions and 7 deletions
@@ -29,7 +29,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.function.UnaryOperator;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
@@ -123,16 +123,16 @@ final class ClassPath {
/**
* Factory method to create a {@link ClassPath} of the given URLs.
* @param getSystemProperty {@link UnaryOperator} allowing access to system properties
* @param getSystemProperty {@link Function} allowing access to system properties
* @param urls the class path URLs
* @return a new {@link ClassPath} instance
*/
static ClassPath of(UnaryOperator<@Nullable String> getSystemProperty, List<URL> urls) {
static ClassPath of(Function<String, @Nullable String> getSystemProperty, List<URL> urls) {
boolean preferArgFile = urls.size() > 1 && isWindows(getSystemProperty);
return new ClassPath(preferArgFile, urls.stream().map(ClassPath::toPathString).collect(JOIN_BY_PATH_SEPARATOR));
}
private static boolean isWindows(UnaryOperator<@Nullable String> getSystemProperty) {
private static boolean isWindows(Function<String, @Nullable String> getSystemProperty) {
String os = getSystemProperty.apply("os.name");
return StringUtils.hasText(os) && os.toLowerCase(Locale.ROOT).contains("win");
}
@@ -22,7 +22,7 @@ import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.UnaryOperator;
import java.util.function.Function;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
@@ -94,11 +94,11 @@ class ClassPathTests {
assertThat(classPath.toString()).isEqualTo(path1 + File.pathSeparator + path2);
}
private UnaryOperator<@Nullable String> onWindows() {
private Function<String, @Nullable String> onWindows() {
return Map.of("os.name", "windows")::get;
}
private UnaryOperator<@Nullable String> onLinux() {
private Function<String, @Nullable String> onLinux() {
return Map.of("os.name", "linux")::get;
}