changeset 4492:259b2536d11c

Merge
author jjg
date Wed, 17 Aug 2011 12:10:53 -0700
parents f4fe826b8034 f59c83f515e6
children e59aad6ed600
files
diffstat 4 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/Locale.java	Wed Aug 17 05:41:20 2011 -0700
+++ b/src/share/classes/java/util/Locale.java	Wed Aug 17 12:10:53 2011 -0700
@@ -1589,7 +1589,7 @@
      * @since 1.7
      */
     public String getDisplayScript() {
-        return getDisplayScript(getDefault());
+        return getDisplayScript(getDefault(Category.DISPLAY));
     }
 
     /**
--- a/src/windows/native/java/lang/java_props_md.c	Wed Aug 17 05:41:20 2011 -0700
+++ b/src/windows/native/java/lang/java_props_md.c	Wed Aug 17 12:10:53 2011 -0700
@@ -563,6 +563,18 @@
         {
             char * display_encoding;
 
+            // Windows UI Language selection list only cares "language"
+            // information of the UI Language. For example, the list
+            // just lists "English" but it actually means "en_US", and
+            // the user cannot select "en_GB" (if exists) in the list.
+            // So, this hack is to use the user LCID region information
+            // for the UI Language, if the "language" portion of those
+            // two locales are the same.
+            if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) ==
+                PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) {
+                userDefaultUILang = userDefaultLCID;
+            }
+
             SetupI18nProps(userDefaultUILang,
                            &sprops.language,
                            &sprops.script,
--- a/test/java/util/Locale/LocaleCategory.java	Wed Aug 17 05:41:20 2011 -0700
+++ b/test/java/util/Locale/LocaleCategory.java	Wed Aug 17 12:10:53 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/test/java/util/Locale/LocaleCategory.sh	Wed Aug 17 05:41:20 2011 -0700
+++ b/test/java/util/Locale/LocaleCategory.sh	Wed Aug 17 12:10:53 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