JDK-8352917 : Incorrect native.encoding on Windows
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 25
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows
  • CPU: generic
  • Submitted: 2025-03-25
  • Updated: 2025-04-21
  • Resolved: 2025-04-15
Related Reports
Relates :  
Relates :  
Relates :  
Description
On Windows, native.encoding property is derived from format locale. This should really be the display locale instead:
---
diff --git a/src/java.base/windows/native/libjava/java_props_md.c b/src/java.base/windows/native/libjava/java_props_md.c
index 03d0acdae1e..46e1b358d20 100644
--- a/src/java.base/windows/native/libjava/java_props_md.c
+++ b/src/java.base/windows/native/libjava/java_props_md.c
@@ -630,7 +630,7 @@ GetJavaProperties(JNIEnv* env)
         LCID userDefaultUILCID = MAKELCID(userDefaultUILang, SORTIDFROMLCID(userDefaultLCID));
 
         {
-            char * display_encoding;
+            char * format_encoding;
             HANDLE hStdOutErr;
 
             // Windows UI Language selection list only cares "language"
@@ -650,13 +650,13 @@ GetJavaProperties(JNIEnv* env)
                            &sprops.format_script,
                            &sprops.format_country,
                            &sprops.format_variant,
-                           &sprops.encoding);
+                           &format_encoding);
             SetupI18nProps(userDefaultUILCID,
                            &sprops.display_language,
                            &sprops.display_script,
                            &sprops.display_country,
                            &sprops.display_variant,
-                           &display_encoding);
+                           &sprops.encoding);
 
             sprops.sun_jnu_encoding = getEncodingInternal(0);
             if (sprops.sun_jnu_encoding == NULL) {

Comments
Subsumed by JDK-8354464
15-04-2025

It's kind of moot making this change, as `sprops.encoding` will never be picked up as the `native.encoding` because it is always derived from `sprops.sun_jnu_encoding`. Making `native.encoding` from `sprops.encoding` will re-create the regression described in JDK-8275145 (if `file.encoding` is specified to `COMPAT`)
11-04-2025