On Fri, 6 May 2022 14:23:00 GMT, Ichiroh Takiguchi <itakigu...@openjdk.org> 
wrote:

>> On JDK19 with Linux ja_JP.eucjp locale,
>> System.getenv() returns unexpected value if environment variable has 
>> Japanese EUC characters.
>> It seems this issue happens because of JEP 400.
>> Arguments for ProcessBuilder have same kind of issue.
>
> 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.

test/jdk/java/lang/System/i18nEnvArg.java line 104:

> 102:             String s = System.getenv(EUC_JP_TEXT);
> 103:             if (!EUC_JP_TEXT.equals(s)) {
> 104:                 System.err.println("ERROR: getenv() returns unexpected 
> data");

Please add the unexpected data `s` to the output string.

test/jdk/java/lang/System/i18nEnvArg.java line 108:

> 106:             if (!EUC_JP_TEXT.equals(args[0])) {
> 107:                 System.err.print("ERROR: Unexpected argument was 
> received: ");
> 108:                 for(char ch : EUC_JP_TEXT.toCharArray()) {

This is the expected value, the previous "Unexpected" labeling might be 
mis-understood.

test/jdk/java/lang/System/i18nEnvArg.java line 111:

> 109:                    System.err.printf("\\u%04X", (int)ch);
> 110:                 }
> 111:                 System.err.print("<->");

This might be clearer if labeled as the actual/incorrect value and on a 
separate line.

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

PR: https://git.openjdk.java.net/jdk/pull/8378

Reply via email to