RFR: 8285517: System.getenv() returns unexpected value if environment variable has non ASCII character [v5]
Ichiroh Takiguchi
itakiguchi at openjdk.java.net
Sat May 7 06:50:41 UTC 2022
On Fri, 6 May 2022 15:13:38 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Ichiroh Takiguchi has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8285517: System.getenv() returns unexpected value if environment variable has non ASCII character
>
> test/jdk/java/lang/ProcessBuilder/Basic.java line 606:
>
>> 604: ? Charset.forName(jnuEncoding, Charset.defaultCharset())
>> 605: : Charset.defaultCharset();
>> 606: if (new String(tested.getBytes(cs), cs).equals(tested)) {
>
> Isn't it always true that the round trip encoding to bytes and back (using the same Charset) to a string is equal()?
> And if it is always true, then the if(...) can be removed.
Above code is related to following code:
https://github.com/openjdk/jdk/blob/5212535a276a92d96ca20bdcfccfbce956febdb1/test/jdk/java/lang/ProcessBuilder/Basic.java#L1569-L1570
If `Charset.defaultCharset()` is `UTF-8`, this code is not skipped.
I think this code will be skipped on JDK17 on C locale.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8378
More information about the core-libs-dev
mailing list