JDK-8275309 : file.encoding system property has an incorrect value on Windows
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 18
  • Submitted: 2021-10-14
  • Updated: 2021-10-15
  • Resolved: 2021-10-15
Related Reports
CSR :  
Description
Summary
-------

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

Problem
-------

With the fix to [JDK-4947890][1], 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

JDK18 (with `-Dfile.encoding=COMPAT` command line option):
file.encoding = Cp1252
sun.jnu.encoding = MS932
```
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.


  [1]: https://bugs.openjdk.java.net/browse/JDK-4947890
Comments
Moving to Approved contingent on a release note being written.
15-10-2021