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

file.encoding system property has an incorrect value on Windows

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 17-pool
    • core-libs
    • None
    • behavioral
    • low
    • Apps expecting the `file.encoding` initialized with `sprops->encoding` see the behavior differently.
    • System or security property
    • Implementation

    Description

      Summary

      Revert the file.encoding initialization back to JDK11's behavior.

      Problem

      With the fix to JDK-4947890, the system property file.encoding changed to be initialized to sprops->encoding, which used to be sprops->sun_jnu_encoding on non macOS platforms. This became an issue on Windows with system locale and user locale set to be different. For example, a user with a Japanese Windows (system locale = Japanese(Japan)) and user's locale English (United States) sees the following behavioral difference:

      JDK11:
      file.encoding = MS932
      sun_jnu_encoding = MS932
      
      JDK17:
      file.encoding = Cp1252
      sun_jnu_encoding = MS932

      java.nio.charset.Charset#defaultCharset() relies on this file.encoding system property, so the users encounter inconsistent default charset with the said condition on Windows.

      Solution

      Initialize file.encoding based on sun_jnu_encoding on non macOS platforms as prior to the fix to JDK-4947890.

      Specification

      N/A. This is a behavioral change only.

      Attachments

        Issue Links

          Activity

            People

              naoto Naoto Sato
              mchung Mandy Chung
              Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: