RFR: 8375013: J2DdemoTest.java - Platform default encoding used for process output
ANUPAM DEV
duke at openjdk.org
Wed Jan 14 05:04:07 UTC 2026
On Tue, 13 Jan 2026 16:52:30 GMT, Phil Race <prr 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
>
>> If these differ between the build machine and the test runner, tests can fail.
>
> How does the build machine locale matter ? Is something caching encoded output at compile time ?
Hi @prrace ,
No, there is no caching at compile time. I referred the test environment as build machine for the class J2DdemoTest.
The test runner can be any IDE or different shell with ANSI. If J2Ddemo outputs a special character (for example a non-standard character in a file path) that doesn't map correctly in ANSI, the decoding might fail or garble the text surrounding it.
So in spite of the error, the below two will never be true:
`if (test.output_contains("ERROR")) `
`if (test.output_contains("Exception")) `
Regards,
Anupam
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29190#issuecomment-3747737943
More information about the client-libs-dev
mailing list