7079486: Locale.getDisplayScript() (no args) does not honor default DISPLAY locale
authornaoto
Wed, 17 Aug 2011 11:09:20 -0700
changeset 10339 80d9f4bc094b
parent 10338 ffaa7122547c
child 10341 3c12667717a7
7079486: Locale.getDisplayScript() (no args) does not honor default DISPLAY locale Reviewed-by: okutsu
jdk/src/share/classes/java/util/Locale.java
jdk/test/java/util/Locale/LocaleCategory.java
jdk/test/java/util/Locale/LocaleCategory.sh
--- a/jdk/src/share/classes/java/util/Locale.java	Wed Aug 17 11:09:06 2011 -0700
+++ b/jdk/src/share/classes/java/util/Locale.java	Wed Aug 17 11:09:20 2011 -0700
@@ -1589,7 +1589,7 @@
      * @since 1.7
      */
     public String getDisplayScript() {
-        return getDisplayScript(getDefault());
+        return getDisplayScript(getDefault(Category.DISPLAY));
     }
 
     /**
--- a/jdk/test/java/util/Locale/LocaleCategory.java	Wed Aug 17 11:09:06 2011 -0700
+++ b/jdk/test/java/util/Locale/LocaleCategory.java	Wed Aug 17 11:09:20 2011 -0700
@@ -56,6 +56,7 @@
                                   Locale.getDefault().getVariant())).build();
             checkDefault();
             testGetSetDefault();
+            testBug7079486();
         } finally {
             // restore the reserved locale
             Locale.setDefault(reservedLocale);
@@ -82,5 +83,24 @@
             throw new RuntimeException("setDefault() should set all default locales for all categories");
         }
     }
+
+    static void testBug7079486() {
+        Locale zh_Hans_CN = Locale.forLanguageTag("zh-Hans-CN");
+
+        // make sure JRE has zh_Hans_CN localized string
+        if (zh_Hans_CN.getDisplayScript(Locale.US).equals(zh_Hans_CN.getDisplayScript(zh_Hans_CN))) {
+            return;
+        }
+
+        Locale.setDefault(Locale.US);
+        String en_script = zh_Hans_CN.getDisplayScript();
+
+        Locale.setDefault(Locale.Category.DISPLAY, zh_Hans_CN);
+        String zh_script = zh_Hans_CN.getDisplayScript();
+
+        if (en_script.equals(zh_script)) {
+            throw new RuntimeException("Locale.getDisplayScript() (no args) does not honor default DISPLAY locale");
+        }
+    }
 }
 
--- a/jdk/test/java/util/Locale/LocaleCategory.sh	Wed Aug 17 11:09:06 2011 -0700
+++ b/jdk/test/java/util/Locale/LocaleCategory.sh	Wed Aug 17 11:09:20 2011 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # @test
-# @bug 4700857 6997928
+# @bug 4700857 6997928 7079486
 # @summary tests for Locale.getDefault(Locale.Category) and 
 #    Locale.setDefault(Locale.Category, Locale)
 # @build LocaleCategory