diff --git a/icu4j/src/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/src/com/ibm/icu/dev/test/util/ULocaleTest.java index 8fbe03f23d..80435deb3e 100644 --- a/icu4j/src/com/ibm/icu/dev/test/util/ULocaleTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/util/ULocaleTest.java @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2004-2008, International Business Machines +* Copyright (c) 2004-2009, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Alan Liu @@ -231,10 +231,23 @@ public class ULocaleTest extends TestFmwk { Locale.setDefault(backupDefault); // Set default via ULocale - ULocale.setDefault(new ULocale("ja_JP@calendar=japanese")); + ULocale ujaJP_calJP = new ULocale("ja_JP@calendar=japanese"); + ULocale.setDefault(ujaJP_calJP); if (!Locale.getDefault().equals(jaJPJP)) { errln("FAIL: ULocale#setDefault failed to set Java Locale ja_JP_JP /actual: " + Locale.getDefault()); } + // Ticket#6672 - missing keywords + defUloc = ULocale.getDefault(); + if (!defUloc.equals(ujaJP_calJP)) { + errln("FAIL: ULocale#getDefault returned " + defUloc + " /expected: ja_JP@calendar=japanese"); + } + // Set a incompatible base locale via Locale#setDefault + Locale.setDefault(Locale.US); + defUloc = ULocale.getDefault(); + if (defUloc.equals(ujaJP_calJP)) { + errln("FAIL: ULocale#getDefault returned " + defUloc + " /expected: " + ULocale.forLocale(Locale.US)); + } + Locale.setDefault(backupDefault); // We also want to map ICU locale ja@calendar=japanese to Java ja_JP_JP diff --git a/icu4j/src/com/ibm/icu/util/ULocale.java b/icu4j/src/com/ibm/icu/util/ULocale.java index dd7becf9dd..d174f3da7f 100644 --- a/icu4j/src/com/ibm/icu/util/ULocale.java +++ b/icu4j/src/com/ibm/icu/util/ULocale.java @@ -1,6 +1,6 @@ /* ****************************************************************************** -* Copyright (C) 2003-2008, International Business Machines Corporation and * +* Copyright (C) 2003-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ @@ -918,7 +918,7 @@ public final class ULocale implements Serializable { public static ULocale getDefault() { synchronized (ULocale.class) { Locale currentDefault = Locale.getDefault(); - if (defaultLocale != currentDefault) { + if (!defaultLocale.equals(currentDefault)) { defaultLocale = currentDefault; defaultULocale = new ULocale(defaultLocale); }