Skip to content
Permalink
Browse files
8261096: Convert jlink tool to use Stream.toList()
Reviewed-by: alanb, smarks
  • Loading branch information
Ian Graves authored and Alan Bateman committed Feb 9, 2021
1 parent 2f893c2 commit edd5fc883a3ee8b61620b84965b2dea757fba7fb
@@ -133,7 +133,7 @@ public static void recreateJimage(Path jimageFile,
Archive::moduleName,
a -> {
try (Stream<Entry> entries = a.entries()) {
return entries.collect(Collectors.toList());
return entries.toList();
}
}));
ByteOrder order = ByteOrder.nativeOrder();
@@ -29,7 +29,6 @@
import java.lang.module.ModuleDescriptor;
import java.nio.ByteOrder;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jdk.internal.jimage.decompressor.Decompressor;
@@ -149,7 +148,7 @@ public int addString(String str) {
Comparator.reverseOrder())).filter((e) -> {
return e.getValue() > 1;
}).map(java.util.Map.Entry::getKey).
collect(Collectors.toList());
toList();
return result;
}

@@ -38,7 +38,6 @@
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.Collections;
import java.util.Locale;
@@ -566,7 +565,7 @@ public boolean shouldListPlugins() {
if (option.isTerminal()) {
return ++i < args.length
? Stream.of(Arrays.copyOfRange(args, i, args.length))
.collect(Collectors.toList())
.toList()
: Collections.emptyList();

}
@@ -576,7 +575,7 @@ public boolean shouldListPlugins() {
}
} else {
return Stream.of(Arrays.copyOfRange(args, i, args.length))
.collect(Collectors.toList());
.toList();
}
}
return Collections.emptyList();
@@ -33,7 +33,6 @@
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import jdk.tools.jlink.plugin.Plugin;

@@ -51,7 +50,7 @@ private Utils() {}
return Arrays.stream(arguments.split(","))
.map((p) -> p.trim())
.filter((p) -> !p.isEmpty())
.collect(Collectors.toList());
.toList();
}


@@ -34,7 +34,6 @@
import java.util.Map;
import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import jdk.tools.jlink.internal.Platform;
import jdk.tools.jlink.plugin.PluginException;
@@ -106,7 +105,7 @@ public ExcludeVMPlugin() {
}
}
return false;
}).collect(Collectors.toList());
}).toList();
return ret;
}

@@ -219,7 +219,7 @@ public void previsit(ResourcePool resources, StringTable strings) {
.distinct()
.sorted()
.map(IncludeLocalesPlugin::tagToLocale)
.collect(Collectors.toList());
.toList();
} else {
// jdk.localedata is not added.
throw new PluginException(PluginsResourceBundle.getMessage(getName() + ".localedatanotfound"));
@@ -236,7 +236,7 @@ public void previsit(ResourcePool resources, StringTable strings) {
META_FILES.stream(),
filtered.stream().flatMap(s -> includeLocaleFilePatterns(s).stream()))
.map(s -> "regex:" + s)
.collect(Collectors.toList());
.toList();

predicate = ResourceFilter.includeFilter(value);
}
@@ -266,7 +266,7 @@ public void previsit(ResourcePool resources, StringTable strings) {
private List<String> includeLocaleFiles(String localeStr) {
return INCLUDE_LOCALE_FILES.stream()
.map(s -> s + localeStr + ".class")
.collect(Collectors.toList());
.toList();
}

private boolean stripUnsupportedLocales(byte[] bytes, ClassReader cr) {
@@ -299,7 +299,7 @@ private boolean filterOutUnsupportedTags(byte[] b) {
locales = originalTags.stream()
.filter(tag -> !tag.isEmpty())
.map(IncludeLocalesPlugin::tagToLocale)
.collect(Collectors.toList());
.toList();
} catch (IllformedLocaleException ile) {
// Seems not an available locales string literal.
return false;
@@ -342,7 +342,7 @@ private boolean filterOutUnsupportedTags(byte[] b) {
.flatMap(Optional::stream)
.flatMap(IncludeLocalesPlugin::localeToTags)
.distinct()
.collect(Collectors.toList());
.toList();

return ret;
}
@@ -51,7 +51,6 @@
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import jdk.internal.jimage.decompressor.CompressIndexes;
import jdk.internal.jimage.decompressor.SignatureParser;
import jdk.internal.jimage.decompressor.StringSharingDecompressor;
@@ -264,7 +263,7 @@ private void scanConstantPool(Set<Integer> utf8Descriptors)
List<Integer> indexes
= parseResult.types.stream().map((type) -> {
return strings.addString(type);
}).collect(Collectors.toList());
}).toList();
if (!indexes.isEmpty()) {
out.write(StringSharingDecompressor.EXTERNALIZED_STRING_DESCRIPTOR);
int sigIndex = strings.addString(parseResult.formatted);
@@ -291,7 +291,7 @@ private Configuration resolve(ModuleFinder finder, Set<String> roots) {
.collect(Collectors.toSet());
return moduleInfos.stream()
.filter(mi -> names.contains(mi.moduleName()))
.collect(Collectors.toList());
.toList();
}

/**

1 comment on commit edd5fc8

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on edd5fc8 Feb 9, 2021

Please sign in to comment.