graal icon indicating copy to clipboard operation
graal copied to clipboard

[GR-71039][Native Image] java.io.Console#charset Does not follow Javadoc, charset is inconsistent with stdout.encoding

Open xiaochenxt opened this issue 2 months ago • 0 comments

Describe the Issue

JVM

Image

native-image

Image

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

java version "25" 2025-09-16 LTS Java(TM) SE Runtime Environment Oracle GraalVM 25-dev+37.1 (build 25+37-LTS-jvmci-b04) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 25-dev+37.1 (build 25+37-LTS-jvmci-b04, mixed mode, sharing)

Operating System and Version

Windows 11 22631.3880

Troubleshooting Confirmation

Run Command

Test

Expected Behavior

stdout.encoding is ms936 System.console().charset().name() is x-mswin-936

Actual Behavior

stdout.encoding is ms936 System.console().charset().name() is UTF-8

Steps to Reproduce

import static java.lang.IO.println;

void main() {
    println("file.encoding is " + System.getProperty("file.encoding"));
    println("sun.jnu.encoding is " + System.getProperty("sun.jnu.encoding"));
    println("native.encoding " + System.getProperty("native.encoding"));
    println("stdout.encoding is " + System.getProperty("stdout.encoding"));
    println("stderr.encoding is " + System.getProperty("stderr.encoding"));
    println("stdin.encoding is " + System.getProperty("stdin.encoding"));
    println("System.console().charset().name() is " + System.console().charset().name());
}

Additional Context

No response

Run-Time Log Output and Error Messages

JVM Execution Result: file.encoding is UTF-8 sun.jnu.encoding is GBK native.encoding GBK stdout.encoding is ms936 stderr.encoding is ms936 stdin.encoding is ms936 System.console().charset().name() is x-mswin-936

native-native Execution Result: file.encoding is UTF-8 sun.jnu.encoding is GBK native.encoding GBK stdout.encoding is ms936 stderr.encoding is ms936 stdin.encoding is ms936 System.console().charset().name() is UTF-8

xiaochenxt avatar Oct 18 '25 08:10 xiaochenxt