Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8276234: Trivially clean up locale-related code #6191

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
pavelrappo marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down