JDK-8350703 : Add standard system property stdin.encoding
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-02-25
  • Updated: 2025-07-17
  • Resolved: 2025-04-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b21Fixed
Related Reports
CSR :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8356045 :  
Description
The list of standard system properties is documented in System.getProperties(). It includes a few different encoding-related properties, in particular stdout.encoding and stderr.encoding. However, there is the possibility that stdin could be redirected to a different location than stdout or stderr, so there should be a system property for stdin as well.

Initially there won't be any uses of stdin.encoding in the JDK, but applications may want to use it in cases where they need to know what encoding to use for reading character data from stdin, for example, using an InputStreamReader or Scanner.

We also expect that there will be future uses for such a property in the JDK.
Comments
Changeset: 15f42e34 Branch: master Author: Stuart Marks <smarks@openjdk.org> Date: 2025-04-25 16:32:42 +0000 URL: https://git.openjdk.org/jdk/commit/15f42e348d4068bd90dd75b270a372353fe0ed07
25-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24738 Date: 2025-04-17 18:59:33 +0000
22-04-2025

The System.in spec should be updated to mention this new property. In addition, there should be mention in the System.in specification that, once System.in has been wrapped in an object that does charset decoding, further reading from System.in results in undefined behavior. This is because charset decoders are allowed to read extra bytes beyond the bytes comprised by the characters decoded. The intent is for System.in to be wrapped by such and object, and that object being the only one that's used for reading from standard input.
09-04-2025

Here's an initial specification draft, derived from the spec of stderr.encoding. This could use some clarification, but it's probably better to be consistent at the moment and to update all the properties at once with some future modification. « Character encoding name for System.in. The Java runtime can be started with the system property set to UTF-8, starting it with the property set to another value leads to undefined behavior. »
25-02-2025