RFR: 8349254: Disable "best-fit" mapping on Windows environment variables [v3]

Jaikiran Pai jpai at openjdk.org
Sat Feb 8 07:18:17 UTC 2025


On Fri, 7 Feb 2025 18:39:25 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> src/java.base/share/native/libjli/args.c line 472:
>> 
>>> 470: JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name) {
>>> 471: #ifdef _WIN32
>>> 472:     char *env = winGetEnv(var_name);
>> 
>> I see that we are limiting this call to use `_wgetenv()` (the wide-character version of `getenv()`) only to `_WIN32`. Is there any harm in using `_wgetenv()` even for `_WIN64`? Or is the `getenv()` implementation on `_WIN64` not susceptible to the issues noted in the JBS?
>
> The macro name is confusing, but `_WIN32` means Win32 API set and does not specify the target platform. This link (https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170) reads
> 
> 
> _WIN32 Defined as 1 when the compilation target is 32-bit ARM, 64-bit ARM, x86, or x64. Otherwise, undefined.
> 
> 
> So I believe `_WIN32` is correct here.

Thank you for that detail Naoto. I didn't realize `_WIN32` was a Windows standard macro - I was under the impression that it is defined by the JDK's build files and (like you noticed) even misunderstood it to be something else.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23498#discussion_r1947500611


More information about the core-libs-dev mailing list