< prev index next >

src/java.base/windows/native/libjava/java_props_md.c

Print this page
rev 52426 : 8185496: Improve performance of system properties initialization in initPhase1
8213424: VersionProps duplicate and skipped initialization


 644         LCID userDefaultLCID = GetUserDefaultLCID();
 645         LCID systemDefaultLCID = GetSystemDefaultLCID();
 646         LCID userDefaultUILang = GetUserDefaultUILanguage();
 647 
 648         {
 649             char * display_encoding;
 650             HANDLE hStdOutErr;
 651 
 652             // Windows UI Language selection list only cares "language"
 653             // information of the UI Language. For example, the list
 654             // just lists "English" but it actually means "en_US", and
 655             // the user cannot select "en_GB" (if exists) in the list.
 656             // So, this hack is to use the user LCID region information
 657             // for the UI Language, if the "language" portion of those
 658             // two locales are the same.
 659             if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) ==
 660                 PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) {
 661                 userDefaultUILang = userDefaultLCID;
 662             }
 663 
 664             SetupI18nProps(userDefaultUILang,
 665                            &sprops.language,
 666                            &sprops.script,
 667                            &sprops.country,
 668                            &sprops.variant,
 669                            &display_encoding);
 670             SetupI18nProps(userDefaultLCID,
 671                            &sprops.format_language,
 672                            &sprops.format_script,
 673                            &sprops.format_country,
 674                            &sprops.format_variant,
 675                            &sprops.encoding);
 676             SetupI18nProps(userDefaultUILang,
 677                            &sprops.display_language,
 678                            &sprops.display_script,
 679                            &sprops.display_country,
 680                            &sprops.display_variant,
 681                            &display_encoding);
 682 
 683             sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID);
 684             if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) {
 685                 // MS claims "Vista has built-in support for HKSCS-2004.
 686                 // All of the HKSCS-2004 characters have Unicode 4.1.
 687                 // PUA code point assignments". But what it really means
 688                 // is that the HKSCS-2004 is ONLY supported in Unicode.
 689                 // Test indicates the MS950 in its zh_HK locale is a


 693                 sprops.sun_jnu_encoding = "MS950_HKSCS";
 694             }
 695 
 696             hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE);
 697             if (hStdOutErr != INVALID_HANDLE_VALUE &&
 698                 GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
 699                 sprops.sun_stdout_encoding = getConsoleEncoding();
 700             }
 701             hStdOutErr = GetStdHandle(STD_ERROR_HANDLE);
 702             if (hStdOutErr != INVALID_HANDLE_VALUE &&
 703                 GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
 704                 if (sprops.sun_stdout_encoding != NULL)
 705                     sprops.sun_stderr_encoding = sprops.sun_stdout_encoding;
 706                 else
 707                     sprops.sun_stderr_encoding = getConsoleEncoding();
 708             }
 709         }
 710     }
 711 
 712     sprops.unicode_encoding = "UnicodeLittle";
 713     /* User TIMEZONE */
 714     {
 715         /*
 716          * We defer setting up timezone until it's actually necessary.
 717          * Refer to TimeZone.getDefault(). However, the system
 718          * property is necessary to be able to be set by the command
 719          * line interface -D. Here temporarily set a null string to
 720          * timezone.
 721          */
 722         sprops.timezone = "";
 723     }
 724 
 725     /* Current directory */
 726     {
 727         WCHAR buf[MAX_PATH];
 728         if (GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR), buf) != 0)
 729             sprops.user_dir = _wcsdup(buf);
 730     }
 731 
 732     sprops.file_separator = "\\";
 733     sprops.path_separator = ";";
 734     sprops.line_separator = "\r\n";
 735 
 736     return &sprops;
 737 }
 738 
 739 jstring
 740 GetStringPlatform(JNIEnv *env, nchar* wcstr)
 741 {
 742     return (*env)->NewString(env, wcstr, (jsize)wcslen(wcstr));
 743 }


 644         LCID userDefaultLCID = GetUserDefaultLCID();
 645         LCID systemDefaultLCID = GetSystemDefaultLCID();
 646         LCID userDefaultUILang = GetUserDefaultUILanguage();
 647 
 648         {
 649             char * display_encoding;
 650             HANDLE hStdOutErr;
 651 
 652             // Windows UI Language selection list only cares "language"
 653             // information of the UI Language. For example, the list
 654             // just lists "English" but it actually means "en_US", and
 655             // the user cannot select "en_GB" (if exists) in the list.
 656             // So, this hack is to use the user LCID region information
 657             // for the UI Language, if the "language" portion of those
 658             // two locales are the same.
 659             if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) ==
 660                 PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) {
 661                 userDefaultUILang = userDefaultLCID;
 662             }
 663 






 664             SetupI18nProps(userDefaultLCID,
 665                            &sprops.format_language,
 666                            &sprops.format_script,
 667                            &sprops.format_country,
 668                            &sprops.format_variant,
 669                            &sprops.encoding);
 670             SetupI18nProps(userDefaultUILang,
 671                            &sprops.display_language,
 672                            &sprops.display_script,
 673                            &sprops.display_country,
 674                            &sprops.display_variant,
 675                            &display_encoding);
 676 
 677             sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID);
 678             if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) {
 679                 // MS claims "Vista has built-in support for HKSCS-2004.
 680                 // All of the HKSCS-2004 characters have Unicode 4.1.
 681                 // PUA code point assignments". But what it really means
 682                 // is that the HKSCS-2004 is ONLY supported in Unicode.
 683                 // Test indicates the MS950 in its zh_HK locale is a


 687                 sprops.sun_jnu_encoding = "MS950_HKSCS";
 688             }
 689 
 690             hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE);
 691             if (hStdOutErr != INVALID_HANDLE_VALUE &&
 692                 GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
 693                 sprops.sun_stdout_encoding = getConsoleEncoding();
 694             }
 695             hStdOutErr = GetStdHandle(STD_ERROR_HANDLE);
 696             if (hStdOutErr != INVALID_HANDLE_VALUE &&
 697                 GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
 698                 if (sprops.sun_stdout_encoding != NULL)
 699                     sprops.sun_stderr_encoding = sprops.sun_stdout_encoding;
 700                 else
 701                     sprops.sun_stderr_encoding = getConsoleEncoding();
 702             }
 703         }
 704     }
 705 
 706     sprops.unicode_encoding = "UnicodeLittle";
 707 
 708     /* User TIMEZONE

 709      * We defer setting up timezone until it's actually necessary.
 710      * Refer to TimeZone.getDefault(). The system property
 711      * is able to be set by the command line interface -Duser.timezone.


 712      */


 713 
 714     /* Current directory */
 715     {
 716         WCHAR buf[MAX_PATH];
 717         if (GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR), buf) != 0)
 718             sprops.user_dir = _wcsdup(buf);
 719     }
 720 
 721     sprops.file_separator = "\\";
 722     sprops.path_separator = ";";
 723     sprops.line_separator = "\r\n";
 724 
 725     return &sprops;
 726 }
 727 
 728 jstring
 729 GetStringPlatform(JNIEnv *env, nchar* wcstr)
 730 {
 731     return (*env)->NewString(env, wcstr, (jsize)wcslen(wcstr));
 732 }
< prev index next >