Clean backport of [JDK-8360312](https://bugs.openjdk.org/browse/JDK-8360312). The bug was introduced in JDK25 and fixed in JDK26, so should be backported to JDK25.
------------- Commit messages: - Backport 712d866b72b43c839c57c3303dfb215f94c0db3b Changes: https://git.openjdk.org/jdk/pull/26198/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26198&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8360312 Stats: 25 lines in 5 files changed: 13 ins; 9 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/26198.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/26198/head:pull/26198 PR: https://git.openjdk.org/jdk/pull/26198