RFR: 8375013: J2DdemoTest.java - Platform default encoding used for process output
Phil Race
prr at openjdk.org
Fri Jan 23 18:52:49 UTC 2026
On Tue, 13 Jan 2026 13:15:00 GMT, ANUPAM DEV <duke at openjdk.org> wrote:
> Hi,
>
> new String(b, 0, n) looks at the operating system's default locale. If these differ between the build machine and the test runner, tests can fail.
> StandardCharsets.UTF_8 is guaranteed to be available on all Java platforms.
>
> Since "ERROR" and "Exception" are ASCII characters, and ASCII is a subset of UTF-8, this will correctly match the tokens regardless of the underlying platform's obscure defaults.
>
> Kindly review.
>
> Regards,
> Anupam
Are you seeing any actual problems ?
The default charset is UTF-8 anyway. I don't see how your change will matter.
(https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html#%3Cinit%3E(byte%5B%5D,int,int)
Constructs a new String by decoding the specified subarray of bytes using the [default charset]
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/charset/Charset.html#defaultCharset()
The default charset is UTF-8
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29190#issuecomment-3791780402
More information about the client-libs-dev
mailing list