Skip to content

Commit

Permalink
8276234: Trivially clean up locale-related code
Browse files Browse the repository at this point in the history
Reviewed-by: redestad, naoto, iris
  • Loading branch information
pavelrappo committed Nov 1, 2021
1 parent 47e7a42 commit 2eafa03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -124,7 +124,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
static final LocalGregorianCalendar JCAL =
(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");

/**
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/sun/util/locale/BaseLocale.java
Original file line number Diff line number Diff line change
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -139,7 +139,7 @@ public static BaseLocale getInstance(String language, String script,
region = "";
}
if (language == null) {
language = null;
language = "";
}
if (variant == null) {
variant = "";
Expand Down
17 changes: 8 additions & 9 deletions src/java.base/share/classes/sun/util/resources/LocaleData.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -205,7 +204,7 @@ public OpenListResourceBundle run() {
});
}

private static abstract class LocaleDataResourceBundleProvider
private abstract static class LocaleDataResourceBundleProvider
implements ResourceBundleProvider {
/**
* Changes baseName to its module dependent package name and
Expand All @@ -231,30 +230,30 @@ protected String toOtherBundleName(String baseName, String bundleName, Locale lo
* A ResourceBundleProvider implementation for loading locale 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
* resource bundles for java.time.
*/
public static abstract class SupplementaryResourceBundleProvider extends LocaleDataResourceBundleProvider {
public abstract static class SupplementaryResourceBundleProvider extends LocaleDataResourceBundleProvider {
}

// Bundles.Strategy implementations

private static class LocaleDataStrategy implements Bundles.Strategy {
private static final LocaleDataStrategy INSTANCE = new LocaleDataStrategy();
// 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"));

private LocaleDataStrategy() {
}

/*
* 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.
*
* @param baseName the resource bundle base name.
Expand Down Expand Up @@ -325,16 +324,16 @@ private static class SupplementaryStrategy extends LocaleDataStrategy {
private static final SupplementaryStrategy INSTANCE
= new SupplementaryStrategy();
// 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);

private SupplementaryStrategy() {
}

@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
// Specifiy only the given locale
return Arrays.asList(locale);
// Specify only the given locale
return List.of(locale);
}

@Override
Expand Down

1 comment on commit 2eafa03

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.