From 65593b749327a52ee161d879dfde44fda0fbaa5b Mon Sep 17 00:00:00 2001 From: Ashay Rane <253344819+raneashay@users.noreply.github.com> Date: Wed, 25 Feb 2026 11:39:07 -0600 Subject: [PATCH 1/3] Fix references to Windows drive letter Prior to this patch, both the build and the tests included several references to C:/. References in the build assumed that Windows is installed on C:/, which causes the build to fail when Windows is installed on a different drive. The references among tests assumed that the C:/ drive exists, which although mostly correct, is not guaranteed, making the tests fragile. This patch fixes the build references to use the `SYSTEMROOT` environment variable, which points to the Windows installation path, instead of hardcoded references to C:/Windows. This patch also updates tests to not use the presence of C:/ to detect Windows (instead relying on the output of `uname -s`) and to not assume that every Windows installation has a C:/. --- make/autoconf/basic_tools.m4 | 4 +++- make/autoconf/toolchain_microsoft.m4 | 2 +- make/scripts/fixpath.sh | 4 +++- test/jdk/com/sun/jdi/JdbReadTwiceTest.sh | 10 +++++++--- test/jdk/java/awt/Dialog/FileDialogUIUpdate.java | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/make/autoconf/basic_tools.m4 b/make/autoconf/basic_tools.m4 index 8e42f9205a454..beb58bd4c736d 100644 --- a/make/autoconf/basic_tools.m4 +++ b/make/autoconf/basic_tools.m4 @@ -56,8 +56,10 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], # Tools only needed on some platforms UTIL_LOOKUP_PROGS(LOCALE, locale) UTIL_LOOKUP_PROGS(PATHTOOL, cygpath wslpath) - UTIL_LOOKUP_PROGS(CMD, cmd.exe, $PATH:/cygdrive/c/windows/system32:/mnt/c/windows/system32:/c/windows/system32) UTIL_LOOKUP_PROGS(LSB_RELEASE, lsb_release) + + SYSTEM32_PATH=$($PATHTOOL -u "$SYSTEMROOT/system32" 2>/dev/null) + UTIL_LOOKUP_PROGS(CMD, cmd.exe, $PATH:$SYSTEM32_PATH) ]) ################################################################################ diff --git a/make/autoconf/toolchain_microsoft.m4 b/make/autoconf/toolchain_microsoft.m4 index f577cf1a2a1d6..6af344a48f61a 100644 --- a/make/autoconf/toolchain_microsoft.m4 +++ b/make/autoconf/toolchain_microsoft.m4 @@ -338,7 +338,7 @@ AC_DEFUN([TOOLCHAIN_EXTRACT_VISUAL_STUDIO_ENV], OLDPATH="$PATH" # Make sure we only capture additions to PATH needed by VS. # Clear out path, but need system dir present for vsvars cmd file to be able to run - export PATH=$WINENV_PREFIX/c/windows/system32 + export PATH=$($PATHTOOL -u "$SYSTEMROOT")/system32 # The "| cat" is to stop SetEnv.Cmd to mess with system colors on some systems # We can't pass -vcvars_ver=$VCVARS_VER here because cmd.exe eats all '=' # in bat file arguments. :-( diff --git a/make/scripts/fixpath.sh b/make/scripts/fixpath.sh index 6a524df4c680b..dcf67ce7115d0 100644 --- a/make/scripts/fixpath.sh +++ b/make/scripts/fixpath.sh @@ -88,7 +88,9 @@ function setup() { fi if [[ -z ${CMD+x} ]]; then - CMD="$DRIVEPREFIX/c/windows/system32/cmd.exe" + # Use SYSTEMROOT to find Windows directory regardless of drive letter + systemroot_unix="$($PATHTOOL -u "$SYSTEMROOT")" + CMD="$systemroot_unix/system32/cmd.exe" fi if [[ -z ${WINTEMP+x} ]]; then diff --git a/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh b/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh index 5902abe50ad69..f6894da7bcbd1 100644 --- a/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh +++ b/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh @@ -43,6 +43,10 @@ if [ -z "$TESTCLASSES" ] ; then exit 1 fi +# Detect if running on Windows +IS_WINDOWS=false +case `uname -s` in CYGWIN*|MINGW*|MSYS*) IS_WINDOWS=true ;; esac + case `uname -s` in Linux) # Need this to convert to the /.automount/... form which @@ -84,7 +88,7 @@ failIfNot() # $1 is the expected number of occurances of $2 in the jdb output. count=$1 shift - if [ -r c:/ ] ; then + if [ "$IS_WINDOWS" = "true" ] ; then sed -e 's@\\@/@g' $tmpResult > $tmpResult.1 mv $tmpResult.1 $tmpResult fi @@ -177,7 +181,7 @@ mkFiles $HOME/.jdbrc $here/jdb.ini clean -if [ ! -r c:/ ] ; then +if [ "$IS_WINDOWS" != "true" ] ; then # No symlinks on windows. echo echo "+++++++++++++++++++++++++++++++++++" @@ -191,7 +195,7 @@ if [ ! -r c:/ ] ; then fi -if [ ! -r c:/ ] ; then +if [ "$IS_WINDOWS" != "true" ] ; then # No symlinks on windows. echo echo "+++++++++++++++++++++++++++++++++++" diff --git a/test/jdk/java/awt/Dialog/FileDialogUIUpdate.java b/test/jdk/java/awt/Dialog/FileDialogUIUpdate.java index f97d947991b43..b479b748d8502 100644 --- a/test/jdk/java/awt/Dialog/FileDialogUIUpdate.java +++ b/test/jdk/java/awt/Dialog/FileDialogUIUpdate.java @@ -70,7 +70,7 @@ public FileDialogUIUpdate() { Button showButton = new Button("Show FileDialog"); setLayout(new BorderLayout()); - fd.setDirectory("c:/"); + fd.setDirectory(System.getenv("SYSTEMROOT")); showButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fd.setVisible(true); From 5674ad47eaf6469c6faba7931e4014fab90a4c2a Mon Sep 17 00:00:00 2001 From: Ashay Rane <253344819+raneashay@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:44:02 -0500 Subject: [PATCH 2/3] Address PR comments 1. Removed reference to c:/ in fixpath.sh 2. Renamed `systemroot_unix` to `systemroot` --- make/scripts/fixpath.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/make/scripts/fixpath.sh b/make/scripts/fixpath.sh index dcf67ce7115d0..9843692feb7ec 100644 --- a/make/scripts/fixpath.sh +++ b/make/scripts/fixpath.sh @@ -71,8 +71,10 @@ function setup() { fi if [[ -z ${DRIVEPREFIX+x} ]]; then - winroot="$($PATHTOOL -u c:/)" - DRIVEPREFIX="${winroot%/c/}" + drive_letter="${SYSTEMROOT%%:*}" + drive_letter_lower="$(echo "$drive_letter" | tr 'A-Z' 'a-z')" + systemroot="$($PATHTOOL -u "$SYSTEMROOT")" + DRIVEPREFIX="${systemroot%%/${drive_letter_lower}/*}" else if [[ $DRIVEPREFIX == "NONE" ]]; then DRIVEPREFIX="" @@ -89,8 +91,8 @@ function setup() { if [[ -z ${CMD+x} ]]; then # Use SYSTEMROOT to find Windows directory regardless of drive letter - systemroot_unix="$($PATHTOOL -u "$SYSTEMROOT")" - CMD="$systemroot_unix/system32/cmd.exe" + systemroot="$($PATHTOOL -u "$SYSTEMROOT")" + CMD="$systemroot/system32/cmd.exe" fi if [[ -z ${WINTEMP+x} ]]; then From 7f1ae73bfa7fb51dbd43ce3af7845e11d0f34199 Mon Sep 17 00:00:00 2001 From: Ashay Rane <253344819+raneashay@users.noreply.github.com> Date: Tue, 31 Mar 2026 17:13:55 -0500 Subject: [PATCH 3/3] Address PR suggestions --- make/autoconf/basic_tools.m4 | 15 +++++++++++++-- make/autoconf/toolchain_microsoft.m4 | 2 +- make/scripts/fixpath.sh | 10 +++++----- test/jdk/com/sun/jdi/JdbReadTwiceTest.sh | 17 ++++++++++------- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/make/autoconf/basic_tools.m4 b/make/autoconf/basic_tools.m4 index beb58bd4c736d..d75142a6dbaff 100644 --- a/make/autoconf/basic_tools.m4 +++ b/make/autoconf/basic_tools.m4 @@ -58,8 +58,19 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], UTIL_LOOKUP_PROGS(PATHTOOL, cygpath wslpath) UTIL_LOOKUP_PROGS(LSB_RELEASE, lsb_release) - SYSTEM32_PATH=$($PATHTOOL -u "$SYSTEMROOT/system32" 2>/dev/null) - UTIL_LOOKUP_PROGS(CMD, cmd.exe, $PATH:$SYSTEM32_PATH) + case "`uname -s 2>/dev/null || true`" in + *MINGW*|*MSYS*|*CYGWIN*|*NT*) HAVE_WINDOWS_ENV=yes ;; + *) HAVE_WINDOWS_ENV=no ;; + esac + + if test "x${HAVE_WINDOWS_ENV}" = "xyes"; then + if test "x${SYSTEMROOT:-}" = "x"; then + AC_MSG_ERROR([Environment variable SYSTEMROOT is not set. Please set SYSTEMROOT (e.g. C:\Windows) before building on Windows.]) + fi + fi + + SYSTEM32_PATH=$($PATHTOOL -u "${SYSTEMROOT}/system32" 2>/dev/null) + UTIL_LOOKUP_PROGS(CMD, cmd.exe, $PATH:${SYSTEM32_PATH}) ]) ################################################################################ diff --git a/make/autoconf/toolchain_microsoft.m4 b/make/autoconf/toolchain_microsoft.m4 index 6af344a48f61a..af08434ec3675 100644 --- a/make/autoconf/toolchain_microsoft.m4 +++ b/make/autoconf/toolchain_microsoft.m4 @@ -338,7 +338,7 @@ AC_DEFUN([TOOLCHAIN_EXTRACT_VISUAL_STUDIO_ENV], OLDPATH="$PATH" # Make sure we only capture additions to PATH needed by VS. # Clear out path, but need system dir present for vsvars cmd file to be able to run - export PATH=$($PATHTOOL -u "$SYSTEMROOT")/system32 + export PATH=$(${PATHTOOL} -u "${SYSTEMROOT}")/system32 # The "| cat" is to stop SetEnv.Cmd to mess with system colors on some systems # We can't pass -vcvars_ver=$VCVARS_VER here because cmd.exe eats all '=' # in bat file arguments. :-( diff --git a/make/scripts/fixpath.sh b/make/scripts/fixpath.sh index 9843692feb7ec..7644b1eb0050e 100644 --- a/make/scripts/fixpath.sh +++ b/make/scripts/fixpath.sh @@ -72,9 +72,9 @@ function setup() { if [[ -z ${DRIVEPREFIX+x} ]]; then drive_letter="${SYSTEMROOT%%:*}" - drive_letter_lower="$(echo "$drive_letter" | tr 'A-Z' 'a-z')" - systemroot="$($PATHTOOL -u "$SYSTEMROOT")" - DRIVEPREFIX="${systemroot%%/${drive_letter_lower}/*}" + drive_letter_lower="$(echo "${drive_letter}" | tr 'A-Z' 'a-z')" + cyg_systemroot="$(${PATHTOOL} -u "${SYSTEMROOT}")" + DRIVEPREFIX="${cyg_systemroot%%/${drive_letter_lower}/*}" else if [[ $DRIVEPREFIX == "NONE" ]]; then DRIVEPREFIX="" @@ -91,8 +91,8 @@ function setup() { if [[ -z ${CMD+x} ]]; then # Use SYSTEMROOT to find Windows directory regardless of drive letter - systemroot="$($PATHTOOL -u "$SYSTEMROOT")" - CMD="$systemroot/system32/cmd.exe" + cyg_systemroot="$(${PATHTOOL} -u "${SYSTEMROOT}")" + CMD="${cyg_systemroot}/system32/cmd.exe" fi if [[ -z ${WINTEMP+x} ]]; then diff --git a/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh b/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh index f6894da7bcbd1..885472ddb1c58 100644 --- a/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh +++ b/test/jdk/com/sun/jdi/JdbReadTwiceTest.sh @@ -43,18 +43,21 @@ if [ -z "$TESTCLASSES" ] ; then exit 1 fi -# Detect if running on Windows -IS_WINDOWS=false -case `uname -s` in CYGWIN*|MINGW*|MSYS*) IS_WINDOWS=true ;; esac - case `uname -s` in + *MINGW*|*MSYS*|*CYGWIN*|*NT*) + IS_WINDOWS=true + ;; Linux) + IS_WINDOWS=false + # Need this to convert to the /.automount/... form which # is what jdb will report when it reads an init file. echo TESTCLASSES=$TESTCLASSES TESTCLASSES=`(cd $TESTCLASSES; /bin/pwd)` echo TESTCLASSES=$TESTCLASSES ;; + *) + IS_WINDOWS=false esac # All output will go under this dir. We define HOME to @@ -88,7 +91,7 @@ failIfNot() # $1 is the expected number of occurances of $2 in the jdb output. count=$1 shift - if [ "$IS_WINDOWS" = "true" ] ; then + if [ "${IS_WINDOWS}" = "true" ] ; then sed -e 's@\\@/@g' $tmpResult > $tmpResult.1 mv $tmpResult.1 $tmpResult fi @@ -181,7 +184,7 @@ mkFiles $HOME/.jdbrc $here/jdb.ini clean -if [ "$IS_WINDOWS" != "true" ] ; then +if [ "${IS_WINDOWS}" != "true" ] ; then # No symlinks on windows. echo echo "+++++++++++++++++++++++++++++++++++" @@ -195,7 +198,7 @@ if [ "$IS_WINDOWS" != "true" ] ; then fi -if [ "$IS_WINDOWS" != "true" ] ; then +if [ "${IS_WINDOWS}" != "true" ] ; then # No symlinks on windows. echo echo "+++++++++++++++++++++++++++++++++++"