<i18n dev> RFR: 8238203: Return value of GetUserDefaultUILanguage() should be handled as LANGID

Yasumasa Suenaga suenaga at oss.nttdata.com
Thu Jan 30 03:36:28 UTC 2020


Hi Sato-san,

I filed it to JBS, and create webrev.
Could you review it?

   JBS: https://bugs.openjdk.java.net/browse/JDK-8238203
   webrev: http://cr.openjdk.java.net/~ysuenaga/JDK-8238203/webrev.00/


Thanks,

Yasumasa


On 2020/01/30 3:15, naoto.sato at oracle.com wrote:
> Hi Suenaga-san,
> 
> I think your fix looks reasonable. Although currently sort id is not being used, I'd replace 'SORT_DEFAULT' with 'SORTIDFROMLCID(userDefaultLCID)', which is more of a correct usage.
> 
> Naoto
> 
> On 1/28/20 11:51 PM, Yasumasa Suenaga wrote:
>> Hi all,
>>
>> I checked how JDK detects default language on Windows, but I cannot understand the code
>> in below:
>>
>> src/java.base/windows/native/libjava/java_props_md.c:
>> ```
>> LCID userDefaultUILang = GetUserDefaultUILanguage();
>> ```
>>
>> According to MSDN [1], GetUserDefaultUILanguage() returns LANGID.
>> `userDefaultUILang` is used later as LCID. I think it is wrong.
>>
>> I think we should be fix it as below.
>> If it is correct, I will file it to JBS and will send webrev.
>>
>> ```
>> diff --git a/src/java.base/windows/native/libjava/java_props_md.c b/src/java.base/windows/native/libjava/java_props_md.cindex 231f44ce2b..9068595dcf 100644
>> --- a/src/java.base/windows/native/libjava/java_props_md.c
>> +++ b/src/java.base/windows/native/libjava/java_props_md.c
>> @@ -641,7 +641,7 @@ GetJavaProperties(JNIEnv* env)
>>            */
>>           LCID userDefaultLCID = GetUserDefaultLCID();
>>           LCID systemDefaultLCID = GetSystemDefaultLCID();
>> -        LCID userDefaultUILang = GetUserDefaultUILanguage();
>> +        LANGID userDefaultUILang = GetUserDefaultUILanguage();
>>
>>           {
>>               char * display_encoding;
>> @@ -655,8 +655,8 @@ GetJavaProperties(JNIEnv* env)
>>               // for the UI Language, if the "language" portion of those
>>               // two locales are the same.
>>               if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) ==
>> -                PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) {
>> -                userDefaultUILang = userDefaultLCID;
>> +                PRIMARYLANGID(userDefaultUILang)) {
>> +                userDefaultUILang = LANGIDFROMLCID(userDefaultLCID);
>>               }
>>
>>               SetupI18nProps(userDefaultLCID,
>> @@ -665,7 +665,7 @@ GetJavaProperties(JNIEnv* env)
>>                              &sprops.format_country,
>>                              &sprops.format_variant,
>>                              &sprops.encoding);
>> -            SetupI18nProps(userDefaultUILang,
>> +            SetupI18nProps(MAKELCID(userDefaultUILang, SORT_DEFAULT),
>>                              &sprops.display_language,
>>                              &sprops.display_script,
>>                              &sprops.display_country,
>> ```
>>
>> Do you have any comments / suggestions?
>>
>>
>> Thanks,
>>
>> Yasumasa
>>
>>
>> [1] https://docs.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultuilanguage


More information about the i18n-dev mailing list