RFR: 8337408: Use GetTempPath2 API instead of GetTempPath [v2]

Dhamoder Nalla dhanalla at openjdk.org
Tue Aug 20 21:08:04 UTC 2024


On Tue, 20 Aug 2024 16:17:24 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Dhamoder Nalla has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   fix missing code
>
> src/java.base/windows/native/libjava/java_props_md.c line 327:
> 
>> 325: typedef DWORD (WINAPI *GetTempPath2WFnPtr)(DWORD, LPWSTR);
>> 326: static GetTempPath2WFnPtr _GetTempPath2W = NULL;
>> 327: static BOOL _GetTempPath2WInitialized = FALSE;
> 
> GetJavaProperties should only be used once so I don't think you need to cache it.
> 
> Also I'm wondering if we can link to the function rather than using GetProcAddress. It looks like GetTempPath2 was added in Windows 8 + Windows Server 2012. I wonder if there is anyone building main line to older SDKs or Windows releases where linking to GetTempPath2 would fail.

Thanks @AlanBateman for reviewing this PR.
GetTempPath2 is available in Windows10 Build 20348 and above as per https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2w#requirements

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20600#discussion_r1723963431


More information about the serviceability-dev mailing list