From: Yoshito Umaoka Date: Thu, 28 Jul 2011 17:55:33 +0000 (+0000) Subject: ICU-8734 ULocale.getDefault to return ULocale.ROOT when it is called when default... X-Git-Tag: milestone-59-0-1~4610 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=503779084583536f837ff04bde8d8f25380ac17a;p=icu ICU-8734 ULocale.getDefault to return ULocale.ROOT when it is called when default ULocale is being initialized. X-SVN-Rev: 30440 --- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java index ba731ea8053..a70c980ec63 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java @@ -526,6 +526,17 @@ public final class ULocale implements Serializable { defaultLocale = currentDefault; defaultULocale = new ULocale(defaultLocale); } + if (defaultULocale == null) { + // When Java's default locale has extensions (such as ja-JP-u-ca-japanese), + // Locale -> ULocale mapping requires BCP47 keyword mapping data that is currently + // stored in a resource bundle. However, UResourceBundle currently requires + // non-null default ULocale. For now, this implementation returns ULocale.ROOT + // to avoid the problem. + + // TODO: Consider moving BCP47 mapping data out of resource bundle later. + + return ULocale.ROOT; + } return defaultULocale; } }