Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8284302

On macOS, the locale should be settable using environment LANG, LC_*

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Withdrawn
    • Icon: P4 P4
    • tbd
    • core-libs
    • None
    • behavioral
    • low
    • Hide
      Switching to the Posix locale as the basis for user.language and user.country should be transparent since the Posix locale information is derived from the macOs locale settings.
      If user has modified the LANG and LC_* environment settings, they affect the system properties `user.language`, `user.script`, `user.country`, and `user.variant`.
      Show
      Switching to the Posix locale as the basis for user.language and user.country should be transparent since the Posix locale information is derived from the macOs locale settings. If user has modified the LANG and LC_* environment settings, they affect the system properties `user.language`, `user.script`, `user.country`, and `user.variant`.
    • System or security property, Use or define an environment variable
    • Implementation

      Summary

      On macOS, the initialization of the Java default locale is changed to use the Unix environment variables for locale including LANG and LC_*. Using the Unix environment variables instead of the native macOS locale will not be a visible change unless the environment has been modified by the user.

      Problem

      On macOS, the Java runtime does not use the Posix locale APIs to initialize the Java system properties that define the default locale. The Posix locale settings are familiar to Unix users via the shell environment variables LANG and related LC_* but they are not used by the Java runtime on macOS. On macOS, the Java runtime uses the Core Foundation APIs for the locale settings. In parallel, macOS initializes the Posix locale from the Core Foundation locale. The system properties initialized are user.language, user.script, user.country, and user.variant.

      Solution

      Change the Java Runtime to set the locale related properties using the Posix setLocale APIs as is done on other Unix platforms. A fallback is provided on macOS to use the Core Foundation locale APIs if thePosix setlocale API does not provide a locale.

      Specification

      The system properties user.language, user.script, user.country, and user.variant are extracted from the BCP47 formatted string returned from the Posix setlocale API. If the string is empty or undefined, the property values are set from the corresponding macOS Core Foundation API.

            rriggs Roger Riggs
            rriggs Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: