RFR: 8348828: Windows dll loading now resolves symlinks [v9]

Benjamin Peterson duke at openjdk.org
Fri Oct 17 22:25:44 UTC 2025


> Deep in the bowels of `System.loadLibrary`, `File.getCanonicalPath()` is called on the target library file before it is passed to the system library loading APIs. In JDK-8003887, `File.getCanonicalPath` was altered to resolve symlinks on Windows. This had unintended consequences for passing a symlink to `System.loadLibrary` on Windows. The underlying Windows `LoadLibrary` API inspects the file name passed to it and adds a `.dll` extension if the it is not already present. Thus, if `System.loadLibrary` was given a symlink to a file and that file didn't have a `.dll` extension, `LoadLibrary` try to load nonexistent file and fail.
> 
> Fix this problem by appending a `.` to library paths in Windows' `os::dll_load`. This trailing dot inhibits `LoadLibrary`'s own appending behavior.

Benjamin Peterson has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 15 additional commits since the last revision:

 - add test showing loading symlinked libraries with various combinations
 - revert dll_load fix
 - Merge branch 'master' into nativelibraries-fix
 - add cast
 - use os::malloc
 - Merge branch 'master' into nativelibraries-fix
 - fix compilation
 - fix grammar
 - add dot in os::dll_load rather than NativeLibraries.java
 - Merge remote-tracking branch 'origin/master' into nativelibraries-fix
 - ... and 5 more: https://git.openjdk.org/jdk/compare/3ebbd323...09de5608

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24694/files
  - new: https://git.openjdk.org/jdk/pull/24694/files/d571e826..09de5608

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24694&range=08
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24694&range=07-08

  Stats: 26638 lines in 664 files changed: 15736 ins; 8292 del; 2610 mod
  Patch: https://git.openjdk.org/jdk/pull/24694.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24694/head:pull/24694

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


More information about the core-libs-dev mailing list