diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index 5a3eaf48d64..d4bd7c5ba9c 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -427,7 +427,7 @@ import sun.util.locale.provider.TimeZoneNameUtility; * stream, including extensions. * *

During deserialization, readResolve adds extensions as described - * in Special Cases, only + * in {@linkplain ##special_cases_constructor Special Cases}, only * for the two cases th_TH_TH and ja_JP_JP. * *

Legacy language codes

@@ -719,16 +719,16 @@ public final class Locale implements Cloneable, Serializable { * @implNote * * - * @deprecated Locale constructors have been deprecated. See - * Obtaining a Locale for other options. + * @deprecated Locale constructors have been deprecated. See {@linkplain ##ObtainingLocale + * Obtaining a Locale} for other options. * * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag * up to 8 characters in length. See the {@code Locale} class description about @@ -755,14 +755,14 @@ public final class Locale implements Cloneable, Serializable { * @implNote * * - * @deprecated Locale constructors have been deprecated. See - * Obtaining a Locale for other options. + * @deprecated Locale constructors have been deprecated. See {@linkplain + * ##ObtainingLocale Obtaining a Locale} for other options. * * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag * up to 8 characters in length. See the {@code Locale} class description about @@ -782,14 +782,14 @@ public final class Locale implements Cloneable, Serializable { * @implNote * * - * @deprecated Locale constructors have been deprecated. See - * Obtaining a Locale for other options. + * @deprecated Locale constructors have been deprecated. See {@linkplain + * ##ObtainingLocale Obtaining a Locale} for other options. * * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag * up to 8 characters in length. See the {@code Locale} class description about @@ -811,18 +811,19 @@ public final class Locale implements Cloneable, Serializable { *
  • This method does not make any syntactic checks on the input. * Use {@link Locale.Builder} for full syntactic checks with BCP47. *
  • The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially, - * see Special Cases for more information. + * see {@linkplain ##special_cases_constructor Special Cases} for more information. *
  • Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to - * their current forms. See Legacy language - * codes for more information. + * their current forms. See {@linkplain ##legacy_language_codes Legacy language + * codes} for more information. * * * @param language A language code. See the {@code Locale} class description of - * language values. + * {@linkplain ##def_language language} values. * @param country A country code. See the {@code Locale} class description of - * country values. + * {@linkplain ##def_region country} values. * @param variant Any arbitrary value used to indicate a variation of a {@code Locale}. - * See the {@code Locale} class description of variant values. + * See the {@code Locale} class description of {@linkplain ##def_variant + * variant} values. * @throws NullPointerException thrown if any argument is null. * @return A {@code Locale} object * @since 19 @@ -840,14 +841,14 @@ public final class Locale implements Cloneable, Serializable { *
  • This method does not make any syntactic checks on the input. * Use {@link Locale.Builder} for full syntactic checks with BCP47. *
  • Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to - * their current forms. See Legacy language - * codes for more information. + * their current forms. See {@linkplain ##legacy_language_codes Legacy language + * codes} for more information. * * * @param language A language code. See the {@code Locale} class description of - * language values. + * {@linkplain ##def_language language} values. * @param country A country code. See the {@code Locale} class description of - * country values. + * {@linkplain ##def_region country} values. * @throws NullPointerException thrown if either argument is null. * @return A {@code Locale} object * @since 19 @@ -864,12 +865,12 @@ public final class Locale implements Cloneable, Serializable { *
  • This method does not make any syntactic checks on the input. * Use {@link Locale.Builder} for full syntactic checks with BCP47. *
  • Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to - * their current forms. See Legacy language - * codes for more information. + * their current forms. See {@linkplain ##legacy_language_codes Legacy language + * codes} for more information. * * * @param language A language code. See the {@code Locale} class description of - * language values. + * {@linkplain ##def_language language} values. * @throws NullPointerException thrown if argument is null. * @return A {@code Locale} object * @since 19 @@ -1197,22 +1198,22 @@ public final class Locale implements Cloneable, Serializable { } /** - * Returns an array of all installed locales. + * {@return an array of installed locales} + * * The returned array represents the union of locales supported * by the Java runtime environment and by installed * {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider} * implementations. At a minimum, the returned array must contain a * {@code Locale} instance equal to {@link Locale#ROOT Locale.ROOT} and * a {@code Locale} instance equal to {@link Locale#US Locale.US}. - * - * @return An array of installed locales. */ public static Locale[] getAvailableLocales() { return LocaleServiceProviderPool.getAllAvailableLocales(); } /** - * Returns a stream of all installed locales. + * {@return a stream of installed locales} + * * The returned stream represents the union of locales supported * by the Java runtime environment and by installed * {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider} @@ -1222,7 +1223,6 @@ public final class Locale implements Cloneable, Serializable { * * @implNote Unlike {@code getAvailableLocales()}, this method does * not create a defensive copy of the Locale array. - * @return A stream of installed locales. * @since 21 */ public static Stream availableLocales() { @@ -1256,12 +1256,11 @@ public final class Locale implements Cloneable, Serializable { } /** - * Returns a {@code Set} of ISO3166 country codes for the specified type. + * {@return a {@code Set} of ISO3166 country codes for the specified type} * * @param type {@link Locale.IsoCountryCode} specified ISO code type. * @see java.util.Locale.IsoCountryCode * @throws NullPointerException if type is null - * @return a {@code Set} of ISO country codes for the specified type. * @since 9 */ public static Set getISOCountries(IsoCountryCode type) { @@ -1308,8 +1307,8 @@ public final class Locale implements Cloneable, Serializable { * Returns the language code of this Locale. * * @implNote This method returns the new forms for the obsolete ISO 639 - * codes ("iw", "ji", and "in"). See - * Legacy language codes for more information. + * codes ("iw", "ji", and "in"). See {@linkplain ##legacy_language_codes + * Legacy language codes} for more information. * * @return The language code, or the empty string if none is defined. * @see #getDisplayLanguage @@ -1355,8 +1354,8 @@ public final class Locale implements Cloneable, Serializable { } /** - * Returns {@code true} if this {@code Locale} has any - * extensions. + * Returns {@code true} if this {@code Locale} has any {@linkplain ##def_extensions + * extensions}. * * @return {@code true} if this {@code Locale} has any extensions * @since 1.8 @@ -1366,8 +1365,8 @@ public final class Locale implements Cloneable, Serializable { } /** - * Returns a copy of this {@code Locale} with no - * extensions. If this {@code Locale} has no extensions, this {@code Locale} + * Returns a copy of this {@code Locale} with no {@linkplain ##def_extensions + * extensions}. If this {@code Locale} has no extensions, this {@code Locale} * is returned. * * @return a copy of this {@code Locale} with no extensions, or {@code this} @@ -1571,16 +1570,15 @@ public final class Locale implements Cloneable, Serializable { * syntax requirements, this method handles these fields as * described below: * - *

    Language: If language is empty, or not well-formed (for example "a" or + *

    Language: If language is empty, or not + * {@linkplain ##def_language well-formed} (for example "a" or * "e2"), it will be emitted as "und" (Undetermined). * - *

    Country: If country is not well-formed (for example "12" or "USA"), - * it will be omitted. + *

    Country: If country is not {@linkplain ##def_region well-formed} + * (for example "12" or "USA"), it will be omitted. * - *

    Variant: If variant is well-formed, each sub-segment + *

    Variant: If variant is {@linkplain ##def_variant + * well-formed}, each sub-segment * (delimited by '-' or '_') is emitted as a subtag. Otherwise: *

      * @@ -1702,7 +1700,7 @@ public final class Locale implements Cloneable, Serializable { *
    • The language codes "iw", "ji", and "in" are mapped to "he", * "yi", and "id" respectively. (This is the same canonicalization * that's done in Locale's constructors.) See - * Legacy language codes + * {@linkplain ##legacy_language_codes Legacy language codes} * for more information. * *
    • The portion of a private use subtag prefixed by "lvariant", @@ -1830,7 +1828,8 @@ public final class Locale implements Cloneable, Serializable { } /** - * Returns a three-letter abbreviation of this locale's language. + * {@return a three-letter abbreviation of this locale's language} + * * If the language matches an ISO 639-1 two-letter code, the * corresponding ISO 639-2/T three-letter lowercase code is * returned. The ISO 639-2 language codes can be found on-line, @@ -1839,7 +1838,6 @@ public final class Locale implements Cloneable, Serializable { * language, the language is returned as is. If the locale does * not specify a language the empty string is returned. * - * @return A three-letter abbreviation of this locale's language. * @throws MissingResourceException Throws MissingResourceException if * three-letter language abbreviation is not available for this locale. */ @@ -1858,7 +1856,8 @@ public final class Locale implements Cloneable, Serializable { } /** - * Returns a three-letter abbreviation for this locale's country. + * {@return a three-letter abbreviation of this locale's country} + * * If the country matches an ISO 3166-1 alpha-2 code, the * corresponding ISO 3166-1 alpha-3 uppercase code is returned. * If the locale doesn't specify a country, this will be the empty @@ -1866,7 +1865,6 @@ public final class Locale implements Cloneable, Serializable { * *

      The ISO 3166-1 codes can be found on-line. * - * @return A three-letter abbreviation of this locale's country. * @throws MissingResourceException Throws MissingResourceException if the * three-letter country abbreviation is not available for this locale. */ @@ -2074,7 +2072,7 @@ public final class Locale implements Cloneable, Serializable { * Returns a name for the locale that is appropriate for display to the * user. This will be the values returned by getDisplayLanguage(), * getDisplayScript(), getDisplayCountry(), getDisplayVariant() and - * optional Unicode extensions + * optional {@linkplain ##def_locale_extension Unicode extensions} * assembled into a single string. The non-empty values are used in order, with * the second and subsequent names in parentheses. For example: *

      @@ -2099,8 +2097,8 @@ public final class Locale implements Cloneable, Serializable { * Returns a name for the locale that is appropriate for display * to the user. This will be the values returned by * getDisplayLanguage(), getDisplayScript(), getDisplayCountry(), - * getDisplayVariant(), and optional - * Unicode extensions assembled into a single string. The non-empty + * getDisplayVariant(), and optional {@linkplain ##def_locale_extension + * Unicode extensions} assembled into a single string. The non-empty * values are used in order, with the second and subsequent names in * parentheses. For example: *
      @@ -2467,7 +2465,7 @@ public final class Locale implements Cloneable, Serializable { * are exactly "ja", "JP", "JP" or "th", "TH", "TH" and script/extensions * fields are empty, this method supplies {@code UNICODE_LOCALE_EXTENSION} * "ca"/"japanese" (calendar type is "japanese") or "nu"/"thai" (number script - * type is "thai"). See Special Cases + * type is "thai"). See {@linkplain ##special_cases_constructor Special Cases} * for more information. * * @return an instance of {@code Locale} equivalent to @@ -2704,7 +2702,7 @@ public final class Locale implements Cloneable, Serializable { /** * Sets the language. If {@code language} is the empty string or * null, the language in this {@code Builder} is removed. Otherwise, - * the language must be well-formed + * the language must be {@linkplain Locale##def_language well-formed} * or an exception is thrown. * *

      The typical language value is a two or three-letter language @@ -2726,7 +2724,7 @@ public final class Locale implements Cloneable, Serializable { /** * Sets the script. If {@code script} is null or the empty string, * the script in this {@code Builder} is removed. - * Otherwise, the script must be well-formed or an + * Otherwise, the script must be {@linkplain Locale##def_script well-formed} or an * exception is thrown. * *

      The typical script value is a four-letter script code as defined by ISO 15924. @@ -2747,7 +2745,7 @@ public final class Locale implements Cloneable, Serializable { /** * Sets the region. If region is null or the empty string, the region * in this {@code Builder} is removed. Otherwise, - * the region must be well-formed or an + * the region must be {@linkplain Locale##def_region well-formed} or an * exception is thrown. * *

      The typical region value is a two-letter ISO 3166 code or a @@ -2772,7 +2770,7 @@ public final class Locale implements Cloneable, Serializable { /** * Sets the variant. If variant is null or the empty string, the * variant in this {@code Builder} is removed. Otherwise, it - * must consist of one or more well-formed + * must consist of one or more {@linkplain Locale##def_variant well-formed} * subtags, or an exception is thrown. * *

      Note: This method checks if {@code variant} @@ -2800,7 +2798,7 @@ public final class Locale implements Cloneable, Serializable { /** * Sets the extension for the given key. If the value is null or the * empty string, the extension is removed. Otherwise, the extension - * must be well-formed or an exception + * must be {@linkplain Locale##def_extensions well-formed} or an exception * is thrown. * *

      Note: The key {@link Locale#UNICODE_LOCALE_EXTENSION @@ -2832,9 +2830,8 @@ public final class Locale implements Cloneable, Serializable { /** * Sets the Unicode locale keyword type for the given key. If the type * is null, the Unicode keyword is removed. Otherwise, the key must be - * non-null and both key and type must be well-formed or an exception - * is thrown. + * non-null and both key and type must be {@linkplain + * Locale##def_locale_extension well-formed} or an exception is thrown. * *

      Keys and types are converted to lower case. * @@ -2861,8 +2858,8 @@ public final class Locale implements Cloneable, Serializable { /** * Adds a unicode locale attribute, if not already present, otherwise - * has no effect. The attribute must not be null and must be well-formed or an exception + * has no effect. The attribute must not be null and must be + * {@linkplain Locale##def_locale_extension well-formed} or an exception * is thrown. * * @param attribute the attribute @@ -2882,8 +2879,8 @@ public final class Locale implements Cloneable, Serializable { /** * Removes a unicode locale attribute, if present, otherwise has no - * effect. The attribute must not be null and must be well-formed or an exception + * effect. The attribute must not be null and must be + * {@linkplain Locale##def_locale_extension well-formed} or an exception * is thrown. * *

      Attribute comparison for removal is case-insensitive. @@ -3088,8 +3085,8 @@ public final class Locale implements Cloneable, Serializable { * RFC 4647 Matching of * Language Tags. A language range is an identifier which is used to * select language tag(s) meeting specific requirements by using the - * mechanisms described in Locale - * Matching. A list which represents a user's preferences and consists + * mechanisms described in {@linkplain Locale##LocaleMatching Locale + * Matching}. A list which represents a user's preferences and consists * of language ranges is called a Language Priority List. * *

      There are two types of language ranges: basic and extended. In RFC @@ -3389,9 +3386,7 @@ public final class Locale implements Cloneable, Serializable { } /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. + * {@return a hash code value for this object} */ @Override public int hashCode() { diff --git a/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java b/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java index 882cbc1c767..fd55a80cd0f 100644 --- a/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java +++ b/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, 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 @@ -86,8 +86,8 @@ import java.util.Locale; * methods of installed providers for the appropriate interface to find one that * supports the requested locale. If such a provider is found, its other * methods are called to obtain the requested object or name. When checking - * whether a locale is supported, the - * locale's extensions are ignored by default. (If locale's extensions should + * whether a locale is supported, the {@linkplain Locale##def_extensions + * locale's extensions} are ignored by default. (If locale's extensions should * also be checked, the {@code isSupportedLocale} method must be overridden.) * If neither the Java runtime environment itself nor an installed provider * supports the requested locale, the methods go through a list of candidate @@ -175,23 +175,22 @@ public abstract class LocaleServiceProvider { } /** - * Returns an array of all locales for which this locale service provider - * can provide localized objects or names. This information is used to - * compose {@code getAvailableLocales()} values of the locale-dependent - * services, such as {@code DateFormat.getAvailableLocales()}. + * {@return an array of all locales for which this locale service provider + * can provide localized objects or names} + * + * This information is used to compose {@code getAvailableLocales()} + * values of the locale-dependent services, such as + * {@code DateFormat.getAvailableLocales()}. * *

      The array returned by this method should not include two or more * {@code Locale} objects only differing in their extensions. - * - * @return An array of all locales for which this locale service provider - * can provide localized objects or names. */ public abstract Locale[] getAvailableLocales(); /** * Returns {@code true} if the given {@code locale} is supported by * this locale service provider. The given {@code locale} may contain - * extensions that should be + * {@linkplain Locale##def_extensions extensions} that should be * taken into account for the support determination. * *

      The default implementation returns {@code true} if the given {@code locale} diff --git a/src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java b/src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java index 5a71d5cbbb5..57fbd3a7726 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleServiceProviderPool.java @@ -50,7 +50,7 @@ import java.util.stream.Stream; public final class LocaleServiceProviderPool { /** - * A Map that holds singleton instances of this class. Each instance holds a + * A Map that holds singleton instances of this class. Each instance holds a * set of provider implementations of a particular locale sensitive service. */ private static final ConcurrentMap, LocaleServiceProviderPool> poolOfPools = @@ -63,7 +63,7 @@ public final class LocaleServiceProviderPool { new ConcurrentHashMap<>(); /** - * Available locales for this locale sensitive service. This also contains + * Available locales for this locale sensitive service. This also contains * JRE's available locales */ private Set availableLocales = null; @@ -148,33 +148,31 @@ public final class LocaleServiceProviderPool { } /** - * Returns a stream of the available locales for all the provider classes. - * This stream is constructed from all the locales - * that are provided by each provider, including the JRE. + * {@return a stream of the available locales for all the provider classes} * - * @return a stream of the available locales for all provider classes + * This stream is constructed from all the locales that are provided by each + * provider, including the JRE. */ public static Stream streamAllAvailableLocales() { return Arrays.stream(AllAvailableLocales.allAvailableLocales); } /** - * Returns an array of available locales for all the provider classes. + * {@return an array of the available locales for all the provider classes} + * * This array is a merged array of all the locales that are provided by each * provider, including the JRE. - * - * @return an array of the available locales for all provider classes */ public static Locale[] getAllAvailableLocales() { return AllAvailableLocales.allAvailableLocales.clone(); } /** - * Returns an array of available locales. This array is a + * {@return an array of the available locales} + * + * This array is a * merged array of all the locales that are provided by each * provider, including the JRE. - * - * @return an array of the available locales */ public Locale[] getAvailableLocales() { Set locList = new HashSet<>();