8276234: Trivially clean up locale-related code

Reviewed-by: redestad, naoto, iris
This commit is contained in:
Pavel Rappo 2021-11-01 22:50:43 +00:00
parent 47e7a42594
commit 2eafa036c0
3 changed files with 12 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -124,7 +124,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
static final LocalGregorianCalendar JCAL = static final LocalGregorianCalendar JCAL =
(LocalGregorianCalendar) CalendarSystem.forName("japanese"); (LocalGregorianCalendar) CalendarSystem.forName("japanese");
// Locale for creating a JapaneseImpericalCalendar. // Locale for creating a JapaneseImperialCalendar.
static final Locale LOCALE = Locale.forLanguageTag("ja-JP-u-ca-japanese"); static final Locale LOCALE = Locale.forLanguageTag("ja-JP-u-ca-japanese");
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -139,7 +139,7 @@ public final class BaseLocale {
region = ""; region = "";
} }
if (language == null) { if (language == null) {
language = null; language = "";
} }
if (variant == null) { if (variant == null) {
variant = ""; variant = "";

View File

@ -42,7 +42,6 @@ package sun.util.resources;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -205,7 +204,7 @@ public class LocaleData {
}); });
} }
private static abstract class LocaleDataResourceBundleProvider private abstract static class LocaleDataResourceBundleProvider
implements ResourceBundleProvider { implements ResourceBundleProvider {
/** /**
* Changes baseName to its module dependent package name and * Changes baseName to its module dependent package name and
@ -231,14 +230,14 @@ public class LocaleData {
* A ResourceBundleProvider implementation for loading locale data * A ResourceBundleProvider implementation for loading locale data
* resource bundles except for the java.time supplementary data. * resource bundles except for the java.time supplementary data.
*/ */
public static abstract class CommonResourceBundleProvider extends LocaleDataResourceBundleProvider { public abstract static class CommonResourceBundleProvider extends LocaleDataResourceBundleProvider {
} }
/** /**
* A ResourceBundleProvider implementation for loading supplementary * A ResourceBundleProvider implementation for loading supplementary
* resource bundles for java.time. * resource bundles for java.time.
*/ */
public static abstract class SupplementaryResourceBundleProvider extends LocaleDataResourceBundleProvider { public abstract static class SupplementaryResourceBundleProvider extends LocaleDataResourceBundleProvider {
} }
// Bundles.Strategy implementations // Bundles.Strategy implementations
@ -246,7 +245,7 @@ public class LocaleData {
private static class LocaleDataStrategy implements Bundles.Strategy { private static class LocaleDataStrategy implements Bundles.Strategy {
private static final LocaleDataStrategy INSTANCE = new LocaleDataStrategy(); private static final LocaleDataStrategy INSTANCE = new LocaleDataStrategy();
// TODO: avoid hard-coded Locales // TODO: avoid hard-coded Locales
private static Set<Locale> JAVA_BASE_LOCALES private static final Set<Locale> JAVA_BASE_LOCALES
= Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US, new Locale("en", "US", "POSIX")); = Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US, new Locale("en", "US", "POSIX"));
private LocaleDataStrategy() { private LocaleDataStrategy() {
@ -254,7 +253,7 @@ public class LocaleData {
/* /*
* This method overrides the default implementation to search * This method overrides the default implementation to search
* from a prebaked locale string list to determin the candidate * from a prebaked locale string list to determine the candidate
* locale list. * locale list.
* *
* @param baseName the resource bundle base name. * @param baseName the resource bundle base name.
@ -325,7 +324,7 @@ public class LocaleData {
private static final SupplementaryStrategy INSTANCE private static final SupplementaryStrategy INSTANCE
= new SupplementaryStrategy(); = new SupplementaryStrategy();
// TODO: avoid hard-coded Locales // TODO: avoid hard-coded Locales
private static Set<Locale> JAVA_BASE_LOCALES private static final Set<Locale> JAVA_BASE_LOCALES
= Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US); = Set.of(Locale.ROOT, Locale.ENGLISH, Locale.US);
private SupplementaryStrategy() { private SupplementaryStrategy() {
@ -333,8 +332,8 @@ public class LocaleData {
@Override @Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) { public List<Locale> getCandidateLocales(String baseName, Locale locale) {
// Specifiy only the given locale // Specify only the given locale
return Arrays.asList(locale); return List.of(locale);
} }
@Override @Override