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

Anton Artemov duke at openjdk.org
Tue Aug 26 14:44:10 UTC 2025


Hi, please consider the following changes:

In `os_windows.cpp` in a few places results returned by `GetLastError()` are stored to `errno`. However, `errno` has no relation to `GetLastError()`, and their ranges are not the same.

Results of `GetLastError()` should be stored into variables of type `DWORD`.

The removed section in `src/hotspot/share/cds/aotClassLocation.cpp` was relying on values returned by `GetLastError()` and stored to `errno` in `os::stat()`. Though the logic was correct, these values should not be stored to `errno`. The functionality is preserved by storing a **valid** value `ENOENT` to `errno` in `os::stat()`. 

Tested in tiers 1 - 3.

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

Commit messages:
 - 8364816: Removed erroneous assignment of errno.
 - Merge remote-tracking branch 'origin/master' into JDK-8364816-get-last-error
 - 8364816: GetLastError stores return value in a DWORD variable

Changes: https://git.openjdk.org/jdk/pull/26901/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26901&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8364816
  Stats: 25 lines in 2 files changed: 2 ins; 6 del; 17 mod
  Patch: https://git.openjdk.org/jdk/pull/26901.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26901/head:pull/26901

PR: https://git.openjdk.org/jdk/pull/26901


More information about the hotspot-runtime-dev mailing list