RFR: 8359732: Make standard i/o encoding related system properties `StaticProperty` [v3]

Alan Bateman alanb at openjdk.org
Thu Jun 19 11:08:04 UTC 2025


On Wed, 18 Jun 2025 18:24:43 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> Refactored the internal handling of `stdin/out/err.encoding` to allow setting them only via command-line options by converting them into `StaticProperty`. This change prevents unexpected behavior caused by applications modifying these properties at runtime using `System.setProperty()`.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Replaces a couple more

Latest version looks okay but I think better to drop the change to System.initPhase1.

src/java.base/share/classes/java/lang/System.java line 1820:

> 1818:         // of those properties default to native.encoding
> 1819:         setOut0(newPrintStream(fdOut, StaticProperty.stdoutEncoding()));
> 1820:         initialErr = newPrintStream(fdErr, StaticProperty.stderrEncoding());

This is initPhase1 where we've just saved the initial properties. I think it would be better to not change this. It would be okay to use tempProps here too, but I think clearer as is.

-------------

PR Review: https://git.openjdk.org/jdk/pull/25860#pullrequestreview-2942535422
PR Review Comment: https://git.openjdk.org/jdk/pull/25860#discussion_r2156732745


More information about the core-libs-dev mailing list