[8.9.0] Update the embedded JDK to 25.0.5.1. (#32783)

OpenJDK 25.0.0 is affected by CVE-2026-114938 ("Java4Shell"), a heap
out-of-bounds write in the x86-64 AVX-512 VBMI Base64 decoding
intrinsic.

Update the Azul Zulu embedded JDK archives to 25.0.5.1, and cherry-pick
`strip_to_jdk_home` in `src/minimize_jdk.sh` (#29003) because newer Azul
Zulu macOS archives place the JDK home under `Contents/Home/` without
top-level symlinks. The Temurin archives for Linux ppc64le, s390x, and
riscv64 remain unchanged because Adoptium has not published patched
builds for those platforms, and those non-x86 architectures are not
affected by CVE-2026-114938.

RELNOTES: Updated the embedded JDK to 25.0.5.1 to address
CVE-2026-114938 (see
https://openjdk.org/groups/vulnerability/advisories/2026-11-17).

(cherry picked from commit 30789d19b83025d021dabece6d17565d9baec582)
(cherry picked from commit 535d6331d6f6378d791e633905e60a909789948b)
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index c3b0a7e..fd362cf 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -247,7 +247,7 @@
   "moduleExtensions": {
     "//:repositories.bzl%async_profiler_repos": {
       "general": {
-        "bzlTransitiveDigest": "6Wfad+bH4h61GGrIlsdDTm2NuuD9ZFw97sH5uB5AzwU=",
+        "bzlTransitiveDigest": "moSFkUwcWIHLMiVSeNUTtr+h3x8MsV7aAPlbBW05RLg=",
         "usagesDigest": "7E4ajPe57HNsFiWMvrwxZ2yZ9nKkcBub4hrKWAVZtoE=",
         "recordedInputs": [
           "REPO_MAPPING:,abseil-cpp abseil-cpp+",
diff --git a/repositories.bzl b/repositories.bzl
index ffbbb83..320229b 100644
--- a/repositories.bzl
+++ b/repositories.bzl
@@ -80,15 +80,15 @@
     """OpenJDK distributions used to create a version of Bazel bundled with the OpenJDK."""
     http_file(
         name = "openjdk_linux_vanilla",
-        integrity = "sha256-Fk2QHlokC4wYUW9atVvBH8lomrboKQRa6oRnNW3Ns0A=",
+        integrity = "sha256-/Ho9k5a0QxNGZrnPfNlGtTLcF4H1NQxyWEmsUNFqcZg=",
         downloaded_file_path = "zulu-linux-vanilla.tar.gz",
-        url = "https://cdn.azul.com/zulu/bin/zulu25.28.85-ca-jdk25.0.0-linux_x64.tar.gz",
+        url = "https://cdn.azul.com/zulu/bin/zulu25.38.201-ca-jdk25.0.5.1-linux_x64.tar.gz",
     )
     http_file(
         name = "openjdk_linux_aarch64_vanilla",
-        integrity = "sha256-tg651UyXukFZVHg0qYzF0BYoHdKz5g50dcukkRMkvLQ=",
+        integrity = "sha256-fww1aBPeMV26xE0aKi1hpcq51qyPLN/24yyZS+XALaE=",
         downloaded_file_path = "zulu-linux-aarch64-vanilla.tar.gz",
-        url = "https://cdn.azul.com/zulu/bin/zulu25.28.85-ca-jdk25.0.0-linux_aarch64.tar.gz",
+        url = "https://cdn.azul.com/zulu/bin/zulu25.38.201-ca-jdk25.0.5.1-linux_aarch64.tar.gz",
     )
     http_file(
         name = "openjdk_linux_ppc64le_vanilla",
@@ -98,27 +98,27 @@
     )
     http_file(
         name = "openjdk_macos_x86_64_vanilla",
-        integrity = "sha256-ws3h0xPZBLeTw3YCFO76IH7Mp98E58QISr3x9rvrwno=",
+        integrity = "sha256-P3O3ynBCXXn7nFxpe5IkhzGhPUP/ltQbx0pWd44l6EY=",
         downloaded_file_path = "zulu-macos-vanilla.tar.gz",
-        url = "https://cdn.azul.com/zulu/bin/zulu25.28.85-ca-jdk25.0.0-macosx_x64.tar.gz",
+        url = "https://cdn.azul.com/zulu/bin/zulu25.38.201-ca-jdk25.0.5.1-macosx_x64.tar.gz",
     )
     http_file(
         name = "openjdk_macos_aarch64_vanilla",
-        integrity = "sha256-c/ZPa618PfMfunQPvLu+98Glzt7/u13zht15vHKrqbY=",
+        integrity = "sha256-JJ1WDVBwP3GufE+QyHKm6caR5iB4RXhtWxj9KNMLj6M=",
         downloaded_file_path = "zulu-macos-aarch64-vanilla.tar.gz",
-        url = "https://cdn.azul.com/zulu/bin/zulu25.28.85-ca-jdk25.0.0-macosx_aarch64.tar.gz",
+        url = "https://cdn.azul.com/zulu/bin/zulu25.38.201-ca-jdk25.0.5.1-macosx_aarch64.tar.gz",
     )
     http_file(
         name = "openjdk_win_vanilla",
-        integrity = "sha256-Xvz05qYTyuBsgEHeijaVtzRqrQMH05e2a/VSgc8aXLY=",
+        integrity = "sha256-AcHEz+jA4EoipG080d3Ri525+yobCoj/2Q4KpXQghF4=",
         downloaded_file_path = "zulu-win-vanilla.zip",
-        url = "https://cdn.azul.com/zulu/bin/zulu25.28.85-ca-jdk25.0.0-win_x64.zip",
+        url = "https://cdn.azul.com/zulu/bin/zulu25.38.201-ca-jdk25.0.5.1-win_x64.zip",
     )
     http_file(
         name = "openjdk_win_arm64_vanilla",
-        integrity = "sha256-9fbYqRNpVkno4mB/4Nx5yBlTslgwE6wfuXfGPLSTW/s=",
+        integrity = "sha256-w3d43p5LuwWqU1clGzZDDjccPtABeE83kv5M1N78790=",
         downloaded_file_path = "zulu-win-arm64.zip",
-        url = "https://cdn.azul.com/zulu/bin/zulu25.28.85-ca-jdk25.0.0-win_aarch64.zip",
+        url = "https://cdn.azul.com/zulu/bin/zulu25.38.201-ca-jdk25.0.5.1-win_aarch64.zip",
     )
 
     # TODO: Update to JDK 25 when available for these architectures.
diff --git a/src/minimize_jdk.sh b/src/minimize_jdk.sh
index 92da6e9..b1144a2 100755
--- a/src/minimize_jdk.sh
+++ b/src/minimize_jdk.sh
@@ -51,10 +51,8 @@
 out=$3
 ARCH=`uname -m`
 if [[ "${ARCH}" == 'ppc64le'  ]] || [[ "${ARCH}" == 's390x' ]] || [[ "${ARCH}" == 'riscv64' ]]; then
-  FULL_JDK_DIR="jdk*"
   DOCS=""
 else
-  FULL_JDK_DIR="zulu*"
   DOCS="DISCLAIMER readme.txt"
 fi
 
@@ -96,11 +94,33 @@
   done
 }
 
+# Strips an extracted JDK archive to its home directory.
+# Some JDK archives (e.g., macOS .jdk bundles) nest the JDK home inside
+# additional directories like Contents/Home/. This function detects the
+# actual JDK home by locating the 'release' file and moves it to the
+# expected top-level directory.
+strip_to_jdk_home() {
+  local dir=$1
+  local release
+  release=$(find "$dir" -name release -maxdepth 4 -print -quit)
+  if [[ -z "$release" ]]; then
+    echo "ERROR: could not find 'release' file in $dir" >&2
+    exit 1
+  fi
+  local jdk_home
+  jdk_home=$(dirname "$release")
+  if [[ "$jdk_home" != "$dir" ]]; then
+    local tmp="${dir}_tmp"
+    mv "$jdk_home" "$tmp"
+    rm -rf "$dir"
+    mv "$tmp" "$dir"
+  fi
+}
+
 if [[ "$UNAME" =~ msys_nt* ]]; then
-  mkdir "tmp.$$"
+  unzip -q "$fulljdk" -d "tmp.$$"
+  strip_to_jdk_home "tmp.$$"
   cd "tmp.$$"
-  unzip -q "../$fulljdk"
-  cd $FULL_JDK_DIR
   # We have to add this module explicitly because it is windows specific, it allows
   # the usage of the Windows truststore
   # e.g. -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT
@@ -123,15 +143,17 @@
   # These are necessary for --host_jvm_debug to work.
   cp bin/dt_socket.dll bin/jdwp.dll reduced/bin
   zip -q -X -r ../reduced.zip reduced/
-  cd ../..
-  mv "tmp.$$/reduced.zip" "$out"
+  cd ..
+  mv reduced.zip "$out"
   rm -rf "tmp.$$"
 else
   # The --no-same-owner flag instructs tar to not try to chown extracted files
   # to the owner stored in the archive - it will try to do that when running as
   # root, but fail when running inside Docker, so we explicitly disable it.
-  tar xf "$fulljdk" --no-same-owner
-  cd $FULL_JDK_DIR
+  mkdir "target_jdk.$$"
+  tar xf "$fulljdk" --no-same-owner -C "target_jdk.$$"
+  strip_to_jdk_home "target_jdk.$$"
+  cd "target_jdk.$$"
   ./bin/jlink --module-path ./jmods/ --add-modules "$modules" \
     --vm=server --strip-debug --no-man-pages \
     --add-options=" ${JVM_OPTIONS}" \
@@ -149,4 +171,5 @@
   zip -q -X -r ../reduced.zip reduced/
   cd ..
   mv reduced.zip "$out"
+  rm -rf "target_jdk.$$"
 fi