RFR: 8283606: Tests may fail with zh locale on MacOS [v2]

Ioi Lam iklam at openjdk.java.net
Mon Mar 28 07:04:46 UTC 2022


On Mon, 28 Mar 2022 05:13:27 GMT, David Holmes <dholmes at openjdk.org> wrote:

> I do not think we should be trying to use JAVA_TOOL_OPTIONS to set "global" test arguments. If setting the locale via -javaoptions does not suffice due to the way tests spawn JVMs without passing on those arguments, then we should deal with the latter on a test-by-test basis IMO. I do not think there can be a single mechanism here that will always work.

There's an ideal fix, but I am not sure if we are willing to go there -- instead of hard coding all the expected messages in English, the tests should get the expected output from the localization resources bundles from javac, javadoc, etc.

Otherwise, the current fix is the best we can do. If a test expects an English output, then it should explicitly say so when spawning a new JVM.

The reason that setting LC_ALL, LANG, etc doesn't work on MacOS is here:

https://github.com/openjdk/jdk/blob/c2c0cb2a4372d78658326461562363de9a1a194f/src/java.base/macosx/native/libjava/java_props_macosx.c#L215-L223

The only case for this file to call  `getenv("LANG")` is when `CFLocaleCopyPreferredLanguages()` returns an empty array. I did some googling but I can't find a way where you can affect the results of  `CFLocaleCopyPreferredLanguages()` by twiddling with the settings in a terminal session. It doesn't work even if you use the per-app locale setting as described in here: https://osxdaily.com/2021/06/02/how-change-language-specific-apps-mac/

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

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


More information about the compiler-dev mailing list