mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8266155: Convert java.base to use Stream.toList()
Reviewed-by: bpb, naoto, iris, chegar
This commit is contained in:
parent
c36c63a008
commit
dd05158b24
8 changed files with 14 additions and 25 deletions
|
@ -3824,7 +3824,7 @@ public final class String
|
|||
}
|
||||
char lastChar = charAt(length - 1);
|
||||
boolean optOut = lastChar == '\n' || lastChar == '\r';
|
||||
List<String> lines = lines().collect(Collectors.toList());
|
||||
List<String> lines = lines().toList();
|
||||
final int outdent = optOut ? 0 : outdent(lines);
|
||||
return lines.stream()
|
||||
.map(line -> {
|
||||
|
|
|
@ -59,7 +59,6 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.lang.invoke.LambdaForm.BasicType.V_TYPE;
|
||||
|
@ -6649,8 +6648,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
iterationVariableTypes.add(in == null ? st.type().returnType() : in.type().returnType());
|
||||
}
|
||||
}
|
||||
final List<Class<?>> commonPrefix = iterationVariableTypes.stream().filter(t -> t != void.class).
|
||||
collect(Collectors.toList());
|
||||
final List<Class<?>> commonPrefix = iterationVariableTypes.stream().filter(t -> t != void.class).toList();
|
||||
|
||||
// Step 1B: determine loop parameters (A...).
|
||||
final List<Class<?>> commonSuffix = buildCommonSuffix(init, step, pred, fini, commonPrefix.size());
|
||||
|
@ -6779,11 +6777,11 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
int pc = h.type().parameterCount();
|
||||
int tpsize = targetParams.size();
|
||||
return pc < tpsize ? dropArguments0(h, pc, targetParams.subList(pc, tpsize)) : h;
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
private static List<MethodHandle> fixArities(List<MethodHandle> hs) {
|
||||
return hs.stream().map(MethodHandle::asFixedArity).collect(Collectors.toList());
|
||||
return hs.stream().map(MethodHandle::asFixedArity).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,6 @@ import java.util.concurrent.ConcurrentMap;
|
|||
import java.util.jar.JarEntry;
|
||||
import java.util.spi.ResourceBundleControlProvider;
|
||||
import java.util.spi.ResourceBundleProvider;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.internal.loader.BootLoader;
|
||||
|
@ -1514,13 +1513,10 @@ public abstract class ResourceBundle {
|
|||
|
||||
private static class ResourceBundleControlProviderHolder {
|
||||
private static final PrivilegedAction<List<ResourceBundleControlProvider>> pa =
|
||||
() -> {
|
||||
return Collections.unmodifiableList(
|
||||
ServiceLoader.load(ResourceBundleControlProvider.class,
|
||||
ClassLoader.getSystemClassLoader()).stream()
|
||||
.map(ServiceLoader.Provider::get)
|
||||
.collect(Collectors.toList()));
|
||||
};
|
||||
() -> ServiceLoader.load(ResourceBundleControlProvider.class,
|
||||
ClassLoader.getSystemClassLoader()).stream()
|
||||
.map(ServiceLoader.Provider::get)
|
||||
.toList();
|
||||
|
||||
private static final List<ResourceBundleControlProvider> CONTROL_PROVIDERS =
|
||||
AccessController.doPrivileged(pa);
|
||||
|
|
|
@ -41,7 +41,6 @@ import java.util.Set;
|
|||
import java.util.StringJoiner;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import static java.util.Collections.*;
|
||||
|
||||
import jdk.internal.access.JavaLangAccess;
|
||||
|
@ -293,7 +292,7 @@ public final class IllegalAccessLogger {
|
|||
List<StackWalker.StackFrame> stack = StackWalkerHolder.INSTANCE.walk(s ->
|
||||
s.dropWhile(this::isJavaBase)
|
||||
.limit(32)
|
||||
.collect(Collectors.toList())
|
||||
.toList()
|
||||
);
|
||||
|
||||
// record usage if this is the first (or not recently recorded)
|
||||
|
|
|
@ -50,7 +50,6 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.internal.loader.Resource;
|
||||
|
@ -84,7 +83,7 @@ public final class ModulePatcher {
|
|||
String mn = e.getKey();
|
||||
List<Path> paths = e.getValue().stream()
|
||||
.map(Paths::get)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
map.put(mn, paths);
|
||||
}
|
||||
this.map = map;
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||
import java.util.function.Supplier;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
|
@ -274,7 +273,7 @@ class ModuleReferences {
|
|||
// take snapshot to avoid async close
|
||||
List<String> names = jf.versionedStream()
|
||||
.map(JarEntry::getName)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
return names.stream();
|
||||
}
|
||||
|
||||
|
@ -340,7 +339,7 @@ class ModuleReferences {
|
|||
List<String> names = jf.stream()
|
||||
.filter(e -> e.section() == JmodFile.Section.CLASSES)
|
||||
.map(JmodFile.Entry::name)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
return names.stream();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ import java.security.PrivilegedActionException;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IPAddressUtil {
|
||||
private static final int INADDR4SZ = 4;
|
||||
|
@ -359,7 +358,7 @@ public class IPAddressUtil {
|
|||
.filter(a -> (a instanceof Inet6Address)
|
||||
&& address.equals(a)
|
||||
&& ((Inet6Address) a).getScopeId() != 0)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
List<InetAddress> result;
|
||||
try {
|
||||
result = AccessController.doPrivileged(pa);
|
||||
|
|
|
@ -36,7 +36,6 @@ import static java.util.Locale.LanguageRange.*;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Implementation for BCP47 Locale matching
|
||||
|
@ -184,7 +183,7 @@ public final class LocaleMatcher {
|
|||
Collection<String> tags) {
|
||||
Set<String> distinctTags = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||
return tags.stream().filter(x -> distinctTags.add(x))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue