< prev index next >
src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java
Print this page
@@ -305,22 +305,26 @@
return modified[0];
}
private boolean filterOutUnsupportedTags(byte[] b) {
List<Locale> locales;
+ String original = new String(b);
try {
- locales = Arrays.asList(new String(b).split(" ")).stream()
+ locales = Arrays.asList(original.split(" ")).stream()
.filter(tag -> !tag.isEmpty())
.map(IncludeLocalesPlugin::tagToLocale)
.collect(Collectors.toList());
} catch (IllformedLocaleException ile) {
// Seems not an available locales string literal.
return false;
}
byte[] filteredBytes = filterLocales(locales).stream()
+ // Make sure the filtered language tags do exist in the
+ // original supported tags for compatibility codes, e.g., "iw"
+ .filter(t -> original.indexOf(t) != -1)
.collect(Collectors.joining(" "))
.getBytes();
if (filteredBytes.length > b.length) {
throw new InternalError("Size of filtered locales is bigger than the original one");
@@ -329,10 +333,15 @@
System.arraycopy(filteredBytes, 0, b, 0, filteredBytes.length);
Arrays.fill(b, filteredBytes.length, b.length, (byte)' ');
return true;
}
+ /*
+ * Filter list of locales according to the secified priorityList. Note
+ * that returned list of language tags may include extra ones, such as
+ * compatibility ones (e.g., "iw" -> "iw", "he").
+ */
private List<String> filterLocales(List<Locale> locales) {
List<String> ret =
Locale.filter(priorityList, locales, Locale.FilteringMode.EXTENDED_FILTERING).stream()
.flatMap(loc -> Stream.concat(Control.getNoFallbackControl(Control.FORMAT_DEFAULT)
.getCandidateLocales("", loc).stream(),
< prev index next >