From 210aa040b5893aa637bd362d8065166f789ef753 Mon Sep 17 00:00:00 2001
From: Magnus Ihse Bursie Special Considerations
having slow disk access will significantly increase build times. If you
need to use a network share for the source code, see below for
suggestions on how to keep the build artifacts on a local disk.
On Windows, if using Cygwin, extra care -must be taken to make sure the environment is consistent. It is -recommended that you follow this procedure:
+On Windows, extra care must be taken to have a smooth building +experience:
+Make sure that all relevant paths have short names. Short names
+are used by the build system to create space-free alternative paths.
+Short name creation is enabled per volume. The default setting can be
+checked with the command: fsutil 8dot3name query. If short
+name creation was turned off when a directory was created, it will not
+have a short name. Whether a short name exists can be checked by running
+dir /X in the containing directory (in cmd.exe). If a short
+path is present you should see something like 'ASDF~1' being displayed
+in one of the columns of the ouput. If a directory is missing a short
+name, the safest way to get one is to enable short names for that
+particular volume with
+fsutil 8dot3name set <drive letter>: 0 (note that
+you need to run as administrator for this), and then re-create the
+particular directory. A short name should be generated automatically
+then. Another option is to manually assign a short name to the directory
+using
+fsutil file setShortName <path> <short name>.
If using Cygwin, you must make sure the +file permissions and attributes between Windows and Cygwin are +consistent. It is recommended that you follow this procedure:
Create the directory that is going to contain the top directory
of the JDK clone by using the mkdir command in the Cygwin
@@ -294,6 +314,9 @@
Do not put the JDK clone in a path under your Cygwin home directory. This is especially important if your user name contains spaces and/or mixed upper and lower case letters.
Failure to follow this procedure might result in hard-to-debug build +problems.
You need to install a git client. You have two choices, Cygwin git or Git for Windows. Unfortunately there are pros and cons with each choice.
@@ -311,9 +334,7 @@core.autocrlf to
false (this is asked during installation).Failure to follow this procedure might result in hard-to-debug build -problems.
+The JDK is a massive project, and require machines ranging from
diff --git a/doc/building.md b/doc/building.md
index 56bc860a13d97..dd926f973cbc4 100644
--- a/doc/building.md
+++ b/doc/building.md
@@ -83,19 +83,39 @@ on where and how to check out the source code.
for the source code, see below for suggestions on how to keep the build
artifacts on a local disk.
-* On Windows, if using [Cygwin](#cygwin), extra care must be taken to make sure
- the environment is consistent. It is recommended that you follow this
- procedure:
-
- * Create the directory that is going to contain the top directory of the JDK
- clone by using the `mkdir` command in the Cygwin bash shell. That is, do
- *not* create it using Windows Explorer. This will ensure that it will have
- proper Cygwin attributes, and that it's children will inherit those
- attributes.
-
- * Do not put the JDK clone in a path under your Cygwin home directory. This
- is especially important if your user name contains spaces and/or mixed
- upper and lower case letters.
+* On Windows, extra care must be taken to have a smooth building experience:
+
+ * Make sure that all relevant paths have short names. Short names are used by
+ the build system to create space-free alternative paths. Short name
+ creation is enabled per volume. The default setting can be checked with the
+ command: `fsutil 8dot3name query`. If short name creation was turned off
+ when a directory was created, it will not have a short name. Whether a
+ short name exists can be checked by running `dir /X` in the containing
+ directory (in cmd.exe). If a short path is present you should see something
+ like 'ASDF~1' being displayed in one of the columns of the ouput. If a
+ directory is missing a short name, the safest way to get one is to enable
+ short names for that particular volume with `fsutil 8dot3name set Prefer having checks inside test code. Not only does having test logic outside, e.g. verification method,
depending on asserts in product code contradict with several items above
-but also decreases test’s readability and stability. It is much easier
+but also decreases test's readability and stability. It is much easier
to understand that a test is testing when all testing logic is located
inside a test or nearby in shared test libraries. As a rule of thumb,
the closer a check to a test, the better. Prefer This is related to the informativeness
property of tests, information for other checks can help to better
-localize a defect’s root-cause. One should use Nearness
Several checks
EXPECT over ASSERT if possible.ASSERT if it
+localize a defect's root-cause. One should use ASSERT if it
is impossible to continue test execution or if it does not make much
sense. Later in the text, EXPECT forms will be used to
refer to both ASSERT/EXPECT.Floating-point comparison
eps.
Use string special macros for C strings comparisons.
-EXPECT_EQ just compares pointers’ values, which is
+
EXPECT_EQ just compares pointers' values, which is
hardly what one wants comparing C strings. GoogleTest provides
EXPECT_STREQ and EXPECT_STRNE macros to
compare C string contents. There are also case-insensitive versions
@@ -293,7 +293,7 @@
This naming scheme helps to find tests, filter them and simplifies
test failure analysis. For example, class Foo - test group
Foo, compiler logging subsystem - test group
-CompilerLogging, G1 GC — test group G1GC, and
+CompilerLogging, G1 GC - test group G1GC, and
so forth.
A test file must have test_ prefix and .cpp
@@ -345,7 +345,7 @@
All test purpose friends should have either Test or
Testable suffix.
It greatly simplifies understanding of friendship’s purpose and +
It greatly simplifies understanding of friendship's purpose and
allows statically check that private members are not exposed
unexpectedly. Having FooTest as a friend of
Foo without any comments will be understood as a necessary
@@ -435,7 +435,7 @@
Restore changed flags.
It is quite common for tests to configure JVM in a certain way
-changing flags’ values. GoogleTest provides two ways to set up
+changing flags' values. GoogleTest provides two ways to set up
environment before a test and restore it afterward: using either
constructor and destructor or SetUp and
TearDown functions. Both ways require to use a test fixture
@@ -444,7 +444,7 @@
Caveats:
Changing a flag’s value could break the invariants between flags' +
Changing a flag's value could break the invariants between flags' values and hence could lead to unexpected/unsupported JVM state.
FLAG_SET_* macros can change more than one flag (in
diff --git a/make/autoconf/basic_windows.m4 b/make/autoconf/basic_windows.m4
index fb6fc526bfa21..dac6ec15db6ca 100644
--- a/make/autoconf/basic_windows.m4
+++ b/make/autoconf/basic_windows.m4
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -159,7 +159,7 @@ AC_DEFUN([BASIC_SETUP_PATHS_WINDOWS],
else
WINENV_PREFIX_ARG="$WINENV_PREFIX"
fi
- FIXPATH_ARGS="-e $PATHTOOL -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR -c $CMD -q"
+ FIXPATH_ARGS="-e $PATHTOOL -p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR -c $CMD"
FIXPATH_BASE="$BASH $FIXPATH_DIR/fixpath.sh $FIXPATH_ARGS"
FIXPATH="$FIXPATH_BASE exec"
@@ -215,7 +215,7 @@ AC_DEFUN([BASIC_WINDOWS_FINALIZE_FIXPATH],
if test "x$OPENJDK_BUILD_OS" = xwindows; then
FIXPATH_CMDLINE=". $TOPDIR/make/scripts/fixpath.sh -e $PATHTOOL \
-p $WINENV_PREFIX_ARG -r ${WINENV_ROOT//\\/\\\\} -t $WINENV_TEMP_DIR \
- -c $CMD -q"
+ -c $CMD"
$ECHO > $OUTPUTDIR/fixpath '#!/bin/bash'
$ECHO >> $OUTPUTDIR/fixpath export PATH='"[$]PATH:'$PATH'"'
$ECHO >> $OUTPUTDIR/fixpath $FIXPATH_CMDLINE '"[$]@"'
diff --git a/make/autoconf/util_paths.m4 b/make/autoconf/util_paths.m4
index 9e3e5472c9e49..969ce5a3bf36a 100644
--- a/make/autoconf/util_paths.m4
+++ b/make/autoconf/util_paths.m4
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -58,21 +58,32 @@ AC_DEFUN([UTIL_PREPEND_TO_PATH],
# 2) The path will be absolute, and it will be in unix-style (on
# cygwin).
# $1: The name of the variable to fix
-# $2: if NOFAIL, errors will be silently ignored
+# $2: if NOFAIL, if the path cannot be resolved then errors will not be
+# reported and an empty path will be set
AC_DEFUN([UTIL_FIXUP_PATH],
[
# Only process if variable expands to non-empty
path="[$]$1"
if test "x$path" != x; then
if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
- if test "x$2" = "xNOFAIL"; then
- quiet_option="-q"
+ imported_path=`$FIXPATH_BASE -q import "$path"`
+ if test $? -ne 0 || test ! -e $imported_path; then
+ if test "x$2" != "xNOFAIL"; then
+ AC_MSG_NOTICE([The path of $1, which is given as "$path", can not be properly resolved.])
+ AC_MSG_NOTICE([Please see the section "Special Considerations" in building.md.])
+ AC_MSG_NOTICE([This is the error message given by fixpath:])
+ # Rerun fixpath without -q to get an error message
+ $FIXPATH_BASE import "$path"
+ AC_MSG_ERROR([Cannot continue])
+ else
+ imported_path=""
+ fi
fi
- imported_path=`$FIXPATH_BASE $quiet_option import "$path"`
- $FIXPATH_BASE verify "$imported_path"
+
+ $FIXPATH_BASE -q verify "$imported_path"
if test $? -ne 0; then
if test "x$2" != "xNOFAIL"; then
- AC_MSG_ERROR([The path of $1, which resolves as "$path", could not be imported.])
+ AC_MSG_ERROR([The path of $1, which resolves as "$path", could not be verified.])
else
imported_path=""
fi
@@ -83,7 +94,7 @@ AC_DEFUN([UTIL_FIXUP_PATH],
if test "x$imported_path_lower" != "x$orig_path_lower"; then
$1="$imported_path"
fi
- else
+ else # non-Windows
[ if [[ "$path" =~ " " ]]; then ]
if test "x$2" != "xNOFAIL"; then
AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
@@ -233,15 +244,19 @@ AC_DEFUN([UTIL_FIXUP_EXECUTABLE],
# This is a path with slashes, don't look at $PATH
if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
# fixpath.sh import will do all heavy lifting for us
- new_path=`$FIXPATH_BASE import "$path"`
+ new_path=`$FIXPATH_BASE -q import "$path"`
- if test ! -e $new_path; then
+ if test $? -ne 0 || test ! -e $new_path; then
# It failed, but maybe spaces were part of the path and not separating
# the command and argument. Retry using that assumption.
- new_path=`$FIXPATH_BASE import "$input"`
- if test ! -e $new_path; then
- AC_MSG_NOTICE([The command for $1, which resolves as "$input", can not be found.])
- AC_MSG_ERROR([Cannot locate $input])
+ new_path=`$FIXPATH_BASE -q import "$input"`
+ if test $? -ne 0 || test ! -e $new_path; then
+ AC_MSG_NOTICE([The command for $1, which is given as "$input", can not be properly resolved.])
+ AC_MSG_NOTICE([Please see the section "Special Considerations" in building.md.])
+ AC_MSG_NOTICE([This is the error message given by fixpath:])
+ # Rerun fixpath without -q to get an error message
+ $FIXPATH_BASE import "$input"
+ AC_MSG_ERROR([Cannot continue])
fi
# It worked, clear all "arguments"
arguments=""
@@ -353,7 +368,15 @@ AC_DEFUN([UTIL_SETUP_TOOL],
else
# Otherwise we believe it is a complete path. Use it as it is.
if test ! -x "$tool_command" && test ! -x "${tool_command}.exe"; then
- AC_MSG_ERROR([User supplied tool $1="$tool_command" does not exist or is not executable])
+ # Maybe the path had spaces in it; try again with the entire argument
+ if test ! -x "$tool_override" && test ! -x "${tool_override}.exe"; then
+ AC_MSG_ERROR([User supplied tool $1="$tool_override" does not exist or is not executable])
+ else
+ # We successfully located the executable assuming the spaces were part of the path.
+ # We can't combine using paths with spaces and arguments, so assume tool_args is empty.
+ tool_command="$tool_override"
+ tool_args=""
+ fi
fi
if test ! -x "$tool_command"; then
tool_command="${tool_command}.exe"
diff --git a/make/scripts/fixpath.sh b/make/scripts/fixpath.sh
index 3a886fee07c47..8eaf57d18f380 100644
--- a/make/scripts/fixpath.sh
+++ b/make/scripts/fixpath.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -157,11 +157,21 @@ function import_path() {
if [[ $? -eq 0 && -e "$unixpath" ]]; then
if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then
# If it is not in envroot, it's a generic windows path
- if [[ ! $winpath =~ ^[-_.:\\a-zA-Z0-9]*$ ]] ; then
+ if [[ ! $winpath =~ ^[-_.:~\\a-zA-Z0-9]*$ ]] ; then
# Path has forbidden characters, rewrite as short name
# This monster of a command uses the %~s support from cmd.exe to
# reliably convert to short paths on all winenvs.
shortpath="$($CMD /q /c for %I in \( "$winpath" \) do echo %~sI 2>/dev/null | tr -d \\n\\r)"
+ if [[ ! $shortpath =~ ^[-_.:~\\a-zA-Z0-9]*$ ]] ; then
+ if [[ $QUIET != true ]]; then
+ echo fixpath: failure: Path "'"$path"'" could not be converted to short path >&2
+ fi
+ if [[ $IGNOREFAILURES != true ]]; then
+ exit 1
+ else
+ shortpath=""
+ fi
+ fi
unixpath="$($PATHTOOL -u "$shortpath")"
# unixpath is based on short name
fi
From 45a94bfe43a4ec020f5661a6d0436036f54da36d Mon Sep 17 00:00:00 2001
From: Magnus Ihse Bursie Special Considerations
directory. This is especially important if your user name contains
spaces and/or mixed upper and lower case letters.
Failure to follow this procedure might result in hard-to-debug build -problems.
+Failure to follow these procedures might result in hard-to-debug +build problems.
You need to install a git client. You have two choices, Cygwin git or Git for Windows. Unfortunately there are pros and cons with each choice.