RFR: 8364816: GetLastError() in os_windows.cpp should not store value to errno [v3]

Anton Artemov duke at openjdk.org
Wed Aug 27 13:09:40 UTC 2025


On Wed, 27 Aug 2025 12:08:36 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

> I'm not sure this is the right solution. Now that we don't store the value of `GetLastError()` in errno and instead set errno to `ENOENT`, we don't detect if we get some other error than no entry. I think we should only set errno to `ENOENT` if `GetLastError()` returns either `ERROR_FILE_NOT_FOUND` or `ERROR_PATH_NOT_FOUND`.

I added this `if` case, but generally I do not think it is needed at all. 

We do not need to detect multiple flavours of failure. Simply because we are interested only in the end result, which is "does the file exist or not". If it does not, it does not matter why.  Introducing generic value` EOTHER `which means anything and nothing in the same time will serve no purpose. 


> I really think that `os::stat` should move away from using errno in this case. Also, it isn't really communicated clearly that that `os::stat()` is setting errno. I think this is best addressed in a follow-up, but it makes it harder to reason clearly about this patch.

Maybe, but it is not in the scope of this PR.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26901#discussion_r2303875760


More information about the hotspot-runtime-dev mailing list