diff --git a/make/jdk/src/classes/build/tools/cldrconverter/Bundle.java b/make/jdk/src/classes/build/tools/cldrconverter/Bundle.java index a51fe64ecaced..9f262fa010608 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/Bundle.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/Bundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, 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 @@ -156,13 +156,6 @@ String getID() { return id; } - String getJavaID() { - // Tweak ISO compatibility for bundle generation - return id.replaceFirst("^he", "iw") - .replaceFirst("^id", "in") - .replaceFirst("^yi", "ji"); - } - boolean isRoot() { return "root".equals(id); } diff --git a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index ddd08b38863ce..5fd7a583a422f 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -536,7 +536,6 @@ private static void convertBundles(List bundles) throws Exception { Map targetMap = bundle.getTargetMap(); EnumSet bundleTypes = bundle.getBundleTypes(); var id = bundle.getID(); - var javaId = bundle.getJavaID(); if (bundle.isRoot()) { // Add DateTimePatternChars because CLDR no longer supports localized patterns. @@ -548,31 +547,31 @@ private static void convertBundles(List bundles) throws Exception { if (bundleTypes.contains(Bundle.Type.LOCALENAMES)) { Map localeNamesMap = extractLocaleNames(targetMap, id); if (!localeNamesMap.isEmpty() || bundle.isRoot()) { - bundleGenerator.generateBundle("util", "LocaleNames", javaId, true, localeNamesMap, BundleType.OPEN); + bundleGenerator.generateBundle("util", "LocaleNames", id, true, localeNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.CURRENCYNAMES)) { Map currencyNamesMap = extractCurrencyNames(targetMap, id, bundle.getCurrencies()); if (!currencyNamesMap.isEmpty() || bundle.isRoot()) { - bundleGenerator.generateBundle("util", "CurrencyNames", javaId, true, currencyNamesMap, BundleType.OPEN); + bundleGenerator.generateBundle("util", "CurrencyNames", id, true, currencyNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.TIMEZONENAMES)) { Map zoneNamesMap = extractZoneNames(targetMap, id); if (!zoneNamesMap.isEmpty() || bundle.isRoot()) { - bundleGenerator.generateBundle("util", "TimeZoneNames", javaId, true, zoneNamesMap, BundleType.TIMEZONE); + bundleGenerator.generateBundle("util", "TimeZoneNames", id, true, zoneNamesMap, BundleType.TIMEZONE); } } if (bundleTypes.contains(Bundle.Type.CALENDARDATA)) { Map calendarDataMap = extractCalendarData(targetMap, id); if (!calendarDataMap.isEmpty() || bundle.isRoot()) { - bundleGenerator.generateBundle("util", "CalendarData", javaId, true, calendarDataMap, BundleType.PLAIN); + bundleGenerator.generateBundle("util", "CalendarData", id, true, calendarDataMap, BundleType.PLAIN); } } if (bundleTypes.contains(Bundle.Type.FORMATDATA)) { Map formatDataMap = extractFormatData(targetMap, id); if (!formatDataMap.isEmpty() || bundle.isRoot()) { - bundleGenerator.generateBundle("text", "FormatData", javaId, true, formatDataMap, BundleType.PLAIN); + bundleGenerator.generateBundle("text", "FormatData", id, true, formatDataMap, BundleType.PLAIN); } } diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index 44a4b8803dc28..43c4c1082769f 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -444,18 +444,26 @@ * in Special Cases, only * for the two cases th_TH_TH and ja_JP_JP. * - *

Legacy language codes

+ *

Legacy language codes

* *

Locale's constructor has always converted three language codes to * their earlier, obsoleted forms: {@code he} maps to {@code iw}, * {@code yi} maps to {@code ji}, and {@code id} maps to - * {@code in}. This continues to be the case, in order to not break - * backwards compatibility. + * {@code in}. Since Java SE 17, this is no longer the case. Each + * language maps to its new form; {@code iw} maps to {@code he}, {@code ji} + * maps to {@code yi}, and {@code in} maps to {@code id}. + * + *

For the backward compatible behavior, the system property + * {@systemProperty java.locale.useOldISOCodes} reverts the behavior + * back to prior to Java SE 17 one. If the system property is set + * to {@code true}, those three current language codes are mapped to their + * backward compatible forms. * *

The APIs added in 1.7 map between the old and new language codes, - * maintaining the old codes internal to Locale (so that - * {@code getLanguage} and {@code toString} reflect the old - * code), but using the new codes in the BCP 47 language tag APIs (so + * maintaining the mapped codes internal to Locale (so that + * {@code getLanguage} and {@code toString} reflect the mapped + * code, which depends on the {@code java.locale.useOldISOCodes} system + * property), but using the new codes in the BCP 47 language tag APIs (so * that {@code toLanguageTag} reflects the new one). This * preserves the equivalence between Locales no matter which code or * API is used to construct them. Java's default resource bundle @@ -720,13 +728,11 @@ private Locale(BaseLocale baseLocale, LocaleExtensions extensions) { * Construct a locale from language, country and variant. * This constructor normalizes the language value to lowercase and * the country value to uppercase. - *

- * Note: + * @implNote *

    - *
  • ISO 639 is not a stable standard; some of the language codes it defines - * (specifically "iw", "ji", and "in") have changed. This constructor accepts both the - * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other - * API on Locale will return only the OLD codes. + *
  • Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to + * their current forms. See Legacy language + * codes for more information. *
  • For backward compatibility reasons, this constructor does not make * any syntactic checks on the input. *
  • The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially, @@ -754,13 +760,11 @@ public Locale(String language, String country, String variant) { * Construct a locale from language and country. * This constructor normalizes the language value to lowercase and * the country value to uppercase. - *

    - * Note: + * @implNote *

      - *
    • ISO 639 is not a stable standard; some of the language codes it defines - * (specifically "iw", "ji", and "in") have changed. This constructor accepts both the - * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other - * API on Locale will return only the OLD codes. + *
    • Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to + * their current forms. See Legacy language + * codes for more information. *
    • For backward compatibility reasons, this constructor does not make * any syntactic checks on the input. *
    @@ -779,13 +783,11 @@ public Locale(String language, String country) { /** * Construct a locale from a language code. * This constructor normalizes the language value to lowercase. - *

    - * Note: + * @implNote *

      - *
    • ISO 639 is not a stable standard; some of the language codes it defines - * (specifically "iw", "ji", and "in") have changed. This constructor accepts both the - * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other - * API on Locale will return only the OLD codes. + *
    • Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to + * their current forms. See Legacy language + * codes for more information. *
    • For backward compatibility reasons, this constructor does not make * any syntactic checks on the input. *
    @@ -1208,19 +1210,10 @@ private static String[] getISO2Table(String table) { /** * Returns the language code of this Locale. * - *

    Note: ISO 639 is not a stable standard— some languages' codes have changed. - * Locale's constructor recognizes both the new and the old codes for the languages - * whose codes have changed, but this function always returns the old code. If you - * want to check for a specific language whose code has changed, don't do - *

    -     * if (locale.getLanguage().equals("he")) // BAD!
    -     *    ...
    -     * 
    - * Instead, do - *
    -     * if (locale.getLanguage().equals(new Locale("he").getLanguage()))
    -     *    ...
    -     * 
    + * @implNote This method returns the new forms for the obsolete ISO 639 + * codes ("iw", "ji", and "in"). See + * Legacy language codes for more information. + * * @return The language code, or the empty string if none is defined. * @see #getDisplayLanguage */ @@ -1608,9 +1601,11 @@ public String toLanguageTag() { * *
  • The language code "und" is mapped to language "". * - *
  • The language codes "he", "yi", and "id" are mapped to "iw", - * "ji", and "in" respectively. (This is the same canonicalization - * that's done in Locale's constructors.) + *
  • 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 + * for more information. * *
  • The portion of a private use subtag prefixed by "lvariant", * if any, is removed and appended to the variant field in the @@ -2397,17 +2392,9 @@ private Object readResolve() throws java.io.ObjectStreamException { private static String convertOldISOCodes(String language) { // we accept both the old and the new ISO codes for the languages whose ISO - // codes have changed, but we always store the OLD code, for backward compatibility - language = LocaleUtils.toLowerString(language).intern(); - if (language == "he") { - return "iw"; - } else if (language == "yi") { - return "ji"; - } else if (language == "id") { - return "in"; - } else { - return language; - } + // codes have changed, but we always store the NEW code, unless the property + // java.locale.useOldISOCodes is set to "true" + return BaseLocale.convertOldISOCodes(LocaleUtils.toLowerString(language).intern()); } private static LocaleExtensions getCompatibilityExtensions(String language, diff --git a/src/java.base/share/classes/java/util/ResourceBundle.java b/src/java.base/share/classes/java/util/ResourceBundle.java index 2b22140311c60..d00837881f50a 100644 --- a/src/java.base/share/classes/java/util/ResourceBundle.java +++ b/src/java.base/share/classes/java/util/ResourceBundle.java @@ -72,6 +72,8 @@ import sun.security.action.GetPropertyAction; import sun.util.locale.BaseLocale; import sun.util.locale.LocaleObjectCache; +import sun.util.resources.Bundles; + import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION; @@ -3098,6 +3100,12 @@ public Locale getFallbackLocale(String baseName, Locale locale) { * nor {@code "java.properties"}, an * {@code IllegalArgumentException} is thrown.
  • * + *
  • If the {@code locale}'s language is one of the + * Legacy language + * codes, either old or new, then repeat the loading process + * if needed, with the bundle name with the other language. + * For example, "iw" for "he" and vice versa. + * *
* * @param baseName @@ -3152,6 +3160,21 @@ public ResourceBundle newBundle(String baseName, Locale locale, String format, * that is visible to the given loader and accessible to the given caller. */ String bundleName = toBundleName(baseName, locale); + var bundle = newBundle0(bundleName, format, loader, reload); + if (bundle == null) { + // Try loading legacy ISO language's other bundles + var otherBundleName = Bundles.toOtherBundleName(baseName, bundleName, locale); + if (!bundleName.equals(otherBundleName)) { + bundle = newBundle0(otherBundleName, format, loader, reload); + } + } + + return bundle; + } + + private ResourceBundle newBundle0(String bundleName, String format, + ClassLoader loader, boolean reload) + throws IllegalAccessException, InstantiationException, IOException { ResourceBundle bundle = null; if (format.equals("java.class")) { try { diff --git a/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java b/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java index b43a886a71021..11ddf7b428345 100644 --- a/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java +++ b/src/java.base/share/classes/java/util/spi/AbstractResourceBundleProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -27,6 +27,7 @@ import jdk.internal.access.JavaUtilResourceBundleAccess; import jdk.internal.access.SharedSecrets; +import sun.util.resources.Bundles; import java.io.IOException; import java.io.InputStream; @@ -187,6 +188,17 @@ protected String toBundleName(String baseName, Locale locale) { public ResourceBundle getBundle(String baseName, Locale locale) { Module module = this.getClass().getModule(); String bundleName = toBundleName(baseName, locale); + var bundle = getBundle0(module, bundleName); + if (bundle == null) { + var otherBundleName = Bundles.toOtherBundleName(baseName, bundleName, locale); + if (!bundleName.equals(otherBundleName)) { + bundle = getBundle0(module, Bundles.toOtherBundleName(baseName, bundleName, locale)); + } + } + return bundle; + } + + private ResourceBundle getBundle0(Module module, String bundleName) { ResourceBundle bundle = null; for (String format : formats) { diff --git a/src/java.base/share/classes/sun/util/locale/BaseLocale.java b/src/java.base/share/classes/sun/util/locale/BaseLocale.java index b520771f20a86..e5bef6dceeab9 100644 --- a/src/java.base/share/classes/sun/util/locale/BaseLocale.java +++ b/src/java.base/share/classes/sun/util/locale/BaseLocale.java @@ -34,6 +34,7 @@ import jdk.internal.misc.CDS; import jdk.internal.vm.annotation.Stable; +import sun.security.action.GetPropertyAction; import java.lang.ref.SoftReference; import java.util.StringJoiner; @@ -98,6 +99,13 @@ public final class BaseLocale { private volatile int hash; + /** + * Boolean for the old ISO language code compatibility. + */ + private static final boolean OLD_ISO_CODES = GetPropertyAction.privilegedGetProperties() + .getProperty("java.locale.useOldISOCodes", "false") + .equalsIgnoreCase("true"); + // This method must be called with normalize = false only when creating the // Locale.* constants and non-normalized BaseLocale$Keys used for lookup. private BaseLocale(String language, String script, String region, String variant, @@ -153,19 +161,22 @@ public static BaseLocale getInstance(String language, String script, // JDK uses deprecated ISO639.1 language codes for he, yi and id if (!language.isEmpty()) { - if (language.equals("he")) { - language = "iw"; - } else if (language.equals("yi")) { - language = "ji"; - } else if (language.equals("id")) { - language = "in"; - } + language = convertOldISOCodes(language); } Key key = new Key(language, script, region, variant, false); return Cache.CACHE.get(key); } + public static String convertOldISOCodes(String language) { + return switch (language) { + case "he", "iw" -> OLD_ISO_CODES ? "iw" : "he"; + case "id", "in" -> OLD_ISO_CODES ? "in" : "id"; + case "yi", "ji" -> OLD_ISO_CODES ? "ji" : "yi"; + default -> language; + }; + } + public String getLanguage() { return language; } diff --git a/src/java.base/share/classes/sun/util/resources/Bundles.java b/src/java.base/share/classes/sun/util/resources/Bundles.java index 556e4132cb61d..8f8809f4ae6f1 100644 --- a/src/java.base/share/classes/sun/util/resources/Bundles.java +++ b/src/java.base/share/classes/sun/util/resources/Bundles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -208,6 +208,17 @@ private static ResourceBundle findBundleOf(CacheKey cacheKey, Class bundleClass = (Class) c; bundle = bundleAccess.newResourceBundle(bundleClass); } + if (bundle == null) { + var otherBundleName = toOtherBundleName(baseName, bundleName, targetLocale); + if (!bundleName.equals(otherBundleName)) { + c = Class.forName(Bundles.class.getModule(), otherBundleName); + if (c != null && ResourceBundle.class.isAssignableFrom(c)) { + @SuppressWarnings("unchecked") + Class bundleClass = (Class) c; + bundle = bundleAccess.newResourceBundle(bundleClass); + } + } + } } catch (Exception e) { cacheKey.setCause(e); } @@ -345,27 +356,55 @@ private static ResourceBundle putBundleInCache(CacheKey cacheKey, return bundle; } + /** + * Generates the other bundle name for languages that have changed, + * i.e. "he", "id", and "yi" + * + * @param baseName ResourceBundle base name + * @param bundleName ResourceBundle bundle name + * @param locale locale + * @return the other bundle name, or the same name for non-legacy ISO languages + */ + public static String toOtherBundleName(String baseName, String bundleName, Locale locale) { + var simpleName= baseName.substring(baseName.lastIndexOf('.') + 1); + var suffix = bundleName.substring(bundleName.lastIndexOf(simpleName) + simpleName.length()); + var otherSuffix = switch(locale.getLanguage()) { + case "he" -> suffix.replaceFirst("^_he(_.*)?$", "_iw$1"); + case "id" -> suffix.replaceFirst("^_id(_.*)?$", "_in$1"); + case "yi" -> suffix.replaceFirst("^_yi(_.*)?$", "_ji$1"); + case "iw" -> suffix.replaceFirst("^_iw(_.*)?$", "_he$1"); + case "in" -> suffix.replaceFirst("^_in(_.*)?$", "_id$1"); + case "ji" -> suffix.replaceFirst("^_ji(_.*)?$", "_yi$1"); + default -> suffix; + }; + + if (suffix.equals(otherSuffix)) { + return bundleName; + } else { + return bundleName.substring(0, bundleName.lastIndexOf(suffix)) + otherSuffix; + } + } /** * The Strategy interface defines methods that are called by Bundles.of during * the resource bundle loading process. */ - public static interface Strategy { + public interface Strategy { /** * Returns a list of locales to be looked up for bundle loading. */ - public List getCandidateLocales(String baseName, Locale locale); + List getCandidateLocales(String baseName, Locale locale); /** * Returns the bundle name for the given baseName and locale. */ - public String toBundleName(String baseName, Locale locale); + String toBundleName(String baseName, Locale locale); /** * Returns the service provider type for the given baseName * and locale, or null if no service providers should be used. */ - public Class getResourceBundleProviderType(String baseName, + Class getResourceBundleProviderType(String baseName, Locale locale); } @@ -374,7 +413,7 @@ public Class getResourceBundleProviderType(Str * BundleReference. */ private static interface CacheKeyReference { - public CacheKey getCacheKey(); + CacheKey getCacheKey(); } /** diff --git a/src/java.base/share/classes/sun/util/resources/LocaleData.java b/src/java.base/share/classes/sun/util/resources/LocaleData.java index 429613413b8a7..22c1398cfc6b0 100644 --- a/src/java.base/share/classes/sun/util/resources/LocaleData.java +++ b/src/java.base/share/classes/sun/util/resources/LocaleData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -216,6 +216,13 @@ private static abstract class LocaleDataResourceBundleProvider protected String toBundleName(String baseName, Locale locale) { return LocaleDataStrategy.INSTANCE.toBundleName(baseName, locale); } + + /** + * Retrieves the other bundle name for legacy ISO 639 languages. + */ + protected String toOtherBundleName(String baseName, String bundleName, Locale locale) { + return Bundles.toOtherBundleName(baseName, bundleName, locale); + } } /** diff --git a/src/java.desktop/share/classes/java/awt/ComponentOrientation.java b/src/java.desktop/share/classes/java/awt/ComponentOrientation.java index abec1d907e770..afa1e8af94a23 100644 --- a/src/java.desktop/share/classes/java/awt/ComponentOrientation.java +++ b/src/java.desktop/share/classes/java/awt/ComponentOrientation.java @@ -158,14 +158,10 @@ public static ComponentOrientation getOrientation(Locale locale) { // to find the appropriate orientation. Until pluggable locales // are introduced however, the flexibility isn't really needed. // So we choose efficiency instead. - String lang = locale.getLanguage(); - if( "iw".equals(lang) || "ar".equals(lang) - || "fa".equals(lang) || "ur".equals(lang) ) - { - return RIGHT_TO_LEFT; - } else { - return LEFT_TO_RIGHT; - } + return switch (locale.getLanguage()) { + case "ar", "fa", "he", "iw", "ji", "ur", "yi" -> RIGHT_TO_LEFT; + default -> LEFT_TO_RIGHT; + }; } /** diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/CollationData_iw.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/CollationData_he.java similarity index 98% rename from src/jdk.localedata/share/classes/sun/text/resources/ext/CollationData_iw.java rename to src/jdk.localedata/share/classes/sun/text/resources/ext/CollationData_he.java index 25fea11ef1e86..b5bb06b35fd56 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/CollationData_iw.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/CollationData_he.java @@ -45,7 +45,7 @@ import java.util.ListResourceBundle; -public class CollationData_iw extends ListResourceBundle { +public class CollationData_he extends ListResourceBundle { protected final Object[][] getContents() { return new Object[][] { diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_iw.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_he.java similarity index 99% rename from src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_iw.java rename to src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_he.java index 93441b49dfa53..cfde6826e40cc 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_iw.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_he.java @@ -78,7 +78,7 @@ import sun.util.resources.ParallelListResourceBundle; -public class FormatData_iw extends ParallelListResourceBundle { +public class FormatData_he extends ParallelListResourceBundle { /** * Overrides ParallelListResourceBundle */ diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_iw_IL.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_he_IL.java similarity index 97% rename from src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_iw_IL.java rename to src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_he_IL.java index 8fefe693a7733..f03bae72d416a 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_iw_IL.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_he_IL.java @@ -42,7 +42,7 @@ import sun.util.resources.ParallelListResourceBundle; -public class FormatData_iw_IL extends ParallelListResourceBundle { +public class FormatData_he_IL extends ParallelListResourceBundle { /** * Overrides ParallelListResourceBundle */ diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_in.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_id.java similarity index 98% rename from src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_in.java rename to src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_id.java index 9b75e8ca1fc9f..c816077942aaa 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_in.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_id.java @@ -63,7 +63,7 @@ import sun.util.resources.ParallelListResourceBundle; -public class FormatData_in extends ParallelListResourceBundle { +public class FormatData_id extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_in_ID.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_id_ID.java similarity index 98% rename from src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_in_ID.java rename to src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_id_ID.java index d9b14c201f82d..ed3b6c77dce23 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_in_ID.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_id_ID.java @@ -63,7 +63,7 @@ import sun.util.resources.ParallelListResourceBundle; -public class FormatData_in_ID extends ParallelListResourceBundle { +public class FormatData_id_ID extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "TimePatterns", diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_iw.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_he.java similarity index 99% rename from src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_iw.java rename to src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_he.java index 3170efd769b28..0b1df1c6b6dd3 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_iw.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_he.java @@ -69,7 +69,7 @@ import sun.util.resources.OpenListResourceBundle; -public class JavaTimeSupplementary_iw extends OpenListResourceBundle { +public class JavaTimeSupplementary_he extends OpenListResourceBundle { @Override protected final Object[][] getContents() { final String[] sharedQuarterNames = { diff --git a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_id.java similarity index 99% rename from src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java rename to src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_id.java index 067027554c674..022a3b664b5ed 100644 --- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java +++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_id.java @@ -69,7 +69,7 @@ import sun.util.resources.OpenListResourceBundle; -public class JavaTimeSupplementary_in extends OpenListResourceBundle { +public class JavaTimeSupplementary_id extends OpenListResourceBundle { @Override protected final Object[][] getContents() { final String[] sharedQuarterAbbreviations = { diff --git a/src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_iw.properties b/src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_he.properties similarity index 100% rename from src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_iw.properties rename to src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_he.properties diff --git a/src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_in_ID.properties b/src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_id_ID.properties similarity index 100% rename from src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_in_ID.properties rename to src/jdk.localedata/share/classes/sun/util/resources/ext/CalendarData_id_ID.properties diff --git a/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_iw_IL.properties b/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_he_IL.properties similarity index 100% rename from src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_iw_IL.properties rename to src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_he_IL.properties diff --git a/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_in_ID.properties b/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_id_ID.properties similarity index 100% rename from src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_in_ID.properties rename to src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_id_ID.properties diff --git a/src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_iw.properties b/src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_he.properties similarity index 100% rename from src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_iw.properties rename to src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_he.properties diff --git a/src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_in.properties b/src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_id.properties similarity index 100% rename from src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_in.properties rename to src/jdk.localedata/share/classes/sun/util/resources/ext/LocaleNames_id.properties diff --git a/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java b/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java index ed9f5b826d972..2ed2851a5217f 100644 --- a/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java +++ b/src/jdk.localedata/share/classes/sun/util/resources/provider/LocaleDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -36,7 +36,15 @@ public class LocaleDataProvider extends LocaleData.CommonResourceBundleProvider { @Override public ResourceBundle getBundle(String baseName, Locale locale) { - return loadResourceBundle(toBundleName(baseName, locale)); + var bundleName = toBundleName(baseName, locale); + var rb = loadResourceBundle(bundleName); + if (rb == null) { + var otherBundleName = toOtherBundleName(baseName, bundleName, locale); + if (!bundleName.equals(otherBundleName)) { + rb = loadResourceBundle(otherBundleName); + } + } + return rb; } /** diff --git a/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java b/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java index 04d3c11b663bc..c214dedba2067 100644 --- a/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java +++ b/src/jdk.localedata/share/classes/sun/util/resources/provider/SupplementaryLocaleDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -35,6 +35,14 @@ public class SupplementaryLocaleDataProvider extends LocaleData.SupplementaryResourceBundleProvider { @Override public ResourceBundle getBundle(String baseName, Locale locale) { - return LocaleDataProvider.loadResourceBundle(toBundleName(baseName, locale)); + var bundleName = toBundleName(baseName, locale); + var rb = LocaleDataProvider.loadResourceBundle(bundleName); + if (rb == null) { + var otherBundleName = toOtherBundleName(baseName, bundleName, locale); + if (!bundleName.equals(otherBundleName)) { + rb = LocaleDataProvider.loadResourceBundle(otherBundleName); + } + } + return rb; } } diff --git a/test/jdk/java/awt/ComponentOrientation/BasicTest.java b/test/jdk/java/awt/ComponentOrientation/BasicTest.java index 50c0f61eafea9..a7b4ac4b22ba5 100644 --- a/test/jdk/java/awt/ComponentOrientation/BasicTest.java +++ b/test/jdk/java/awt/ComponentOrientation/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4108453 4778440 6304780 6396378 + * @bug 4108453 4778440 6304780 6396378 8263202 * @summary Basic tests for java.awt.ComponentOrientation * @build TestBundle TestBundle_es TestBundle_iw * @build TestBundle1 TestBundle1_ar @@ -100,6 +100,12 @@ static void TestLocale() { orient = ComponentOrientation.getOrientation(new Locale("ar", "")); Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "ar == RIGHT_TO_LEFT"); + orient = ComponentOrientation.getOrientation(new Locale("he", "")); + Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "he == RIGHT_TO_LEFT"); + + orient = ComponentOrientation.getOrientation(new Locale("yi", "")); + Assert(orient == ComponentOrientation.RIGHT_TO_LEFT, "yi == RIGHT_TO_LEFT"); + System.out.println(" } Pass"); } @@ -130,6 +136,10 @@ static void TestBundle() { rb = ResourceBundle.getBundle("TestBundle", new Locale("iw", "IL")); assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "iw == RIGHT_TO_LEFT" ); + // Test with "he" locale. This should load TestBundle_iw and fetch the orientation from there + rb = ResourceBundle.getBundle("TestBundle", new Locale("he", "IL")); + assertEquals(rb, ComponentOrientation.RIGHT_TO_LEFT, "he == RIGHT_TO_LEFT" ); + // This bundle has no orientation setting at all, so we should get // the system's default orientation for Arabic rb = ResourceBundle.getBundle("TestBundle1", new Locale("ar", "")); diff --git a/test/jdk/java/util/Locale/LocaleEnhanceTest.java b/test/jdk/java/util/Locale/LocaleEnhanceTest.java index 692a4e469ceca..29c8d29ebd83c 100644 --- a/test/jdk/java/util/Locale/LocaleEnhanceTest.java +++ b/test/jdk/java/util/Locale/LocaleEnhanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020, 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 @@ -44,7 +44,7 @@ /** * @test * @bug 6875847 6992272 7002320 7015500 7023613 7032820 7033504 7004603 - * 7044019 8008577 8176853 8255086 + * 7044019 8008577 8176853 8255086 8263202 * @summary test API changes to Locale * @library /java/text/testlib * @modules jdk.localedata @@ -292,12 +292,12 @@ public void testConstructor() { { "xXxXxXxXxXxX", "yYyYyYyYyYyYyYyY", "zZzZzZzZzZzZzZzZ", "xxxxxxxxxxxx", "YYYYYYYYYYYYYYYY" }, // mapped language ids - { "he", "IW", "", "iw" }, - { "iw", "IW", "", "iw" }, - { "yi", "DE", "", "ji" }, - { "ji", "DE", "", "ji" }, - { "id", "ID", "", "in" }, - { "in", "ID", "", "in" }, + { "he", "IL", "", "he" }, + { "iw", "IL", "", "he" }, + { "yi", "DE", "", "yi" }, + { "ji", "DE", "", "yi" }, + { "id", "ID", "", "id" }, + { "in", "ID", "", "id" }, // special variants { "ja", "JP", "JP" }, { "th", "TH", "TH" }, @@ -467,8 +467,8 @@ public void testToLanguageTag() { // three-letter language tags are not canonicalized { "Eng", "", "", "eng" }, // legacy languages canonicalize to modern equivalents - { "he", "IW", "", "he-IW" }, - { "iw", "IW", "", "he-IW" }, + { "he", "IL", "", "he-IL" }, + { "iw", "IL", "", "he-IL" }, { "yi", "DE", "", "yi-DE" }, { "ji", "DE", "", "yi-DE" }, { "id", "ID", "", "id-ID" }, diff --git a/test/jdk/java/util/Locale/LocaleTest.java b/test/jdk/java/util/Locale/LocaleTest.java index c571fcf63dfe5..f0cb6996d14c9 100644 --- a/test/jdk/java/util/Locale/LocaleTest.java +++ b/test/jdk/java/util/Locale/LocaleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -25,11 +25,12 @@ * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613 * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951 * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549 - * 6786276 7066203 7085757 8008577 8030696 8170840 8255086 + * 6786276 7066203 7085757 8008577 8030696 8170840 8255086 8263202 * @summary test Locales * @library /java/text/testlib * @modules jdk.localedata - * @run main/othervm -Djava.locale.providers=JRE,SPI LocaleTest + * @run main/othervm -Djava.locale.providers=COMPAT,SPI LocaleTest + * @run main/othervm -Djava.locale.providers=COMPAT,SPI -Djava.locale.useOldISOCodes=true LocaleTest */ /* * @@ -677,7 +678,7 @@ public void TestUninstalledISO3Names() { } /** - * @bug 4052404 4778440 + * @bug 4052404 4778440 8263202 */ public void TestChangedISO639Codes() { Locale hebrewOld = new Locale("iw", "IL", ""); @@ -687,18 +688,34 @@ public void TestChangedISO639Codes() { Locale indonesianOld = new Locale("in", "", ""); Locale indonesianNew = new Locale("id", "", ""); - if (!hebrewNew.getLanguage().equals("iw")) { - errln("Got back wrong language code for Hebrew: expected \"iw\", got \"" - + hebrewNew.getLanguage() + "\""); - } - if (!yiddishNew.getLanguage().equals("ji")) { - errln("Got back wrong language code for Yiddish: expected \"ji\", got \"" - + yiddishNew.getLanguage() + "\""); - } - if (!indonesianNew.getLanguage().equals("in")) { - errln("Got back wrong language code for Indonesian: expected \"in\", got \"" - + indonesianNew.getLanguage() + "\""); + if ("true".equalsIgnoreCase(System.getProperty("java.locale.useOldISOCodes"))) { + if (!hebrewNew.getLanguage().equals("iw")) { + errln("Got back wrong language code for new Hebrew: expected \"iw\", got \"" + + hebrewNew.getLanguage() + "\""); + } + if (!yiddishNew.getLanguage().equals("ji")) { + errln("Got back wrong language code for new Yiddish: expected \"ji\", got \"" + + yiddishNew.getLanguage() + "\""); + } + if (!indonesianNew.getLanguage().equals("in")) { + errln("Got back wrong language code for new Indonesian: expected \"in\", got \"" + + indonesianNew.getLanguage() + "\""); + } + } else { + if (!hebrewOld.getLanguage().equals("he")) { + errln("Got back wrong language code for old Hebrew: expected \"he\", got \"" + + hebrewNew.getLanguage() + "\""); + } + if (!yiddishOld.getLanguage().equals("yi")) { + errln("Got back wrong language code for old Yiddish: expected \"yi\", got \"" + + yiddishNew.getLanguage() + "\""); + } + if (!indonesianOld.getLanguage().equals("id")) { + errln("Got back wrong language code for old Indonesian: expected \"id\", got \"" + + indonesianNew.getLanguage() + "\""); + } } + } /** diff --git a/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java b/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java index 29b25e6ae4f52..1d8bdbb89db15 100644 --- a/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java +++ b/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -188,4 +188,31 @@ public static void runModuleWithCp(String cp, String mp, String mn, } } } + + /** + * Run the module test with "useOldISOCodes=true". + * + * @param mp module path + * @param mn module name + * @param localeList locale list + */ + public static void runModuleWithLegacyCode(String mp, String mn, List localeList) + throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java"); + launcher.addToolArg("-ea") + .addToolArg("-esa") + .addToolArg("-Djava.locale.useOldISOCodes=true") + .addToolArg("-p") + .addToolArg(mp) + .addToolArg("-m") + .addToolArg(mn); + localeList.forEach(launcher::addToolArg); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (exitCode != 0) { + throw new RuntimeException("Execution of the test failed. " + + "Unexpected exit code: " + exitCode); + } + } } \ No newline at end of file diff --git a/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java b/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java index 29c01a5809218..69f0db8325838 100644 --- a/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java +++ b/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8044767 8139067 8210408 + * @bug 8044767 8139067 8210408 8263202 * @summary Basic tests for ResourceBundle with modules: * 1) Named module "test" contains resource bundles for root and en, * and separate named modules "eubundles" and "asiabundles" contain @@ -82,7 +82,7 @@ public class BasicTest { private static final List LOCALE_LIST = List.of("de", "fr", "ja", "zh-tw", "en", "de"); private static final List LOCALE_LIST_BASIC = List.of("de", "fr", - "ja", "ja-jp", "zh-tw", "en", "de", "ja-jp"); + "ja", "ja-jp", "zh-tw", "en", "de", "ja-jp", "in", "yi"); private static final List MODULE_LIST = List.of("asiabundles", "eubundles", "test"); @@ -130,6 +130,7 @@ public void runBasicTest(String src, String mod, List moduleList, moduleList.forEach(mn -> ModuleTestUtil.prepareModule(srcPath, modPath, mn, resFormat)); ModuleTestUtil.runModule(modPath.toString(), MAIN, localeList); + ModuleTestUtil.runModuleWithLegacyCode(modPath.toString(), MAIN, localeList); } @Test diff --git a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java index f14ace513e6fb..61c684417265e 100644 --- a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java +++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -33,6 +33,6 @@ public class MyResourcesAsia extends MyResourcesProvider { public MyResourcesAsia() { super("java.properties", "asia", Locale.JAPANESE, Locale.JAPAN, Locale.CHINESE, Locale.TAIWAN, - new Locale("vi")); + new Locale("vi"), new Locale("in")); } } diff --git a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_id.properties b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_id.properties new file mode 100644 index 0000000000000..a3bfe1a3d725f --- /dev/null +++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_id.properties @@ -0,0 +1,24 @@ +# +# Copyright (c) 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 +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +key=id: message diff --git a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java index 6a5048aa81a9d..462c1804c3375 100644 --- a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java +++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -32,6 +32,6 @@ public class MyResourcesEU extends MyResourcesProvider { public MyResourcesEU() { super("java.class", "eu", - Locale.GERMAN, Locale.FRENCH, new Locale("es")); + Locale.GERMAN, Locale.FRENCH, new Locale("es"), new Locale("yi")); } } diff --git a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResources_ji.java b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResources_ji.java new file mode 100644 index 0000000000000..0b381ae7c8047 --- /dev/null +++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResources_ji.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.resources.eu; + +import java.util.ListResourceBundle; + +public class MyResources_ji extends ListResourceBundle { + @Override + public Object[][] getContents() { + return new Object[][] { + // returned value is compared with Locale.toLanguageTag() + // which always returns NEW code + { "key", "yi: message" } + }; + } +} diff --git a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/jdk/test/Main.java b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/jdk/test/Main.java index 65388e7066f28..974fa88f36a22 100644 --- a/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/jdk/test/Main.java +++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/jdk/test/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -39,7 +39,7 @@ public static void main(String[] args) throws Exception { locale); String tag = locale.toLanguageTag(); // normalized String value = rb.getString("key"); - System.out.println("locale = " + tag + ", value = " + value); + System.out.println("locale = " + locale + ", value = " + value); if (!value.startsWith(tag + ':')) { errors++; } diff --git a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java index cd973dcbd91f2..336f02f6d3910 100644 --- a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java @@ -377,13 +377,13 @@ public class IncludeLocalesPluginTest { "--include-locales=he,id,yi", "jdk.localedata", List.of( - "/jdk.localedata/sun/text/resources/ext/FormatData_in.class", - "/jdk.localedata/sun/text/resources/ext/FormatData_in_ID.class", - "/jdk.localedata/sun/text/resources/ext/FormatData_iw.class", - "/jdk.localedata/sun/text/resources/ext/FormatData_iw_IL.class", - "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_in.class", - "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_iw.class", - "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ji.class"), + "/jdk.localedata/sun/text/resources/ext/FormatData_he.class", + "/jdk.localedata/sun/text/resources/ext/FormatData_he_IL.class", + "/jdk.localedata/sun/text/resources/ext/FormatData_id.class", + "/jdk.localedata/sun/text/resources/ext/FormatData_id_ID.class", + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_he.class", + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_id.class", + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_yi.class"), List.of( "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/thai_dict", @@ -396,8 +396,8 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"), List.of( - "(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "in", "in_ID", - "in_ID_#Latn", "iw", "iw_IL", "iw_IL_#Hebr", "ji", "ji_001", "ji_001_#Hebr"), + "(root)", "en", "en_US", "en_US_#Latn", "en_US_POSIX", "id", "id_ID", + "id_ID_#Latn", "he", "he_IL", "he_IL_#Hebr", "yi", "yi_001", "yi_001_#Hebr"), "", },