> Although the original implementation of `JLI_Open()` borrowed from the
> code in src/hotspot/os/windows/os_windows.cpp, the improvements to
> os_windows.cpp don't seem to have been applied to java_md.c, causing
> some tests to fail when the path to JAR files is longer than `MAXPATH`
> (i.e. 260) characters on Windows (see associated JBS issue 8385024 for
> details). Since `JLI_Open()` is not just invoked inside tests, this is
> not a test-specific issue, so fixing the test is not the right solution.
>
> This patch applies the recent changes from os_windows.cpp to java_md.c
> so that `JLI_Open()` can correctly handle longer than `MAXPATH` paths.
> The new code is almost the same as that in `wide_abs_unc_path()` in
> os_windows.cpp, except that the code in java_md.c uses `JLI_MemAlloc()`
> and `JLI_MemFree()` for memory allocation and deallocation.
>
> Although it would be ideal to have just one implementation between
> HotSpot and the launcher, the dependencies of the two components
> prevents us from having a single implementation.
>
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK
> Interim AI Policy](https://openjdk.org/legal/ai).
Ashay Rane has updated the pull request incrementally with one additional
commit since the last revision:
Address PR comments
1. Optimize for the common case when the JAR path is shorter than
`MAX_PATH` by using a stack buffer of size length `MAX_PATH`. If the
full path is longer than that, then we allocate a heap buffer of the
desired size before calling `GetFullPathNameW()` with a buffer of the
right size.
2. Normalize the path before called `set_path_prefix()`, just like in
os_windows.cpp. This ensures that prefixed paths with forward
slashes work correctly.
3. Renamed `create_unc_path()` to `convert_to_absolute_path()` to
reflect the common action performed by the function.
4. Dropped the accidental overwritting of `errno` after calling
`_wopen()`.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/31209/files
- new: https://git.openjdk.org/jdk/pull/31209/files/d50cf21e..098f775a
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=31209&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=31209&range=00-01
Stats: 121 lines in 1 file changed: 101 ins; 7 del; 13 mod
Patch: https://git.openjdk.org/jdk/pull/31209.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/31209/head:pull/31209
PR: https://git.openjdk.org/jdk/pull/31209