Technical Documentation: openjdk/jdk
ℹ️ Provenance: Multi-Tier Ingestion · CodeWiki Reference
Overview (README.md)
Welcome to the JDK!
For build instructions please see the
online documentation,
or either of these files:
- doc/building.html (html version)
- doc/building.md (markdown version)
See https://openjdk.org/ for more information about the OpenJDK
Community and the JDK and see https://bugs.openjdk.org for JDK issue
tracking.
Doc Building (`doc/building.md`)
% Building the JDK
TL;DR (Instructions for the Impatient)
If you are eager to try out building the JDK, these simple steps work most of
the time. They assume that you have installed Git (and Cygwin, MSYS2 or WSL if
running on Windows), and want to clone the main-line JDK repository.
Get the complete source code:
git clone https://git.openjdk.org/jdkRun configure:
bash configureIf
configurefails due to missing dependencies (to either the
toolchain, build tools, external libraries or the boot JDK),
most of the time it prints a suggestion on how to resolve the situation on
your platform. Follow the instructions, and try runningbash configure
again.Run make:
make imagesVerify your newly built JDK:
./build/*/images/jdk/bin/java -versionRun basic tests:
make test-tier1
If any of these steps failed, or if you want to know more about build
requirements or build functionality, please continue reading this document.
Introduction
The JDK is a complex software project. Building it requires a certain amount of
technical expertise, a fair number of dependencies on external software, and
reasonably powerful hardware.
If you just want to use the JDK and not build it yourself, this document is not
for you. See for instance OpenJDK installation
for some methods of installing a prebuilt JDK.
Getting the Source Code
Make sure you are getting the correct version. At the OpenJDK Git
site you can see a list of all available
repositories. Commonly used repositories are:
The JDK Project (the main-line currently
in development): https://git.openjdk.org/jdkThe JDK Updates Project, which
has one repository per update release, e.g. https://git.openjdk.org/jdk17u
for JDK 17.
If you want to build an older version, e.g. JDK 17, it is strongly recommended
that you use the JDK Updates repository, e.g. the jdk17u, which contains
incremental updates, instead of the JDK Project repository jdk17, which was
frozen at JDK 17 GA.
If you are new to Git, a good place to start is the book Pro
Git. The rest of this document assumes a
working knowledge of Git.
Special Considerations
For a smooth building experience, it is recommended that you follow these rules
on where and how to check out the source code.
Do not check out the source code in a path which contains spaces. Chances are
the build will not work. This is most likely to be an issue on Windows
systems.Do not check out the source code in a path which has a very long name or is
nested many levels deep. Chances are you will hit an OS limitation during the
build.Put the source code on a local disk, not a network share. If possible, use an
SSD. The build process is very disk intensive, and 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.UTF-8 support is needed to compile the JDK. On Unix systems, this typically
means that theC.UTF-8oren_US.UTF-8locale needs to be available. For
Windows users, please see the section on Locale
Requirements below.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 runningdir /Xin 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 withfsutil 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 usingfsutil file setShortName <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 themkdircommand 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.
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.The Cygwin
gitclient has no line ending issues and understands Cygwin
paths (which are used throughout the JDK build system). However, it does
not currently work well with the Skara CLI tooling. Please see the Skara
wiki on Git clients for up-to-date
information about the Skara git client support.The Git for Windows client has issues with
line endings, and do not understand Cygwin paths. It does work well with
the Skara CLI tooling, however. To alleviate the line ending problems,
make sure you setcore.autocrlftofalse(this is asked during
installation).
Build Hardware Requirements
The JDK is a massive project, and require machines ranging from decent to
powerful to be able to build in a reasonable amount of time, or to be able to
complete a build at all.
We strongly recommend usage of an SSD disk for the build, since disk speed is
one of the limiting factors for build performance.
Building on x86
At a minimum, a machine with 2-4 cores is advisable, as well as 2-4 GB of RAM.
(The more cores to use, the more memory you need.) At least 6 GB of free disk
space is required.
Even for 32-bit builds, it is recommended to use a 64-bit build machine, and
instead create a 32-bit target using --with-target-bits=32.
Note: The 32-bit x86 port is deprecated and may be removed in a future release.
Building on aarch64
At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM. (The
more cores to use, the more memory you need.) At least 6 GB of free disk space
is required.
If you do not have access to sufficiently powerful hardware, it is also
possible to use cross-compiling.
Branch Protection
In order to use Branch Protection features in the VM,--enable-branch-protection must be used. This option requires C++ compiler
support for -mbranch-protection=standard in GCC 9.1.0+ or Clang 10+ on
Linux/AArch64 or for /guard:signret in Visual Studio 2019+ on Windows/ARM64.
The resulting build can be run on both machines with and without support for
branch protection in hardware. Branch Protection is fully supported for the
Linux/AArch64 target and only partially supported for the Windows/ARM64 target.
Building on 32-bit ARM
This is not recommended. Instead, see the section on Cross-compiling.
Operating System Requirements
The mainline JDK project supports Linux, macOS, AIX and Windows. Support for
other operating system, e.g. BSD, exists in separate "port" projects.
In general, the JDK can be built on a wide range of versions of these operating
systems, but the further you deviate from what is tested on a daily basis, the
more likely you are to run into problems.
This table lists the OS versions used by Oracle when building the JDK. Such
information is always subject to change, but this table is up to date at the
time of writing.
| Operating system | Vendor/version used |
|---|---|
| Linux/x64 | Oracle Linux 6.4 / 8.x |
| Linux/aarch64 | Oracle Linux 7.6 / 8.x |
| macOS | macOS 14.x |
| Windows | Windows Server 2016 |
The double version numbers for Linux are due to the hybrid model used at
Oracle, where header files and external libraries from an older version are
used when building on a more modern version of the OS.
The Build Group has a wiki page with Supported Build Platforms. From time to
time, this is updated by contributors to list successes or failures of building
on different platforms.
Windows
Windows XP is not a supported platform, but all newer Windows should be able to
build the JDK.
On Windows, it is important that you pay attention to the instructions in the
Special Considerations.
Windows is the only non-POSIX OS supported by the JDK, and as such, requires
some extra care. A POSIX support layer is required to build on Windows.
Currently, the supported such layers are Cygwin, MSYS2 and Windows Subsystem
for Linux (WSL). Of these, Cygwin is the one that has received the most
real-world testing and is likely to cause least trouble.
Internally in the build system, all paths are represented as Unix-style paths,
e.g. /cygdrive/c/git/jdk/Makefile rather than C:\git\jdk\Makefile. This
rule also applies to input to the build system, e.g. in arguments toconfigure. So, use --with-msvcr-dll=/cygdrive/c/msvcr100.dll rather than--with-msvcr-dll=c:\msvcr100.dll. For details on this conversion, see the
section on Fixpath.
Locale Requirements
Building and testing the JDK requires a well-defined locale to be guaranteed to
run correctly. On non-Windows operating systems, this is achieved using theLC_* variables, which propagate to all child processes of the build.
Unfortunately, there is no way to set the locale for a specific process like
this in Windows. Instead, changes to locale can only be made globally, which
will affect all applications run by the user. Furthermore, Windows makes a
difference between user locale and system locale, where the latter determines
e.g. the file path encoding. Both this locale settings affect building and
testing the JDK.
The recommended and supported way of building the JDK on Windows is to
set both the system locale and the user locale to US English. The system
setting can be changed by going to the Control Panel, choosing "Regional
Settings" -> "Administrative" and then pressing on the "Change System Locale"
button.
Since this is annoying for users who prefer another locale, we strive to get
the building and testing to work on other locales as well. This is on a "best
effort" level, so beware! You might get odd results in both building and
testing. If you do, remember that locales other than US English are not
supported nor recommended.
It is also imperative to install the US English language pack in Visual Studio.
For details, see Microsoft Visual Studio.
Cygwin
Install Cygwin as instructed on the home page. It is
strongly recommended to use the 64-bit version of Cygwin.
Note: Cygwin has a model of continuously updating all packages without any
easy way to install or revert to a specific version of a package. This means
that whenever you add or update a package in Cygwin, you might (inadvertently)
update tools that are used by the JDK build process, and that can cause
unexpected build problems.
The JDK requires GNU Make 4.0 or greater in Cygwin. This is usually not a
problem, since Cygwin currently only distributes GNU Make at a version above
4.0.
Apart from the basic Cygwin installation, the following packages must also be
installed:
autoconfmakezipunzip
Often, you can install these packages using the following command line:
<path to Cygwin setup>/setup-x86_64 -q -P autoconf -P make -P unzip -P zipUnfortunately, Cygwin can be unreliable in certain circumstances. If you
experience build tool crashes or strange issues when building on Windows,
please check the Cygwin FAQ on the "BLODA" list and the section on fork()
failures.
MSYS2
Install MSYS2 as instructed on the home page.
Apart from the basic MSYS2 installation, the following packages must also be
installed:
autoconftarmakezipunzip
You can install these packages using the following command line:
pacman -S autoconf tar make zip unzipWindows Subsystem for Linux (WSL)
WSL comes in two flavors, WSL1 and WSL2. These are drastically different under
the hood. WSL1 runs the binaries natively by translating Linux kernel calls
into Windows kernel calls, while WSL2 runs Linux in a virtual machine. Both
solutions have their pros and cons, and you might need to test both before
deciding which works best for you. Both WSL1 and WSL2 are supported, but to
varying degrees.
To use WSL for building the JDK, you will need Windows 10 version 1809 or
later, and you will need to install an Ubuntu guest.
It is possible to build both Windows and Linux binaries from WSL. To build
Windows binaries, you must use a Windows boot JDK (located in a
Windows-accessible directory). To build Linux binaries, you must use a Linux
boot JDK. The default behavior is to build for Windows. To build for Linux,
pass --build=x86_64-unknown-linux-gnu --openjdk-target=x86_64-unknown-linux-gnu to configure.
If building Windows binaries, the source code must be located in a Windows-
accessible directory. This is because Windows executables (such as Visual
Studio and the boot JDK) must be able to access the source code. Also, the
drive where the source is stored must be mounted as case-insensitive by
changing either /etc/fstab or /etc/wsl.conf in WSL. Individual directories may
be corrected using the fsutil tool in case the source was cloned before
changing the mount options.
Note that while it's possible to build on WSL, testing is still not fully
supported.
macOS
Apple is using a quite aggressive scheme of pushing OS updates, and coupling
these updates with required updates of Xcode. Unfortunately, this makes it
difficult for a project such as the JDK to keep pace with a continuously
updated machine running macOS. See the section on Apple Xcode
on some strategies to deal with this.
It is recommended that you use at least macOS 14 and Xcode 15.4, but
earlier versions may also work.
Starting with Xcode 26, introduced in macOS 26, the Metal toolchain no longer
comes bundled with Xcode, so it needs to be installed separately. This can
either be done via the Xcode's Settings/Components UI, or in the command line
calling xcodebuild -downloadComponent MetalToolchain.
The standard macOS environment contains the basic tooling needed to build, but
for external libraries a package manager is recommended. The JDK uses
homebrew in the examples, but feel free to use whatever
manager you want (or none).
Linux
It is often not much problem to build the JDK on Linux. The only general advice
is to try to use the compilers, external libraries and header files as provided
by your distribution.
The basic tooling is provided as part of the core operating system, but you
will most likely need to install developer packages.
For apt-based distributions (Debian, Ubuntu, etc), try this:
sudo apt-get install build-essential autoconfFor rpm-based distributions (Fedora, Red Hat, etc), try this:
sudo yum groupinstall "Development Tools"For Alpine Linux, aside from basic tooling, install the GNU versions of some
programs:
sudo apk add build-base bash grep zipAIX
Please consult the AIX section of the Supported Build Platforms OpenJDK Build
Wiki page for details about which versions of AIX are supported.
Native Compiler (Toolchain) Requirements
Large portions of the JDK consists of native code, that needs to be compiled to
be able to run on the target platform. In theory, toolchain and operating
system should be independent factors, but in practice there's more or less a
one-to-one correlation between target operating system and toolchain.
| Operating system | Supported toolchain |
|---|---|
| Linux | gcc, clang |
| macOS | Apple Xcode (using clang) |
| AIX | IBM Open XL C/C++ |
| Windows | Microsoft Visual Studio |
Please see the individual sections on the toolchains for version
recommendations. As a reference, these versions of the toolchains are used, at
the time of writing, by Oracle for the daily builds of the JDK. It should be
possible to compile the JDK with both older and newer versions, but the closer
you stay to this list, the more likely you are to compile successfully without
issues.
| Operating system | Toolchain version |
|---|---|
| Linux | gcc 14.2.0 |
| macOS | Apple Xcode 15.4 (using clang 15.0.0) |
| Windows | Microsoft Visual Studio 2022 version 17.13.2 |
All compilers are expected to be able to handle the C11 language standard for
C, and C++14 for C++.
gcc
The minimum accepted version of gcc is 10.0. Older versions will not be accepted
by configure.
The JDK is currently known to compile successfully with gcc version 14.2 or
newer.
In general, any version between these two should be usable.
clang
The minimum accepted version of clang is 13. Older versions will not be
accepted by configure.
To use clang instead of gcc on Linux, use --with-toolchain-type=clang.
Apple Xcode
The oldest supported version of Xcode is 13.0.
You will need to download Xcode either from the App Store or specific versions
can be easily located via the Xcode Releases
website.
When updating Xcode, it is advisable to keep an older version for building the
JDK. To use a specific version of Xcode you have multiple options:
- Use
xcode-select -sbefore runningconfigure, e.g.xcode-select -s /Applications/Xcode13.1.app. The drawback is that the setting
is system wide and you may have to revert it after a JDK build. - Use configure option
--with-xcode-path, e.g.configure --with-xcode-path=/Applications/Xcode13.1.appThis allows using a
specific Xcode version for a JDK build, independently of the active Xcode
version byxcode-select.
If you have recently (inadvertently) updated your OS and/or Xcode version, and
the JDK can no longer be built, please see the section on Problems with the
Build Environment, and Getting
Help to find out if there are any recent, non-merged patches
available for this update.
Microsoft Visual Studio
The minimum accepted version is Visual Studio 2019 version 16.8. (Note that
this version is often presented as "MSVC 14.28", and reported by cl.exe as
19.28.) Older versions will not be accepted by configure and will not work.
The maximum accepted version of Visual Studio is 2026.
If you have multiple versions of Visual Studio installed, configure will by
default pick the latest. You can request a specific version to be used by
setting --with-toolchain-version, e.g. --with-toolchain-version=2022.
If you have Visual Studio installed but configure fails to detect it, it may
be because of spaces in path.
You must install the US English locale, otherwise the build system might not be
able to interact properly with the compiler. You can add additional language
packs when installing Visual Studio.
If you have already installed Visual Studio without the US English language
pack, you can modify the installation to add this. You can either do this via a
GUI like this:
- Click on "Visual Studio Installer" in Start menu.
- Click "Modify".
- Select the tab "Language packs".
- Choose "English".
- Click "Modify".
or you can run it on the command line. For this to work, you need to startcmd.exe using "Run as Administrator". Then execute the following line: (note
that the " characters are essential)
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --channelId VisualStudio.16.Release --productId Microsoft.VisualStudio.Product.BuildTools --addProductLang en-us -pVisualStudio.16.Release represent VS 2019, so adjust the version number
accordingly. If you have not installed the BuildTools, but e.g.Professional, adjust the product ID accordingly.
IBM Open XL C/C++
The minimum accepted version of Open XL is 17.1.1.4. This is in essence clang
15, and will be treated as such by the OpenJDK build system.
Boot JDK Requirements
Paradoxically, building the JDK requires a pre-existing JDK. This is called the
"boot JDK". The boot JDK does not, however, have to be a JDK built directly
from the source code available in the OpenJDK Community. If you are porting the
JDK to a new platform, chances are that there already exists another JDK for
that platform that is usable as boot JDK.
The rule of thumb is that the boot JDK for building JDK major version N
should be a JDK of major version N-1, so for building JDK 18 a JDK 17 would
be suitable as boot JDK. However, the JDK should be able to "build itself", so
an up-to-date build of the current JDK source is an acceptable alternative. If
you are following the N-1 rule, make sure you've got the latest update
version, since e.g. JDK 8 GA might not be able to build JDK 9 on all platforms.
Early in the release cycle, version N-1 may not yet have been released. In
that case, the preferred boot JDK will be version N-2 until version N-1 is
available.
The configure scripts tries to locate a suitable boot JDK automatically, but
due to the lack of standard installation locations on most platforms, this
heuristics has a high likelihood to fail. If the boot JDK is not automatically
detected, or the wrong JDK is picked, use --with-boot-jdk to point to the JDK
to use.
Getting JDK Binaries
An overview of common ways to download and install prebuilt JDK binaries can be
found on https://openjdk.org/install. An alternative is to download the Oracle
JDK. Another is
Adoptium, which publishes prebuilt binaries for
various platforms.
On Linux you can also get a JDK from the Linux distribution. On apt-based
distros (like Debian and Ubuntu), sudo apt-get install openjdk-<VERSION>-jdk
is typically enough to install a JDK <VERSION>. On rpm-based distros (like
Fedora and Red Hat), try sudo yum install java-<VERSION>-openjdk-devel.
External Library Requirements
Different platforms require different external libraries. In general, libraries
are not optional - that is, they are either required or not used.
If a required library is not detected by configure, you need to provide the
path to it. There are two forms of the configure arguments to point to an
external library: --with-<LIB>= or --with-<LIB>-include= --with-<LIB>-lib=.
The first variant is more concise, but require the include files and library
files to reside in a default hierarchy under this directory. In most cases, it
works fine. As a fallback, the second version allows you to point to the
include directory and the lib directory separately.
FreeType
FreeType2 from The FreeType Project is not
required on any platform. The exception is on Unix-based platforms when
configuring such that the build artifacts will reference a system installed
library, rather than bundling the JDK's own copy.
- To install on an apt-based Linux, try running
sudo apt-get install libfreetype6-dev. - To install on an rpm-based Linux, try running
sudo yum install freetype-devel. - To install on Alpine Linux, try running
sudo apk add freetype-dev. - To install on macOS, try running
brew install freetype.
Use --with-freetype-include= and --with-freetype-lib= ifconfigure does not automatically locate the platform FreeType files.
Fontconfig
Fontconfig from freedesktop.org Fontconfig is
required on all platforms except Windows and macOS.
- To install on an apt-based Linux, try running
sudo apt-get install libfontconfig-dev. - To install on an rpm-based Linux, try running
sudo yum install fontconfig-devel. - To install on Alpine Linux, try running
sudo apk add fontconfig-dev.
Use --with-fontconfig-include= and --with-fontconfig= ifconfigure does not automatically locate the platform Fontconfig files.
CUPS
CUPS, Common UNIX Printing System header files are
required on all platforms, except Windows. Often these files are provided by
your operating system.
- To install on an apt-based Linux, try running
sudo apt-get install libcups2-dev. - To install on an rpm-based Linux, try running
sudo yum install cups-devel. - To install on Alpine Linux, try running
sudo apk add cups-dev.
Use --with-cups= if configure does not properly locate your CUPS
files.
X11
Certain X11 libraries and include files are required on
Linux.
- To install on an apt-based Linux, try running
sudo apt-get install libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev. - To install on an rpm-based Linux, try running
sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel. - To install on Alpine Linux, try running
sudo apk add libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev.
Use --with-x= if configure does not properly locate your X11 files.
ALSA
ALSA, Advanced Linux Sound Architecture is
required on Linux. At least version 0.9.1 of ALSA is required.
- To install on an apt-based Linux, try running
sudo apt-get install libasound2-dev. - To install on an rpm-based Linux, try running
sudo yum install alsa-lib-devel. - To install on Alpine Linux, try running
sudo apk add alsa-lib-dev.
Use --with-alsa= if configure does not properly locate your ALSA
files.
libffi
libffi, the Portable Foreign Function Interface Library is required when building the Zero version of
Hotspot.
- To install on an apt-based Linux, try running
sudo apt-get install libffi-dev. - To install on an rpm-based Linux, try running
sudo yum install libffi-devel. - To install on Alpine Linux, try running
sudo apk add libffi-dev.
Use --with-libffi= if configure does not properly locate your libffi
files.
Build Tools Requirements
Autoconf
The JDK build requires Autoconf on all
platforms. At least version 2.69 is required.
- To install on an apt-based Linux, try running
sudo apt-get install autoconf. - To install on an rpm-based Linux, try running
sudo yum install autoconf. - To install on Alpine Linux, try running
sudo apk add autoconf. - To install on macOS, try running
brew install autoconf. - To install on Windows, try running
/setup-x86_64 -q -P autoconf.
If configure has problems locating your installation of autoconf, you can
specify it using the AUTOCONF environment variable, like this:
AUTOCONF=<path to autoconf> configure ...GNU Make
The JDK build requires GNU Make. No other
flavors of make are supported.
At least version 3.81 of GNU Make must be used. For distributions supporting
GNU Make 4.0 or above, we strongly recommend it. GNU Make 4.0 contains useful
functionality to handle parallel building (supported by --with-output-sync)
and speed and stability improvements.
Note that configure locates and verifies a properly functioning version ofmake and stores the path to this make binary in the configuration. If you
start a build using make on the command line, you will be using the version
of make found first in your PATH, and not necessarily the one stored in the
configuration. This initial make will be used as "bootstrap make", and in a
second stage, the make located by configure will be called. Normally, this
will present no issues, but if you have a very old make, or a non-GNU Makemake in your path, this might cause issues.
If you want to override the default make found by configure, use the MAKE
configure variable, e.g. configure MAKE=/opt/gnu/make.
GNU Bash
The JDK build requires GNU Bash. No other
shells are supported.
At least version 3.2 of GNU Bash must be used.
Graphviz and Pandoc
In order to build man pages and the full docs (see the --enable-full-docs
configure option) Pandoc is required. For full docs also
Graphviz is required. Any recent versions should
work. For reference, and subject to change, Oracle builds use Graphviz
9.0.0 and Pandoc 3.6.4.
Running Configure
To build the JDK, you need a "configuration", which consists of a directory
where to store the build output, coupled with information about the platform,
the specific build machine, and choices that affect how the JDK is built.
The configuration is created by the configure script. The basic invocation of
the configure script looks like this:
bash configure [options]This will create an output directory containing the configuration and setup an
area for the build result. This directory typically looks likebuild/linux-x64-server-release, but the actual name depends on your specific
configuration. (It can also be set directly, see Using Multiple
Configurations). This directory is referred to
as $BUILD in this documentation.
configure will try to figure out what system you are running on and where all
necessary build components are. If you have all prerequisites for building
installed, it should find everything. If it fails to detect any component
automatically, it will exit and inform you about the problem.
Some command line examples:
Create a 32-bit build for Windows with FreeType2 in
C:\freetype-i586:textbash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32Create a debug build with the
serverJVM and DTrace enabled:textbash configure --enable-debug --with-jvm-variants=server --enable-dtrace
Common Configure Arguments
Here follows some of the most common and important configure argument.
To get up-to-date information on all available configure argument, please
run:
bash configure --help(Note that this help text also include general autoconf options, like--dvidir, that is not relevant to the JDK. To list only JDK-specific
features, use bash configure --help=short instead.)
Configure Arguments for Tailoring the Build
--enable-debug- Set the debug level tofastdebug(this is a shorthand
for--with-debug-level=fastdebug)--with-debug-level=<level>- Set the debug level, which can berelease,fastdebug,slowdebugoroptimized. Default isrelease.optimizedis
variant ofreleasewith additional Hotspot debug code.--with-native-debug-symbols=<method>- Specify if and how native debug
symbols should be built. Available methods arenone,internal,external,zipped. Default behavior depends on platform. See Native Debug
Symbols for more details.--with-version-string=<string>- Specify the version string this build will
be identified with.--with-version-=<value>- A group of options, where `` can be
any ofpre,opt,build,major,minor,securityorpatch. Use
these options to modify just the corresponding part of the version string
from the default, or the value provided by--with-version-string.--with-jvm-variants=<variant>[,<variant>...]- Build the specified variant
(or variants) of Hotspot. Valid variants are:server,client,minimal,core,zero,custom. Note that not all variants are possible to combine
in a single build.--enable-jvm-feature-<feature>or--disable-jvm-feature-<feature>-
Include (or exclude)<feature>as a JVM feature in Hotspot. You can also
specify a list of features to be enabled, separated by space or comma, as--with-jvm-features=<feature>[,<feature>...]. If you prefix<feature>
with a-, it will be disabled. These options will modify the default list
of features for the JVM variant(s) you are building. For thecustomJVM
variant, the default list is empty. A complete list of valid JVM features can
be found usingbash configure --help.--with-target-bits=- Create a target binary suitable for running on
a `` platform. Use this to create 32-bit output on a 64-bit build
platform, instead of doing a full cross-compile. (This is known as a
reduced build.)
On Linux, BSD and AIX, it is possible to override where Java by default
searches for runtime/JNI libraries. This can be useful in situations where
there is a special shared directory for system JNI libraries. This setting can
in turn be overridden at runtime by setting the java.library.path property.
--with-jni-libpath=- Use the specified path as a default when
searching for runtime libraries.
Configure Arguments for Native Compilation
--with-devkit=- Use this devkit for compilers, tools and resources--with-sysroot=- Use this directory as sysroot--with-extra-path=[;]- Prepend these directories to the
default path when searching for all kinds of binaries--with-toolchain-path=[;]- Prepend these directories when
searching for toolchain binaries (compilers etc)--with-extra-cflags=<flags>- Append these flags when compiling JDK C files--with-extra-cxxflags=<flags>- Append these flags when compiling JDK C++
files--with-extra-ldflags=<flags>- Append these flags when linking JDK
libraries
Configure Arguments for External Dependencies
--with-boot-jdk=- Set the path to the Boot JDK--with-freetype=- Set the path to FreeType--with-cups=- Set the path to CUPS--with-x=- Set the path to X11--with-alsa=- Set the path to ALSA--with-libffi=- Set the path to libffi--with-jtreg=- Set the path to JTReg. See Running Tests
Certain third-party libraries used by the JDK (libjpeg, giflib, libpng, lcms
and zlib) are included in the JDK repository. The default behavior of the JDK
build is to use the included ("bundled") versions of libjpeg, giflib, libpng
and lcms. For zlib, the system lib (if present) is used except on Windows and
AIX. However the bundled libraries may be replaced by an external version. To
do so, specify system as the `` option in these arguments. (The
default is bundled).
--with-libjpeg=- Use the specified source for libjpeg--with-giflib=- Use the specified source for giflib--with-libpng=- Use the specified source for libpng--with-lcms=- Use the specified source for lcms--with-zlib=- Use the specified source for zlib
On Linux, it is possible to select either static or dynamic linking of the C++
runtime. The default is static linking, with dynamic linking as fallback if the
static library is not found.
--with-stdc++lib=<method>- Use the specified method (static,dynamic
ordefault) for linking the C++ runtime.
Configure Control Variables
It is possible to control certain aspects of configure by overriding the
value of configure variables, either on the command line or in the
environment.
Normally, this is not recommended. If used improperly, it can lead to a
broken configuration. Unless you're well versed in the build system, this is
hard to use properly. Therefore, configure will print a warning if this is
detected.
However, there are a few configure variables, known as control variables
that are supposed to be overridden on the command line. These are variables
that describe the location of tools needed by the build, like MAKE or GREP.
If any such variable is specified, configure will use that value instead of
trying to autodetect the tool. For instance, bash configure MAKE=/opt/gnumake4.0/bin/make.
If a configure argument exists, use that instead, e.g. use --with-jtreg
instead of setting JTREGEXE.
Also note that, despite what autoconf claims, setting CFLAGS will not
accomplish anything. Instead use --with-extra-cflags (and similar forcxxflags and ldflags).
Running Make
When you have a proper configuration, all you need to do to build the JDK is to
run make. (But see the warning at GNU Make about running the
correct version of make.)
When running make without any arguments, the default target is used, which is
the same as running make default or make jdk. This will build a minimal (or
roughly minimal) set of compiled output (known as an "exploded image") needed
for a developer to actually execute the newly built JDK. The idea is that in an
incremental development fashion, when doing a normal make, you should only
spend time recompiling what's changed (making it purely incremental) and only
do the work that's needed to actually run and test your code.
The output of the exploded image resides in $BUILD/jdk. You can test the
newly built JDK like this: $BUILD/jdk/bin/java -version.
Common Make Targets
Apart from the default target, here are some common make targets:
hotspot- Build all of hotspot (but only hotspot)hotspot-<variant>- Build just the specified jvm variantimagesorproduct-images- Build the JDK imagedocsordocs-image- Build the documentation imagetest-image- Build the test imageallorall-images- Build all images (product, docs and test)bootcycle-images- Build images twice, second time with newly built JDK
(good for testing)clean- Remove all files generated by make, but not those generated by
configuredist-clean- Remove all files, including configuration
Run make help to get an up-to-date list of important make targets and make
control variables.
It is possible to build just a single module, a single phase, or a single phase
of a single module, by creating make targets according to these following
patterns. A phase can be either of gensrc, gendata, copy, java,launchers, or libs. See Using Fine-Grained Make Targets for more details about this functionality.
- `` - Build the specified phase and everything it depends on
<module>- Build the specified module and everything it depends on<module>-- Compile the specified phase for the specified module and
everything it depends on
Similarly, it is possible to clean just a part of the build by creating make
targets according to these patterns:
clean-<outputdir>- Remove the subdir in the output dir with the nameclean-- Remove all build results related to a certain build phaseclean-<module>- Remove all build results related to a certain moduleclean-<module>-- Remove all build results related to a certain
module and phase
Make Control Variables
It is possible to control make behavior by overriding the value of make
variables, either on the command line or in the environment.
Normally, this is not recommended. If used improperly, it can lead to a
broken build. Unless you're well versed in the build system, this is hard to
use properly. Therefore, make will print a warning if this is detected.
However, there are a few make variables, known as control variables that
are supposed to be overridden on the command line. These make up the "make
time" configuration, as opposed to the "configure time" configuration.
General Make Control Variables
JOBS- Specify the number of jobs to build with. See Build
Performance.LOG- Specify the logging level and functionality. See Checking the Build
Log FileCONFandCONF_NAME- Selecting the configuration(s) to use. See Using
Multiple Configurations
Test Make Control Variables
These make control variables only make sense when running tests. Please see
Testing the JDK (html, markdown) for details.
TESTTEST_JOBSTEST_OPTSTEST_VM_OPTSJTREGGTESTMICRO
Advanced Make Control Variables
These advanced make control variables can be potentially unsafe. See Hints and
Suggestions for Advanced Users and
Understanding the Build System for details.
SPECCONF_CHECKCOMPARE_BUILDJDK_FILTERSPEC_FILTER
Running Tests
Most of the JDK tests are using the JTReg test
framework. Make sure that your configuration knows where to find your
installation of JTReg. If this is not picked up automatically, use the--with-jtreg= option to point to the JTReg framework.
Note that this option should point to the JTReg home, i.e. the top directory,
containing lib/jtreg.jar etc.
The Adoption Group provides recent
builds of jtreg here.
Download the latest .tar.gz file, unpack it, and point --with-jtreg to thejtreg directory that you just unpacked.
Building of Hotspot Gtest suite requires the source code of Google Test
framework. The top directory, which contains both googletest and googlemock
directories, should be specified via --with-gtest. The minimum supported
version of Google Test is 1.14.0, whose source code can be obtained:
- by downloading and unpacking the source bundle from
here, or - by checking out
v1.14.0tag ofgoogletestproject:git clone -b v1.14.0 https://github.com/google/googletest
To execute the most basic tests (tier 1), use:
make test-tier1For more details on how to run tests, please see Testing the JDK
(html, markdown).
Signing
macOS
Modern versions of macOS require applications to be signed and notarized before
distribution. See Apple's documentation for more background on what this means
and how it works. To help support this, the JDK build can be configured to
automatically sign all native binaries, and the JDK bundle, with all the
options needed for successful notarization, as well as all the entitlements
required by the JDK. To enable hardened signing, use configure parameter--with-macosx-codesign=hardened and configure the signing identity you wish
to use with --with-macosx-codesign-identity=. The identity refers
to a signing identity from Apple that needs to be preinstalled on the build
host.
When not signing for distribution with the hardened option, the JDK build will
still attempt to perform adhoc signing to add the special entitlementcom.apple.security.get-task-allow to each binary. This entitlement is
required to be able to dump core files from a process. Note that adding this
entitlement makes the build invalid for notarization, so it is only added when
signing in debug mode. To explicitly enable this kind of ad hoc signing, use
configure parameter --with-macosx-codesign=debug. It will be enabled by
default in most cases.
It's also possible to completely disable any explicit codesign operations done
by the JDK build using the configure parameter --without-macosx-codesign. The
exact behavior then depends on the architecture. For macOS on x64, it (at least
at the time of this writing) results in completely unsigned binaries that
should still work fine for development and debugging purposes. On aarch64, the
Xcode linker will apply a default "ad hoc" signing, without any entitlements.
Such a build does not allow dumping core files.
The default mode "auto" will try for hardened signing if the debug level isrelease and either the default identity or the specified identity is valid.
If hardened isn't possible, then debug signing is chosen if it works. If
nothing works, the codesign build step is disabled.
Cross-Compiling
Cross-compiling means using one platform (the build platform) to generate
output that can ran on another platform (the target platform).
The typical reason for cross-compiling is that the build is performed on a more
powerful desktop computer, but the resulting binaries will be able to run on a
different, typically low-performing system. Most of the complications that
arise when building for embedded is due to this separation of build and
target systems.
This requires a more complex setup and build procedure. This section assumes
you are familiar with cross-compiling in general, and will only deal with the
particularities of cross-compiling the JDK. If you are new to cross-compiling,
please see the external links at Wikipedia for a good start
on reading materials.
Cross-compiling the JDK requires you to be able to build both for the build
platform and for the target platform. The reason for the former is that we need
to build and execute tools during the build process, both native tools and Java
tools.
If all you want to do is to compile a 32-bit version, for the same OS, on a
64-bit machine, consider using --with-target-bits=32 instead of doing a
full-blown cross-compilation. (While this surely is possible, it's a lot more
work and will take much longer to build.)
Setting up a cross-compilation environment by hand is time-consuming and error
prone. It is highly recommended that you use one of the automated methods
described in Cross compiling the easy way.
Specifying the Target Platform
You must specify the target platform when cross-compiling. Doing so will also
automatically turn the build into a cross-compiling mode. The simplest way to
do this is to use the --openjdk-target argument, e.g.--openjdk-target=arm-linux-gnueabihf. or --openjdk-target=aarch64-oe-linux.
This will automatically set the --host and --target options for autoconf,
which can otherwise be confusing. (In autoconf terminology, the "target" is
known as "host", and "target" is used for building a Canadian cross-compiler.)
If --build has not been explicitly passed to configure, --openjdk-target
will autodetect the build platform and internally set the flag automatically,
otherwise the platform that was explicitly passed to --build will be used
instead.
Boot JDK and Build JDK
When cross-compiling, make sure you use a boot JDK that runs on the build
system, and not on the target system.
To be able to build, we need a "Build JDK", which is a JDK built from the
current sources (that is, the same as the end result of the entire build
process), but able to run on the build system, and not the target system.
(In contrast, the Boot JDK should be from an older release, e.g. JDK 8 when
building JDK 9.)
The build process will create a minimal Build JDK for you, as part of building.
To speed up the build, you can use --with-build-jdk to configure to point
to a pre-built Build JDK. Please note that the build result is unpredictable,
and can possibly break in subtle ways, if the Build JDK does not exactly
match the current sources.
Toolchain Considerations
You will need two copies of your toolchain, one which generates output that can
run on the target system (the normal, or target, toolchain), and one that
generates output that can run on the build system (the build toolchain).
If you are cross-compiling using gcc, it is recommended to use the gcc standard
where you prefix cross-compiling tools with the target denominator. If you
follow this standard, configure is likely to pick up the toolchain correctly.
The build toolchain will be auto-detected just the same way the normal
build/target toolchain will be auto-detected when not cross-compiling. If
this is not what you want, or if the auto-detection fails, you can specify a
devkit containing the build toolchain using --with-build-devkit toconfigure, or by giving BUILD_CC and BUILD_CXX arguments.
It is often helpful to locate the cross-compilation tools, headers and
libraries in a separate directory, outside the normal path, and point out that
directory to configure. Do this by setting the sysroot (--with-sysroot) and
appending the directory when searching for cross-compilations tools
(--with-toolchain-path). As a compact form, you can also use --with-devkit
to point to a single directory, if it is correctly setup. (Seemake/autoconf/basics.m4 for details.)
Native Libraries
You will need copies of external native libraries for the target system
present on the build machine while building.
Take care not to replace the build system's version of these libraries by
mistake, as that can render the build machine unusable.
Make sure that the libraries you point to (ALSA, X11, etc) are for the target
platform, not the build platform.
ALSA
You will need alsa libraries suitable for your target system. In most cases,
using Debian's pre-built libraries work fine.
Note that alsa is needed even if you only want to build a headless JDK.
Go to Debian Package Search,
search for thelibasound2andlibasound2-devpackages for your target
system, and download them to /tmp.Install the libraries into the cross-compilation toolchain. For instance:
textcd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb . dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .If alsa is not properly detected by
configure, you can specify it by--with-alsa.
X11
When not building a headless JDK, you will need X11 libraries suitable for your
target system. In most cases, using Debian's pre-built libraries work fine.
Go to Debian Package Search,
search for the following packages for your target system, and download them
to /tmp/target-x11:libxilibxi-devx11proto-core-devx11proto-input-devx11proto-kb-devx11proto-render-devx11proto-xext-devlibice-devlibxrenderlibxrender-devlibxrandr-devlibsm-devlibxt-devlibx11libx11-devlibxtstlibxtst-devlibxextlibxext-dev
Install the libraries into the cross-compilation toolchain. For instance:
textcd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr mkdir X11R6 cd X11R6 for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done mv usr/* . cd lib cp arm-linux-gnueabihf/* .You can ignore the following messages, since these libraries are not needed
to successfully complete a full JDK build.textcp: cannot stat `arm-linux-gnueabihf/libICE.so': No such file or directory cp: cannot stat `arm-linux-gnueabihf/libSM.so': No such file or directory cp: cannot stat `arm-linux-gnueabihf/libXt.so': No such file or directoryIf the X11 libraries are not properly detected by
configure, you can point
them out by--with-x.
Verifying the Build
The build will end up in a directory named likebuild/linux-arm-normal-server-release.
Inside this build output directory, the images/jdk will contain the newly
built JDK, for your target system.
Copy these folders to your target system. Then you can run e.g.images/jdk/bin/java -version.
Cross-Compiling the Easy Way
Setting up a proper cross-compilation environment can be a lot of work.
Fortunately there are ways that more or less automate this process. Here are
two recommended methods, using the "devkits" that can be generated by the JDK
build system, or by using the debootstrap command in Debian. The former works
on all Linux distributions, the latter only on Debian and derivatives. Both
solution only work for gcc.
The devkit method is regularly used for testing by Oracle, and the debootstrap
method is regularly used in GitHub Actions testing.
Using OpenJDK Devkits
The JDK build system provides out-of-the box support for creating and using so
called devkits. A devkit is basically a collection of a cross-compiling
toolchain and a sysroot environment which can easily be used together with the--with-devkit configure option to cross compile the JDK. On Linux/x86_64, the
following command:
bash configure --with-devkit=<devkit-path> --openjdk-target=ppc64le-linux-gnu && makewill configure and build the JDK for Linux/ppc64le assuming that <devkit-path>
points to a Linux/x86_64 to Linux/ppc64le devkit.
Devkits can be created from the make/devkit directory by executing:
make [ TARGETS="<TARGET_TRIPLET>+" ] [ BASE_OS=<OS> ] [ BASE_OS_VERSION=<VER> ]where TARGETS contains one or more TARGET_TRIPLETs of the form described in
section 3.4 of the GNU Autobook. If no targets are
given, a native toolchain for the current platform will be created. Currently,
at least the following targets are known to work:
| Supported devkit targets |
|---|
| x86_64-linux-gnu |
| aarch64-linux-gnu |
| arm-linux-gnueabihf |
| ppc64le-linux-gnu |
| riscv64-linux-gnu |
| s390x-linux-gnu |
BASE_OS must be one of OL for Oracle Linux or Fedora. The release/version
of the base OS can be specified using the BASE_OS_VERSION option. If the build
is successful, the new devkits can be found in the build/devkit/result
subdirectory:
cd make/devkit
make TARGETS="ppc64le-linux-gnu aarch64-linux-gnu" BASE_OS=Fedora
ls -1 ../../build/devkit/result/
x86_64-linux-gnu-to-aarch64-linux-gnu
x86_64-linux-gnu-to-ppc64le-linux-gnuNotice that devkits are not only useful for targeting different build
platforms. Because they contain the full build dependencies for a system (i.e.,
compiler and root file system/sysroot), they can easily be used to build
well-known, reliable, and reproducible build environments. You can, for example,
create and use a devkit with a version of the GCC compiler not provided by the
host OS, using a sysroot from an older Linux distribution to produce JDK
binaries which will run on all Linux systems with newer runtime libraries.
Using Debian debootstrap
On Debian (or a derivative like Ubuntu), you can create sysroots for foreign
architectures with tools provided by the OS. You can use debootstrap to
create a target system chroot directory, which would have the native
libraries and headers specific to that target system. After that, you can use
the cross-compiler on the build system, pointing into the chroot to get the
build dependencies right. This allows building for foreign architectures with
native compilation speed.
For example, cross-compiling to AArch64 from x86_64 could be done like this:
Install cross-compiler on the build system:
textapt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnuCreate chroot on the build system, configuring it for target system:
textsudo debootstrap \ --arch=arm64 \ --verbose \ --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \ --resolve-deps \ buster \ ~/sysroot-arm64 \ https://httpredir.debian.org/debian/To create an Ubuntu-based chroot:
textsudo debootstrap \ --arch=arm64 \ --verbose \ --components=main,universe \ --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \ --resolve-deps \ jammy \ ~/sysroot-arm64 \ http://ports.ubuntu.com/ubuntu-ports/Note that
symlinksis in the universe repository.Make sure the symlinks inside the newly created chroot point to proper
locations:textsudo chroot ~/sysroot-arm64 symlinks -cr .Configure and build with newly created chroot as sysroot/toolchain-path:
textsh ./configure \ --openjdk-target=aarch64-linux-gnu \ --with-sysroot=~/sysroot-arm64 make images ls build/linux-aarch64-server-release/
The build does not create new files in that chroot, so it can be reused for
multiple builds without additional cleanup.
The build system should automatically detect the toolchain paths and
dependencies, but sometimes it might require a little nudge with:
Native compilers: override
CCorCXXfor./configureFreetype lib location: override
--with-freetype-lib, for example${sysroot}/usr/lib/${target}/Freetype includes location: override
--with-freetype-includefor example${sysroot}/usr/include/freetype2/X11 libraries location: override
--x-libraries, for example${sysroot}/usr/lib/${target}/
Architectures that are known to successfully cross-compile like this are:
| Target | Debian tree | Debian arch | --openjdk-target=... |
--with-jvm-variants=... |
|---|---|---|---|---|
| x86 | buster | i386 | i386-linux-gnu | (all) |
| arm | buster | armhf | arm-linux-gnueabihf | (all) |
| aarch64 | buster | arm64 | aarch64-linux-gnu | (all) |
| ppc64le | buster | ppc64el | powerpc64le-linux-gnu | (all) |
| s390x | buster | s390x | s390x-linux-gnu | (all) |
| mipsle | buster | mipsel | mipsel-linux-gnu | zero |
| mips64le | buster | mips64el | mips64el-linux-gnueabi64 | zero |
| armel | buster | arm | arm-linux-gnueabi | zero |
| ppc | sid | powerpc | powerpc-linux-gnu | zero |
| ppc64be | sid | ppc64 | powerpc64-linux-gnu | (all) |
| m68k | sid | m68k | m68k-linux-gnu | zero |
| alpha | sid | alpha | alpha-linux-gnu | zero |
| sh4 | sid | sh4 | sh4-linux-gnu | zero |
| riscv64 | sid | riscv64 | riscv64-linux-gnu | (all) |
Considerations for Specific Targets
Building for ARM32
A common cross-compilation target is the ARM CPU. When building for ARM, it is
recommended to set the ABI profile. A number of pre-defined ABI profiles are
available using --with-abi-profile: arm-vfp-sflt, arm-vfp-hflt,arm-sflt, armv5-vfp-sflt and armv6-vfp-hflt. Note that soft-float ABIs
are no longer properly supported by the JDK.
Building for RISC-V
The RISC-V community provides a basic GNU compiler toolchain, but the external
libraries required by the JDK complicate the
building process. The placeholder <toolchain-installed-path> shown below is
the path where you want to install the toolchain.
Install the RISC-V GNU compiler toolchain:
textgit clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain cd riscv-gnu-toolchain ./configure --prefix=<toolchain-installed-path> make linux export PATH=<toolchain-installed-path>/bin:$PATHCross-compile all the required libraries:
text# An example for libffi git clone https://github.com/libffi/libffi cd libffi ./configure --host=riscv64-unknown-linux-gnu --prefix=<toolchain-installed-path>/sysroot/usr make make installConfigure and build the JDK:
textbash configure \ --with-boot-jdk=$BOOT_JDK \ --openjdk-target=riscv64-linux-gnu \ --with-sysroot=<toolchain-installed-path>/sysroot \ --with-toolchain-path=<toolchain-installed-path>/bin \ --with-extra-path=<toolchain-installed-path>/bin make images
Building for musl
Just like it's possible to cross-compile for a different CPU, it's possible to
cross-compile for musl libc on a glibc-based build system. A devkit
suitable for most target CPU architectures can be obtained from
musl.cc. After installing the required packages in the
sysroot, configure the build with --openjdk-target:
sh ./configure --with-jvm-variants=server \
--with-boot-jdk=$BOOT_JDK \
--with-build-jdk=$BUILD_JDK \
--openjdk-target=x86_64-unknown-linux-musl \
--with-devkit=$DEVKIT \
--with-sysroot=$SYSROOTand run make normally.
Building for Windows AArch64
The Visual Studio Build Tools can be used for building the JDK without a full
Visual Studio installation. To set up the Visual Studio 2022 Build Tools on a
Windows AArch64 machine for a native build, launch the installer as follows
in a Windows command prompt:
vs_buildtools.exe --quiet --wait --norestart --nocache ^
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" ^
--add Microsoft.VisualStudio.Component.VC.CoreBuildTools ^
--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^
--add Microsoft.VisualStudio.Component.Windows11SDK.22621To generate Windows AArch64 builds using Cygwin on a Windows x64 machine,
you must set the proper target platform by adding--openjdk-target=aarch64-unknown-cygwin to your configure command line.
Build Performance
Building the JDK requires a lot of horsepower. Some of the build tools can be
adjusted to utilize more or less of resources such as parallel threads and
memory. The configure script analyzes your system and selects reasonable
values for such options based on your hardware. If you encounter resource
problems, such as out of memory conditions, you can modify the detected values
with:
--with-num-cores-- number of cores in the build system, e.g.--with-num-cores=8.--with-memory-size-- memory (in MB) available in the build system, e.g.--with-memory-size=1024
You can also specify directly the number of build jobs to use with--with-jobs=N to configure, or JOBS=N to make. Do not use the -j flag
to make. In most cases it will be ignored by the makefiles, but it can cause
problems for some make targets.
It might also be necessary to specify the JVM arguments passed to the Boot JDK,
using e.g. --with-boot-jdk-jvmargs="-Xmx8G". Doing so will override the
default JVM arguments passed to the Boot JDK.
At the end of a successful execution of configure, you will get a performance
summary, indicating how well the build will perform. Here you will also get
performance hints. If you want to build fast, pay attention to those!
If you want to tweak build performance, run with make LOG=info to get a build
time summary at the end of the build process.
Disk Speed
If you are using network shares, e.g. via NFS, for your source code, make sure
the build directory is situated on local disk (e.g. by ln -s /localdisk/jdk-build $JDK-SHARE/build). The performance penalty is extremely
high for building on a network share; close to unusable.
Also, make sure that your build tools (including Boot JDK and toolchain) is
located on a local disk and not a network share.
As has been stressed elsewhere, do use SSD for source code and build directory,
as well as (if possible) the build tools.
Virus Checking
The use of virus checking software, especially on Windows, can significantly
slow down building of the JDK. If possible, turn off such software, or exclude
the directory containing the JDK source code from on-the-fly checking.
Ccache
The JDK build supports building with ccache when using gcc or clang. Using
ccache can radically speed up compilation of native code if you often rebuild
the same sources. Your mileage may vary however, so we recommend evaluating it
for yourself. To enable it, make sure it's on the path and configure with--enable-ccache.
Sccache
The JDK build supports building with sccache when using gcc, clang, or Microsoft
toolchains. To enable it, make sure the sccache binary is on the path (or
specify the path to the binary using the SCCACHE argument to the configure
script) and configure with --enable-sccache. To optionally specify where
sccache stores its cache files, use --with-sccache-dir. Precompiled headers
are disabled when sccache is enabled.
Precompiled Headers
By default, the Hotspot build uses pre-compiled headers (PCH) on the toolchains
were it is properly supported (clang, gcc, and Visual Studio). Normally, this
speeds up the build process, but in some circumstances, it can actually slow
things down.
You can experiment by disabling pre-compiled headers using--disable-precompiled-headers.
Icecc / Icecream
icecc/icecream is a simple way to setup a
distributed compiler network. If you have multiple machines available for
building the JDK, you can drastically cut individual build times by utilizing
it.
To use, setup an icecc network, and install icecc on the build machine. Then
run configure using --enable-icecc.
Using the javac Server
To speed up compilation of Java code, especially during incremental
compilations, the javac server is automatically enabled in the configuration
step by default. To explicitly enable or disable the javac server, use either--enable-javac-server or --disable-javac-server.
Building the Right Target
Selecting the proper target to build can have dramatic impact on build time.
For normal usage, jdk or the default target is just fine. You only need to
build images for shipping, or if your tests require it.
See also Using Fine-Grained Make Targets on
how to build an even smaller subset of the product.
Troubleshooting
If your build fails, it can sometimes be difficult to pinpoint the problem or
find a proper solution.
Locating the Source of the Error
When a build fails, it can be hard to pinpoint the actual cause of the error.
In a typical build process, different parts of the product build in parallel,
with the output interlaced.
Build Failure Summary
To help you, the build system will print a failure summary at the end. It looks
like this:
ERROR: Build failed for target 'hotspot' in configuration 'linux-x64' (exit code 2)
=== Output from failing command(s) repeated here ===
* For target hotspot_variant-server_libjvm_objs_psMemoryPool.o:
/src/jdk/hotspot/src/share/vm/services/psMemoryPool.cpp:1:1: error: 'failhere' does not name a type
... (rest of output omitted)
* All command lines available in /src/jdk/build/linux-x64/make-support/failure-logs.
=== End of repeated output ===
=== Make failed targets repeated here ===
lib/CompileJvm.gmk:207: recipe for target '/src/jdk/build/linux-x64/hotspot/variant-server/libjvm/objs/psMemoryPool.o' failed
make/Main.gmk:263: recipe for target 'hotspot-server-libs' failed
=== End of repeated output ===
HELP: Try searching the build log for the name of the first failed target.
HELP: Run 'make doctor' to diagnose build problems.Let's break it down! First, the selected configuration, and the top-level
target you entered on the command line that caused the failure is printed.
Then, between the Output from failing command(s) repeated here and End of repeated output the first lines of output (stdout and stderr) from the actual
failing command is repeated. In most cases, this is the error message that
caused the build to fail. If multiple commands were failing (this can happen in
a parallel build), output from all failed commands will be printed here.
The path to the failure-logs directory is printed. In this file you will find
a <target>.log file that contains the output from this command in its
entirety, and also a <target>.cmd, which contain the complete command line
used for running this command. You can re-run the failing command by executing. /<target>.cmd in your shell.
Another way to trace the failure is to follow the chain of make targets, from
top-level targets to individual file targets. Between Make failed targets repeated here and End of repeated output the output from make showing this
chain is repeated. The first failed recipe will typically contain the full path
to the file in question that failed to compile. Following lines will show a
trace of make targets why we ended up trying to compile that file.
Finally, some hints are given on how to locate the error in the complete log.
In this example, we would try searching the log file for "psMemoryPool.o".
Another way to quickly locate make errors in the log is to search for "] Error" or "***".
Note that the build failure summary will only help you if the issue was a
compilation failure or similar. If the problem is more esoteric, or is due to
errors in the build machinery, you will likely get empty output logs, and No indication of failed target found instead of the make target chain.
Checking the Build Log File
The output (stdout and stderr) from the latest build is always stored in$BUILD/build.log. The previous build log is stored as build.log.old. This
means that it is not necessary to redirect the build output yourself if you
want to process it.
You can increase the verbosity of the log file, by the LOG control variable
to make. If you want to see the command lines used in compilations, useLOG=cmdlines. To increase the general verbosity, use LOG=info, LOG=debug
or LOG=trace. Both of these can be combined with cmdlines, e.g.LOG=info,cmdlines. The debug log level will show most shell commands
executed by make, and trace will show all. Beware that both these log levels
will produce a massive build log!
Fixing Unexpected Build Failures
Most of the time, the build will fail due to incorrect changes in the source
code.
Sometimes the build can fail with no apparent changes that have caused the
failure. If this is the first time you are building the JDK on this particular
computer, and the build fails, the problem is likely with your build
environment. But even if you have previously built the JDK with success, and it
now fails, your build environment might have changed (perhaps due to OS
upgrades or similar). But most likely, such failures are due to problems with
the incremental rebuild.
Running "make doctor"
The build system comes with a built-in problem diagnosing system. If you
encounter unexpected build failures, you are highly encouraged to run make doctor. The build system will check for common sources of build problems and
suggest suitable actions to take to fix those problems.
These checks are not done during normal build time since they are either too
expensive performance-wise to perform, or since they are not conclusive and
just an indication about a potential problem.
The output from make doctor can look like this:
"make doctor" will help you analyze your build environment. It can highlight
certain well-known problems, but it can never find all possible errors.
* Verifying that configure has picked up git...
* Checking for warnings from configure...
---
The following warnings were produced. Repeated here for convenience:
WARNING: pandoc is version 3.1.9, not the recommended version 3.6.4
---
! Inspect the warnings, fix any problems, and re-run configure
* Checking for left-over core files...
Found these potential core files. They might interfere with the build process:
---
src/hotspot/core.1337
---
! Remove left-over core files
* Checking for untracked files with illegal names...
* If all else fails, try removing the entire build directory and re-creating
the same configuration using:
---
configure_command_line=$(make print-configuration)
make dist-clean
bash configure $configure_command_line
---
* The build README (doc/building.md) is a great source of information,
especially the chapter "Fixing Unexpected Build Failures". Check it out!
* If you still need assistance please contact [email protected].Problems with the Build Environment
Make sure your configuration is correct. Re-run configure, and look for any
warnings. Warnings that appear in the middle of the configure output is also
repeated at the end, after the summary. The entire log is stored in$BUILD/configure.log.
Verify that the summary at the end looks correct. Are you indeed using the Boot
JDK and native toolchain that you expect?
By default, the JDK has a strict approach where warnings from the compiler is
considered errors which fail the build. For very new or very old compiler
versions, this can trigger new classes of warnings, which thus fails the build.
Run configure with --disable-warnings-as-errors to turn of this behavior.
(The warnings will still show, but not make the build fail.)
Problems with Incremental Rebuilds
Incremental rebuilds mean that when you modify part of the product, only the
affected parts get rebuilt. While this works great in most cases, and
significantly speed up the development process, from time to time complex
interdependencies will result in an incorrect build result. This is the most
common cause for unexpected build problems.
Here are a suggested list of things to try if you are having unexpected build
problems. Each step requires more time than the one before, so try them in
order. Most issues will be solved at step 1 or 2.
Make sure your repository is up-to-date
Run
git pull origin masterto make sure you have the latest changes.Clean build results
The simplest way to fix incremental rebuild issues is to run
make clean.
This will remove all build results, but not the configuration or any build
system support artifacts. In most cases, this will solve build errors
resulting from incremental build mismatches.Completely clean the build directory.
If this does not work, the next step is to run
make dist-clean, or
removing the build output directory ($BUILD). This will clean all
generated output, including your configuration. You will need to re-runconfigureafter this step. A good idea is to runmake print-configurationbefore runningmake dist-clean, as this will print
your currentconfigurecommand line. Here's a way to do this:textmake print-configuration > current-configuration make dist-clean bash configure $(cat current-configuration) makeRe-clone the Git repository
Sometimes the Git repository gets in a state that causes the product to be
un-buildable. In such a case, the simplest solution is often the
"sledgehammer approach": delete the entire repository, and re-clone it. If
you have local changes, save them first to a different location usinggit format-patch.
Specific Build Issues
Clock Skew
If you get an error message like this:
File 'xxx' has modification time in the future.
Clock skew detected. Your build may be incomplete.then the clock on your build machine is out of sync with the timestamps on the
source files. Other errors, apparently unrelated but in fact caused by the
clock skew, can occur along with the clock skew warnings. These secondary
errors may tend to obscure the fact that the true root cause of the problem is
an out-of-sync clock.
If you see these warnings, reset the clock on the build machine, run make clean and restart the build.
Out of Memory Errors
On Windows, you might get error messages like this:
fatal error - couldn't allocate heap
cannot create ... Permission denied
spawn failedThis can be a sign of a Cygwin problem. See the information about solving
problems in the Cygwin section. Rebooting the computer might help
temporarily.
Spaces in Path
On Windows, when configuring, fixpath.sh may report that some directory names
have spaces. Usually, it assumes those directories have short
paths.
You can run fsutil file setshortname in cmd on directories to assign
arbitrary short paths so configure can access them. If the result says "Access
denied", it may be that there are processes running in that directory; in this
case, you can reboot Windows in safe mode and run the command on those directories
again.
The only directories required to have short paths are Microsoft Visual Studio
and Windows Kits; the rest of the "contains space" warnings from configure,
such as IntelliJ IDEA, can be ignored. You can choose any short name; once it
is set, configure's tools like cygpath can convert the directory with spaces
to your chosen short name and pass it to the build system.
Getting Help
If none of the suggestions in this document helps you, or if you find what you
believe is a bug in the build system, please contact the Build Group by sending
a mail to [email protected]. Please include
the relevant parts of the configure and/or build log.
If you need general help or advice about developing for the JDK, you can also
contact the Adoption Group. See the section on Contributing to OpenJDK for more information.
Reproducible Builds
Build reproducibility is the property of getting exactly the same bits out when
building, every time, independent on who builds the product, or where. This is
for many reasons a harder goal than it initially appears, but it is an
important goal, for security reasons and others. Please see Reproducible
Builds for more information about the
background and reasons for reproducible builds.
Currently, it is not possible to build the JDK fully reproducibly, but getting
there is an ongoing effort.
An absolute prerequisite for building reproducible is to specify a fixed build
time, since time stamps are embedded in many file formats. This is done by
setting the SOURCE_DATE_EPOCH environment variable, which is an industry
standard, that many
tools, such as gcc, recognize, and use in place of the current time when
generating output.
To generate reproducible builds, you must set SOURCE_DATE_EPOCH before
running configure. The value in SOURCE_DATE_EPOCH will be stored in the
configuration, and used by make. Setting SOURCE_DATE_EPOCH before runningmake will have no effect on the build.
You must also make sure your build does not rely on configure's default ad
hoc version strings. Default ad hoc version strings OPT segment include user
name and source directory. You can either override just the OPT segment using--with-version-opt=<any fixed string>, or you can specify the entire version
string using --with-version-string=<your version>.
This is a typical example of how to build the JDK in a reproducible way:
export SOURCE_DATE_EPOCH=946684800
bash configure --with-version-opt=adhoc
makeNote that regardless of whether you specify a source date for configure or
not, the JDK build system will set SOURCE_DATE_EPOCH for all build tools when
building. If --with-source-date has the value current (which is the default
unless SOURCE_DATE_EPOCH is found by in the environment by configure), the
source date value will be determined at configure time.
There are several aspects of reproducible builds that can be individually
adjusted by configure arguments. If any of these are given, they will
override the value derived from SOURCE_DATE_EPOCH. These arguments are:
--with-source-date
This option controls how the JDK build sets SOURCE_DATE_EPOCH when building.
It can be set to a value describing a date, either an epoch based timestamp as
an integer, or a valid ISO-8601 date.
It can also be set to one of the special values current, updated or
version. current means that the time of running configure will be used.
version will use the nominal release date for the current JDK version.
updated, which means that SOURCE_DATE_EPOCH will be set to the current
time each time you are running make. All choices, except for updated, will
set a fixed value for the source date timestamp.
When SOURCE_DATE_EPOCH is set, the default value for --with-source-date
will be the value given by SOURCE_DATE_EPOCH. Otherwise, the default value
is current.
--with-hotspot-build-time
This option controls the build time string that will be included in the
hotspot library (libjvm.so or jvm.dll). If the source date is fixed (e.g.
by setting SOURCE_DATE_EPOCH), the default value for
--with-hotspot-build-time will be an ISO 8601 representation of that time
stamp. Otherwise the default value will be the current time when building
hotspot.
--with-copyright-year
This option controls the copyright year in some generated text files. When the
source date is fixed (e.g. by setting SOURCE_DATE_EPOCH), the default value
for --with-copyright-year will be the year of that time stamp. Otherwise the
default is the current year at the time of running configure. This can be
overridden by --with-copyright-year=<year>.
--enable-reproducible-build
This option controls additional behavior needed to make the build
reproducible. When the source date is fixed (e.g. by setting
SOURCE_DATE_EPOCH), this flag will be turned on by default. Otherwise, the
value is determined by heuristics. If it is explicitly turned off, the build
might not be reproducible.
Hints and Suggestions for Advanced Users
Bash Completion
The configure and make commands try to play nice with bash command-line
completion (using <tab> or <tab><tab>). To use this functionality, make
sure you enable completion in your ~/.bashrc (see instructions for bash in
your operating system).
Make completion will work out of the box, and will complete valid make targets.
For instance, typing make jdk-i<tab> will complete to make jdk-image.
The configure script can get completion for options, but for this to work you
need to help bash on the way. The standard way of running the script, bash configure, will not be understood by bash completion. You need configure to
be the command to run. One way to achieve this is to add a simple helper script
to your path:
cat << EOT > /tmp/configure
#!/bin/bash
if [ \$(pwd) = \$(cd \$(dirname \$0); pwd) ] ; then
echo >&2 "Abort: Trying to call configure helper recursively"
exit 1
fi
bash \$PWD/configure "\$@"
EOT
chmod +x /tmp/configure
sudo mv /tmp/configure /usr/local/binNow configure --en<tab>-dt<tab> will result in configure --enable-dtrace.
Using Multiple Configurations
You can have multiple configurations for a single source repository. When you
create a new configuration, run configure --with-conf-name=<name> to create a
configuration with the name <name>. Alternatively, you can create a directory
under build and run configure from there, e.g. mkdir build/<name> && cd build/<name> && bash ../../configure.
Then you can build that configuration using make CONF=<selector>, where<selector> is interpreted as follows:
- If
<selector>exacly matches the name of a configuration, this and only
this configuration will be selected. - If
<selector>matches (i.e. is a substring of) the names of several
configurations, then all these configurations will be selected. - If
<selector>is empty (i.e.CONF=), then all configurations will be
selected. - If
<selector>begins with!, then all configurations not matching the
string following!will be selected.
A more specialized version, CONF_NAME=<name> also exists, which will only
match if the given <name> exactly matches a single configuration.
Alternatively, you can execute make in the configuration directory, e.g. cd build/<name> && make.
make CONF_NAME=<name> or
Handling Reconfigurations
If you update the repository and part of the configure script has changed, the
build system will force you to re-run configure.
Most of the time, you will be fine by running configure again with the same
arguments as the last time, which can easily be performed by make reconfigure. To simplify this, you can use the CONF_CHECK make control
variable, either as make CONF_CHECK=auto, or by setting an environment
variable. For instance, if you add export CONF_CHECK=auto to your .bashrc
file, make will always run reconfigure automatically whenever the configure
script has changed.
You can also use CONF_CHECK=ignore to skip the check for a needed configure
update. This might speed up the build, but comes at the risk of an incorrect
build result. This is only recommended if you know what you're doing.
From time to time, you will also need to modify the command line to configure
due to changes. Use make print-configuration to show the command line used
for your current configuration.
Using Fine-Grained Make Targets
The default behavior for make is to create consistent and correct output, at
the expense of build speed, if necessary.
If you are prepared to take some risk of an incorrect build, and know enough of
the system to understand how things build and interact, you can speed up the
build process considerably by instructing make to only build a portion of the
product.
Building Individual Modules
The safe way to use fine-grained make targets is to use the module specific
make targets. All source code in the JDK is organized so it belongs to a
module, e.g. java.base or jdk.jdwp.agent. You can build only a specific
module, by giving it as make target: make jdk.jdwp.agent. If the specified
module depends on other modules (e.g. java.base), those modules will be built
first.
You can also specify a set of modules, just as you can always specify a set of
make targets: make jdk.crypto.cryptoki jdk.crypto.ec jdk.crypto.mscapi
Building Individual Module Phases
The build process for each module is divided into separate phases. Not all
modules need all phases. Which are needed depends on what kind of source code
and other artifact the module consists of. The phases are:
gensrc(Generate source code to compile)gendata(Generate non-source code artifacts)copy(Copy resource artifacts)java(Compile Java code)launchers(Compile native executables)libs(Compile native libraries)
You can build only a single phase for a module by using the notation$MODULE-$PHASE. For instance, to build the gensrc phase for java.base,
use make java.base-gensrc.
Note that some phases may depend on others, e.g. java depends on gensrc (if
present). Make will build all needed prerequisites before building the
requested phase.
Skipping the Dependency Check
When using an iterative development style with frequent quick rebuilds, the
dependency check made by make can take up a significant portion of the time
spent on the rebuild. In such cases, it can be useful to bypass the dependency
check in make.
Note that if used incorrectly, this method can lead to a broken build!
To achieve this, append -only to the build target. For instance, make jdk.jdwp.agent-java-only will only build the java phase of thejdk.jdwp.agent module. If the required dependencies are not present, the
build can fail. On the other hand, the execution time measures in milliseconds.
A useful pattern is to build the first time normally (e.g. make jdk.jdwp.agent) and then on subsequent builds, use the -only make target.
Rebuilding Part of java.base (JDK\_FILTER)
In older versions of the JDK, inefficiencies when building java.base (by far
the largest module in the JDK) could be overcome by using the make control
variable JDK_FILTER. This is not needed anymore for performance reasons, but
the functionality is still present.
To use this, set the make control variable JDK_FILTER to specify a pattern
that will be used to limit the set of files being recompiled. For instance,make java.base JDK_FILTER=javax/crypto will limit the compilation to files in
the javax.crypto package.
Understanding the Build System
This section will give you a more technical description on the details of the
build system.
Configurations
The build system expects to find one or more configuration. These are
technically defined by the spec.gmk in a subdirectory to the build
subdirectory. The spec.gmk file is generated by configure, and contains in
principle the configuration (directly or by files included by spec.gmk).
You can, in fact, select a configuration to build by pointing to the spec.gmk
file with the SPEC make control variable, e.g. make SPEC=$BUILD/spec.gmk.
While this is not the recommended way to call make as a user, it is what is
used under the hood by the build system.
Build Output Structure
The build output for a configuration will end up in build/<configuration name>, which we refer to as $BUILD in this document. The $BUILD directory
contains the following important directories:
buildtools/
configure-support/
hotspot/
images/
jdk/
make-support/
support/
test-results/
test-support/This is what they are used for:
images: This is the directory were the output of the*-imagemake targets
end up. For instance,make jdk-imageends up inimages/jdk.jdk: This is the "exploded image". Aftermake jdk, you will be able to
launch the newly built JDK by running$BUILD/jdk/bin/java.test-results: This directory contains the results from running tests.support: This is an area for intermediate files needed during the build,
e.g. generated source code, object files and class files. Some noteworthy
directories insupportisgensrc, which contains the generated source
code, and themodules_*directories, which contains the files in a
per-module hierarchy that will later be collapsed into thejdkdirectory of
the exploded image.buildtools: This is an area for tools compiled for the build platform that
are used during the rest of the build.hotspot: This is an area for intermediate files needed when building
hotspot.configure-support,make-supportandtest-support: These directories
contain files that are needed by the build system forconfigure,makeand
for running tests.
Fixpath
Windows path typically look like C:\User\foo, while Unix paths look like/home/foo. Tools with roots from Unix often experience issues related to this
mismatch when running on Windows.
In the JDK build, we always use Unix paths internally, and only just before
calling a tool that does not understand Unix paths do we convert them to
Windows paths.
This conversion is done by the fixpath.sh tool, which is a small wrapper that
modifies Unix-style paths to Windows-style paths. The fixpath tool is called
with the first argument as a sub-command describing the action it should take.
Available actions are import, exec, print and verify.
importis called at configure time to convert a path given by the user and
that might be in Windows format to Unix path, which is used internally.execis called at build time. This will take the command line provided,
complete with arguments, converting the paths in the command line, and then
execute the command.printis called at build time, in the rare cases where a path might be
needed in Windows format, but not as an argument to a command to execute.verifyis called at configure time to check that a path is correctly
specified and reachable by Windows.
The fixpath tool uses a somewhat complex heuristic to infer which part of the
command line arguments refer to paths, and converts those. In some
circumstances, these heuristics can fail.
If you are having strange build issues related to path conversion, you might
need to debug how fixpath treats your paths. Here are some ways to do this.
One way is to define the environment variable DEBUG_FIXPATH, e.g.DEBUG_FIXPATH=1 make jdk. When set, any call to fixpath exec will result in
an output like this:
fixpath: debug: input: ls /mnt/c/windows
fixpath: debug: output: ls c:\windowsYou can also call fixpath yourself manually with your paths to see how they are
translated. For this, use print and import. For example:
$ bash make/scripts/fixpath.sh print /mnt/c/windows
c:\windows
$ bash make/scripts/fixpath.sh import "c:\\windows"
/mnt/c/windowsRemember that backslash is used as an escape character in the shell, and needs
to be doubled when used in Windows paths.
Native Debug Symbols
Native libraries and executables can have debug symbol (and other debug
information) associated with them. How this works is very much platform
dependent, but a common problem is that debug symbol information takes a lot of
disk space, but is rarely needed by the end user.
The JDK supports different methods on how to handle debug symbols. The method
used is selected by --with-native-debug-symbols, and available methods arenone, internal, external, zipped.
nonemeans that no debug symbols will be generated during the build.internalmeans that debug symbols will be generated during the build, and
they will be stored in the generated binary.externalmeans that debug symbols will be generated during the build, and
after the compilation, they will be moved into a separate.debuginfofile.
(This was previously known as FDS, Full Debug Symbols).zippedis likeexternal, but the .debuginfo file will also be zipped into
a.dizfile.
When building for distribution, zipped is a good solution. Binaries built
with internal is suitable for use by developers, since they facilitate
debugging, but should be stripped before distributed to end users.
Autoconf Details
The configure script is using the autoconf framework, but it has grown to
deviate quite a lot from a traditional autoconf configure script.
The configure script in the top level directory of the JDK is just a thin
wrapper that calls make/autoconf/configure. This in turn will run autoconf
to create the runnable (generated) configure script, as.build/generated-configure.sh. Apart from being responsible for the
generation of the runnable script, the configure script also provides
functionality that is not easily expressed in the normal Autoconf framework. As
part of this functionality, the generated script is called.
The build system will detect if the Autoconf source files have changed, and
will trigger a regeneration of the generated script if needed. You can also
manually request such an update by bash configure autogen.
Developing the Build System Itself
This section contains a few remarks about how to develop for the build system
itself. It is not relevant if you are only making changes in the product source
code.
While technically using make, the make source files of the JDK does not
resemble most other Makefiles. Instead of listing specific targets and actions
(perhaps using patterns), the basic modus operandi is to call a high-level
function (or properly, macro) from the API in make/common. For instance, to
compile all classes in the jdk.internal.foo package in the jdk.foo module,
a call like this would be made:
$(eval $(call SetupJavaCompilation, BUILD_FOO_CLASSES, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(TOPDIR)/src/jkd.foo/share/classes, \
INCLUDES := jdk/internal/foo, \
BIN := $(SUPPORT_OUTPUTDIR)/foo_classes, \
))By encapsulating and expressing the high-level knowledge of what should be
done, rather than how it should be done (as is normal in Makefiles), we can
build a much more powerful and flexible build system.
Correct dependency tracking is paramount. Sloppy dependency tracking will lead
to improper parallelization, or worse, race conditions.
To test for/debug race conditions, try running make JOBS=1 and make JOBS=100 and see if it makes any difference. (It shouldn't).
To compare the output of two different builds and see if, and how, they differ,
run $BUILD1/compare.sh -o $BUILD2, where $BUILD1 and $BUILD2 are the two
builds you want to compare.
To automatically build two consecutive versions and compare them, useCOMPARE_BUILD. The value of COMPARE_BUILD is a set of variable=value
assignments, like this:
make COMPARE_BUILD=CONF=--enable-new-hotspot-feature:MAKE=hotspotSee make/InitSupport.gmk for details on how to use COMPARE_BUILD.
To analyze build performance, run with LOG=trace and check$BUILD/build-trace-time.log. Use JOBS=1 to avoid parallelism.
Please check that you adhere to the Code Conventions for the Build System before submitting
patches.
Contributing to the JDK
So, now you've built your JDK, and made your first patch, and want to
contribute it back to the OpenJDK Community.
First of all: Thank you! We gladly welcome your contribution. However, please
bear in mind that the JDK is a massive project, and we must ask you to follow
our rules and guidelines to be able to accept your contribution.
The official place to start is the OpenJDK Developers’ Guide.
Editing This Document
If you want to contribute changes to this document, edit doc/building.md and
then run make update-build-docs to generate the same changes indoc/building.html.
Override styles from the base CSS file that are not ideal for this document.
header-includes:
- ''
Doc Hotspot Style (`doc/hotspot-style.md`)
% HotSpot Coding Style
Introduction
This is a collection of rules, guidelines, and suggestions for writing
HotSpot code. Following these will help new code fit in with existing
HotSpot code, making it easier to read and maintain. Failure to
follow these guidelines may lead to discussion during code reviews, if
not outright rejection of a change.
Changing this Document
Proposed changes should be discussed on the
HotSpot Developers mailing
list. Changes are likely to be cautious and incremental, since HotSpot
coders have been using these guidelines for years.
Substantive changes are approved by
rough consensus of
the HotSpot Group Members.
The Group Lead determines whether consensus has been reached.
Editorial changes (changes that only affect the description of HotSpot
style, not its substance) do not require the full consensus gathering
process. The normal HotSpot pull request process may be used for
editorial changes, with the additional requirement that the requisite
reviewers are also HotSpot Group Members.
Why Care About Style?
Some programmers seem to have lexers and even C preprocessors
installed directly behind their eyeballs. The rest of us require code
that is not only functionally correct but also easy to read. More than
that, since there is no one style for easy-to-read code, and since a
mashup of many styles is just as confusing as no style at all, it is
important for coders to be conscious of the many implicit stylistic
choices that historically have gone into the HotSpot code base.
Some of these guidelines are driven by the cross-platform requirements
for HotSpot. Shared code must work on a variety of platforms, and may
encounter deficiencies in some. Using platform conditionalization in
shared code is usually avoided, while shared code is strongly
preferred to multiple platform-dependent implementations, so some
language features may be recommended against.
Some of the guidelines here are relatively arbitrary choices among
equally plausible alternatives. The purpose of stating and enforcing
these rules is largely to provide a consistent look to the code. That
consistency makes the code more readable by avoiding non-functional
distractions from the interesting functionality.
When changing pre-existing code, it is reasonable to adjust it to
match these conventions. Exception: If the pre-existing code clearly
conforms locally to its own peculiar conventions, it is not worth
reformatting the whole thing. Also consider separating changes that
make extensive stylistic updates from those which make functional
changes.
Counterexamples
Many of the guidelines mentioned here have (sometimes widespread)
counterexamples in the HotSpot code base. Finding a counterexample is
not sufficient justification for new code to follow the counterexample
as a precedent, since readers of your code will rightfully expect your
code to follow the greater bulk of precedents documented here.
Occasionally a guideline mentioned here may be just out of synch with
the actual HotSpot code base. If you find that a guideline is
consistently contradicted by a large number of counterexamples, please
bring it up for discussion and possible change. The architectural
rule, of course, is "When in Rome do as the Romans". Sometimes in the
suburbs of Rome the rules are a little different; these differences
can be pointed out here.
Structure and Formatting
Factoring and Class Design
Group related code together, so readers can concentrate on one
section of one file.Classes are the primary code structuring mechanism. Place related
functionality in a class, or a set of related classes. Use of either
namespaces or public non-member functions is rare in HotSpot code.
Static non-member functions are not uncommon.If a class
FooBaris going to be used in more than one place, put it
a file named fooBar.hpp and fooBar.cpp. If the class is a sidekick
to a more important classBazBat, it can go in bazBat.hpp.Put a member function
FooBar::banginto the same file that definedFooBar, or its associated *.inline.hpp or *.cpp file.Use public accessor functions for member variables accessed
outside the class.Assign names to constant literals and use the names instead.
Keep functions small, a screenful at most. Split out chunks of
logic into file-local classes or static functions if needed.Factor away nonessential complexity into local inline helper
functions and helper classes.Think clearly about internal invariants that apply to each class,
and document them in the form of asserts within member functions.Make simple, self-evident contracts for member functions. If you cannot
communicate a simple contract, redesign the class.Implement classes as if expecting rough usage by clients. Check for
incorrect usage of a class usingassert(...),guarantee(...),ShouldNotReachHere()and comments wherever needed. Performance is
almost never a reason to omit asserts.When possible, design as if for reusability. This forces a clear
design of the class's externals, and clean hiding of its internals.Initialize all variables and data structures to a known state. If a
class has a constructor, initialize it there.Do no optimization before its time. Prove the need to optimize.
When you must defactor to optimize, preserve as much structure as
possible. If you must hand-inline some name, label the local copy with
the original name.If you need to use a hidden detail (e.g., a structure offset), name
it (as a constant or function) in the class that owns it.Don't use the Copy and Paste keys to replicate more than a couple
lines of code. Name what you must repeat.If a class needs a member function to change a user-visible attribute, the
change should be done with a "setter" accessor matched to the simple
"getter".
Conventions for Lock-free Code
Sometimes variables are accessed concurrently without appropriate synchronization
context, such as a held mutex or at a safepoint. In such cases the variable should
be declared volatile and it should NOT be accessed as a normal C++ lvalue. Rather,
access should be performed via functions from Atomic, such as Atomic::load,Atomic::store, etc.
This special formulation makes it more clear to maintainers that the variable is
accessed concurrently in a lock-free manner.
Source Files
All source files must have a globally unique basename. The build
system depends on this uniqueness.Keep the include lines within a section alphabetically sorted by their
lowercase value. If an include must be out of order for correctness,
suffix with it a comment such as// do not reorder. Source code
processing tools can also use this hint.Put conditional inclusions (
#if ...) at the end of the section of HotSpot
include lines. This also applies to macro-expanded includes of platform
dependent files.Put system includes in a section after the HotSpot include lines with a blank
line separating the two sections.Do not put non-trivial function implementations in .hpp files. If
the implementation depends on other .hpp files, put it in a .cpp or
a .inline.hpp file..inline.hpp files should only be included in .cpp or .inline.hpp
files.All .inline.hpp files should include their corresponding .hpp file as
the first include line with a blank line separating it from the rest of the
include lines. Declarations needed by other files should be put in the .hpp
file, and not in the .inline.hpp file. This rule exists to resolve problems
with circular dependencies between .inline.hpp files.Do not include a .hpp file if the corresponding .inline.hpp file is included.
Use include guards for .hpp and .inline.hpp files. The name of the defined
guard should be derived from the full search path of the file relative to the
hotspot source directory. The guard should be all upper case with all paths
separators and periods replaced by underscores.Some build configurations use precompiled headers to speed up the
build times. The precompiled headers are included in the precompiled.hpp
file. Note that precompiled.hpp is just a build time optimization, so
don't rely on it to resolve include problems.
JTReg Tests
JTReg tests should have meaningful names.
JTReg tests associated with specific bugs should be tagged with the
@bugkeyword in the test description.JTReg tests should be organized by component or feature under
test/, in a directory hierarchy that generally follows that of thesrc/directory. There may be additional subdirectories to further
categorize tests by feature. This structure makes it easy to run a
collection of tests associated with a specific feature by specifying
the associated directory as the source of the tests to run.- Some (older) tests use the associated bug number in the directory
name, the test name, or both. That naming style should no longer be
used, with existing tests using that style being candidates for migration.
- Some (older) tests use the associated bug number in the directory
Naming
The length of a name may be correlated to the size of its scope. In
particular, short names (even single letter names) may be fine in a
small scope, but are usually inappropriate for larger scopes.Prefer whole words rather than abbreviations, unless the
abbreviation is more widely used than the long form in the code's
domain.Choose names consistently. Do not introduce spurious
variations. Abbreviate corresponding terms to a consistent length.Global names must be unique, to avoid One Definition Rule (ODR)
violations. A common prefixing scheme for related global names is
often used. (This is instead of using namespaces, which are mostly
avoided in HotSpot.)Don't give two names to the semantically same thing. But use
different names for semantically different things, even if they are
representationally the same. (So use meaningfultypedefor template
alias names where appropriate.)When choosing names, avoid categorical nouns like "variable",
"field", "parameter", "value", and verbs like "compute", "get".
(storeValue(int param)is bad.)Type names and global names should use mixed-case with the first
letter of each word capitalized (FooBar).Embedded abbreviations in
otherwise mixed-case names are usually capitalized entirely rather
than being treated as a single word with only the initial letter
capitalized, e.g. "HTML" rather than "Html".Function and local variable names use lowercase with words separated
by a single underscore (foo_bar).Class data member names have a leading underscore, and use lowercase
with words separated by a single underscore (_foo_bar).Constant names may be upper-case or mixed-case, according to
historical necessity. (Note: There are many examples of constants
with lowercase names.)Constant names should follow an existing pattern, and must have a
distinct appearance from other names in related APIs.Class and type names should be noun phrases. Consider an "er" suffix
for a class that represents an action.Function names should be verb phrases that reflect changes of state
known to a class's user, or else noun phrases if they cause no change
of state visible to the class's user.Getter accessor names are noun phrases, with no "
get_" noise
word. Boolean getters can also begin with "is_" or "has_". Member
function for reading data members usually have the same name as the
data member, exclusive of the leading underscore.Setter accessor names prepend "
set_" to the getter name.Other member function names are verb phrases, as if commands to the receiver.
Avoid leading underscores (as "
_oop") except in cases required
above. (Names with leading underscores can cause portability
problems.)
Commenting
Clearly comment subtle fixes.
Clearly comment tricky classes and functions.
If you have to choose between commenting code and writing wiki
content, comment the code. Link from the wiki to the source file if
it makes sense.As a general rule don't add bug numbers to comments (they would soon
overwhelm the code). But if the bug report contains significant
information that can't reasonably be added as a comment, then refer to
the bug report.Personal names are discouraged in the source code, which is a team
product.
Macros
You can almost always use an inline function or class instead of a
macro. Use a macro only when you really need it.Templates may be preferable to multi-line macros. (There may be
subtle performance effects with templates on some platforms; revert
to macros if absolutely necessary.)#ifdefs should not be used to introduce platform-specific code
into shared code (except for_LP64). They must be used to manage
header files, in the pattern found at the top of every source
file. They should be used mainly for major build features, includingPRODUCT,ASSERT,_LP64,INCLUDE_SERIALGC,COMPILER1, etc.For build features such as
PRODUCT, use#ifdef PRODUCTfor
multiple-line inclusions or exclusions.For short inclusions or exclusions based on build features, use
macros likePRODUCT_ONLYandNOT_PRODUCT. But avoid using them
with multiple-line arguments, since debuggers do not handle that
well.Use
CATCH,THROW, etc. for HotSpot-specific exception processing.
Whitespace
In general, don't change whitespace unless it improves readability
or consistency. Gratuitous whitespace changes will make integrations
and backports more difficult.Use One-True-Brace-Style.
The opening brace for a function or class
is normally at the end of the line; it is sometimes moved to the
beginning of the next line for emphasis. Substatements are enclosed
in braces, even if there is only a single statement. Extremely simple
one-line statements may drop braces around a substatement.Indentation levels are two columns.
There is no hard line length limit. That said, bear in mind that
excessively long lines can cause difficulties. Some people like to
have multiple side-by-side windows in their editors, and long lines
may force them to choose among unpleasant options. They can use wide
windows, reducing the number that can fit across the screen, and
wasting a lot of screen real estate because most lines are not that
long. Alternatively, they can have more windows across the screen,
with long lines wrapping (or worse, requiring scrolling to see in
their entirety), which is harder to read. Similar issues exist for
side-by-side code reviews.Tabs are not allowed in code. Set your editor accordingly.
(Emacs:(setq-default indent-tabs-mode nil).)Use good taste to break lines and align corresponding tokens on
adjacent lines.Use spaces around operators, especially comparisons and
assignments. (Relaxable for boolean expressions and high-precedence
operators in classic math-style formulas.)Put spaces on both sides of control flow keywords
if,else,for,switch, etc. Don't add spaces around the associated
control expressions. Examples:textwhile (test_foo(args...)) { // Yes while(test_foo(args...)) { // No, missing space after while while ( test_foo(args...) ) { // No, excess spaces around controlUse extra parentheses in expressions whenever operator precedence
seems doubtful. Always use parentheses in shift/mask expressions
(<<,&,|). Don't add whitespace immediately inside
parentheses.Use more spaces and blank lines between larger constructs, such as
classes or function definitions.If the surrounding code has any sort of vertical organization,
adjust new lines horizontally to be consistent with that
organization. (E.g., trailing backslashes on long macro definitions
often align.)
Avoid implicit conversions to bool
- Use
boolfor boolean values. - Do not use ints or pointers as (implicit) booleans with
&&,||,if,while. Instead, compare explicitly, i.e.if (x != 0)orif (ptr != nullptr), etc. - Do not use non-boolean declarations in condition forms, i.e. don't use
if (T v = value) { ... }. But see
Enhanced selection statements.
Miscellaneous
Use the Resource Acquisition Is Initialization (RAII)
design pattern to manage bracketed critical
sections. See classResourceMarkfor an example.Use functions from globalDefinitions.hpp and related files when
performing bitwise
operations on integers. Do not code directly as C operators, unless
they are extremely simple. (Examples:align_up,is_power_of_2,exact_log2.)Use arrays with abstractions supporting range checks.
Always enumerate all cases in a switch statement or provide a default
case. It is ok to have an empty default with comment.
Use of C++ Features
HotSpot was originally written in a subset of the C++98/03 language.
More recently, support for C++17 is provided, though again,
HotSpot only uses a subset. (Backports to JDK versions lacking
support for more recent Standards must of course stick with the
original C++98/03 subset.)
This section describes that subset. Features from the C++98/03
language may be used unless explicitly forbidden here. Features from
C++11, C++14, and C++17 may be explicitly permitted or explicitly forbidden,
and discussed accordingly here. There is a third category, undecided
features, about which HotSpot developers have not yet reached a
consensus, or perhaps have not discussed at all. Use of these
features is also forbidden.
(The use of some features may not be immediately obvious and may slip
in anyway, since the compiler will accept them. The code review
process is the main defense against this.)
Some features are discussed in their own subsection, typically to provide
more extensive discussion or rationale for limitations. Features that
don't have their own subsection are listed in omnibus feature sections
for permitted, forbidden, and undecided features.
Lists of new features for C++11, C++14, and C++17, along with links to their
descriptions, can be found in the online documentation for some of the
compilers and libraries. The C++17 Standard is the definitive
description.
- C++ Standards Support in GCC
- C++ Support in Clang
- Visual C++ Language Conformance
- libstdc++ Status
- libc++ Status
As a rule of thumb, permitting features which simplify writing code
and, especially, reading code, is encouraged.
Similar discussions for some other projects:
Google C++ Style Guide —
Currently (2020) targeting C++17.C++11 and C++14 use in Chromium —
Categorizes features as allowed, banned, or to be discussed.llvm Coding Standards —
Currently (2020) targeting C++14.Using C++ in Mozilla code —
C++17 support is required for recent versions (2020).
Error Handling
Do not use exceptions. Exceptions are disabled by the build configuration
for some platforms.
Rationale: There is significant concern over the performance cost of
exceptions and their usage model and implications for maintainable code.
That's not just a matter of history that has been fixed; there remain
questions and problems even today (2019). See, for example, Zero cost
deterministic
exceptions.
Because of this, HotSpot has always used a build configuration that disables
exceptions where that is available. As a result, HotSpot code uses error
handling mechanisms such as two-phase construction, factory functions,
returning error codes, and immediate termination. Even if the cost of
exceptions were not a concern, the existing body of code was not written with
exception safety in mind. Making HotSpot exception safe would be a very large
undertaking.
In addition to the usual alternatives to exceptions, HotSpot provides its
own exception mechanism. This is based on a set of macros defined in
utilities/exceptions.hpp.
RTTI (Runtime Type Information)
Do not use Runtime Type Information (RTTI).
RTTI is disabled by the build configuration for some
platforms. Among other things, this means dynamic_cast cannot be used.
Rationale: Other than to implement exceptions (which HotSpot doesn't use),
most potential uses of RTTI are better done via virtual functions. Some of
the remainder can be replaced by bespoke mechanisms. The cost of the
additional runtime data structures needed to support RTTI are deemed not
worthwhile, given the alternatives.
Memory Allocation
Do not use the standard global allocation and deallocation functions (globaloperator new and related functions), other than the non-allocating forms of
those functions. Use of these functions by HotSpot code is disabled for some
platforms.
Rationale: HotSpot often uses "resource" or "arena" allocation. Even
where heap allocation is used, the standard global functions are
avoided in favor of wrappers around malloc and free that support the
JVM's Native Memory Tracking (NMT) feature. Typically, uses of the globaloperator new are inadvertent and therefore often associated with memory
leaks.
Native memory allocation failures are often treated as non-recoverable.
The place where "out of memory" is (first) detected may be an innocent
bystander, unrelated to the actual culprit.
Class Inheritance
Use public single inheritance.
Prefer composition rather than non-public inheritance.
Restrict inheritance to the "is-a" case; use composition rather than
non-is-a related inheritance.
Avoid multiple inheritance. Never use virtual inheritance.
Namespaces
Avoid using namespaces. HotSpot code normally uses "all static"
classes rather than namespaces for grouping. An "all static" class is
not instantiable, has only static members, and is normally derived
(possibly indirectly) from the helper class AllStatic.
Benefits of using such classes include:
Provides access control for members, which is unavailable with
namespaces.Avoids Argument Dependent Lookup (ADL).
Closed for additional members. Namespaces allow names to be added in
multiple contexts, making it harder to see the complete API.
Namespaces should be used only in cases where one of those "benefits"
is actually a hindrance.
In particular, don't use anonymous namespaces. They seem like they should
be useful, and indeed have some real benefits for naming and generated code
size on some platforms. Unfortunately, debuggers don't seem to like them at
all.
https://groups.google.com/forum/#!topic/mozilla.dev.platform/KsaG3lEEaRM
Suggests Visual Studio debugger might not be able to refer to
anonymous namespace symbols, so can't set breakpoints in them.
Though the discussion seems to go back and forth on that.
https://firefox-source-docs.mozilla.org/code-quality/coding-style/coding_style_cpp.html
Search for "Anonymous namespaces"
Suggests preferring "static" to anonymous namespaces where applicable,
because of poor debugger support for anonymous namespaces.
https://sourceware.org/bugzilla/show_bug.cgi?id=16874
Bug for similar gdb problems.
C++ Standard Library
Only curated parts of the C++ Standard Library may be used by HotSpot code.
Functions that may throw exceptions must not be used. This is in accordance
with the HotSpot policy of not using exceptions.
Also in accordance with HotSpot policy, the
standard global allocator must not be used. This means
that uses of standard container classes cannot presently be used, as doing so
requires specialization on some allocator type that is integrated with the
existing HotSpot allocation mechanisms. (Such allocators may be provided in
the future.)
Standard Library identifiers should usually be fully qualified; using
directives must not be used to bring Standard Library identifiers into scope
just to remove the need for namespace qualification. Requiring qualification
makes it easy to distinguish between references to external libraries and code
that is part of HotSpot.
As with language features, Standard Library facilities are either permitted,
explicitly forbidden, or undecided (and so implicitly forbidden).
Most HotSpot code should not directly #include C++ Standard Library headers.
HotSpot provides a set of wrapper headers for the Standard Library headers
containing permitted definitions. These wrappers are in the cppstdlib
directory, with the same name as the corresponding Standard Library header and
a .hpp extension. These wrappers provide a place for any additional code
(some of which may be platform-specific) needed to support HotSpot usage.
These wrappers also provide a place to document HotSpot usage, including any
restrictions. The set of wrappers and the usage documentation should be
considered part of HotSpot style. Any changes are subject to the same process
as applies to this document. (For historical reasons, there may be many direct
inclusions of some C++ Standard Library headers.)
Historically, HotSpot has mostly avoided use of the Standard
Library.
(It used to be impossible to use most of it in shared code,
because the build configuration for Solaris with Solaris Studio made
all but a couple of pieces inaccessible. Support for header-only
parts was added in mid-2017. Support for Solaris was removed
in 2020.)
Some reasons for this include
Exceptions. Perhaps the largest core issue with adopting the use of
Standard Library facilities is exceptions. HotSpot does not use
exceptions and, for platforms which allow doing so, builds with them
turned off. Many Standard Library facilities implicitly or explicitly
use exceptions. On the other hand, many don't, and can be used without
concern for this issue. Others may have a useful subset that doesn't
use exceptions.assert. An issue that is quickly encountered is theassertmacro name
collision (JDK-8007770).
(Not all Standard Library implementations useassertin header files, but
some do.) HotSpot provides a mechanism for addressing this, by establishing a
scope around the include of a library header where the HotSpotassertmacro
is suppressed. One of the reasons for using wrapper headers rather than
directly including standard headers is to provide a central place to deal with
this issue for each header.Memory allocation. HotSpot requires explicit control over where allocations
occur. The C++98/03std::allocatorclass is too limited to support our
usage. But changes to the allocator concept in more recent Standards removed
some of the limitations, supporting stateful allocators. HotSpot may, in the
future, provide standard-conforming allocators that are integrated with
HotSpot's existing allocation mechanisms.Implementation vagaries. Bugs, or simply different implementation choices,
can lead to different behaviors among the various Standard Libraries we need
to deal with. But only selected parts of the Standard Library are being
permitted, and one of the selection criteria is maturity. Some of these
facilities are among the most heavily tested and used C++ codes that exist.Inconsistent naming conventions. HotSpot and the C++ Standard use different
naming conventions. The coexistence of those different conventions might
appear jarring and reduce readability. However, experience in some other code
bases suggests this isn't a significant problem, so long as Standard Library
names are namespace-qualified. It is tempting to bring the Standard Library
names into scope via ausing std;directive. Doing so makes writing code
using those names easier, since the qualifiers don't need to be included. But
there are several reasons not to do that.There is a risk of future name collisions. Additional Standard Library
headers may be included, adding to the list of names being used. Also,
future versions of the Standard Library may add currently unknown names to
the headers already being included.It may harm readability. Code where this is relevant is a mixture of the
local HotSpot naming conventions and the Standard Library's (or other
3rd-party library's) naming conventions. With only unqualified names, any
distinctions from the naming conventions for the different code sources
are lost. Instead one may end up with an undifferentiated mess, where it's
not obvious whether an identifier is from local code that is inconsistent
with HotSpot style (and there's a regretable amount of that for historical
reasons), or is following some other convention. Having the qualifiers
disambiguates that.It can be helpful to know, at a glance, whether the definition is in
HotSpot or elsewhere, for purposes of looking up the definition or
documentation.
Type Deduction
Use type deduction only if it makes the code clearer or safer. Do not
use it merely to avoid the inconvenience of writing an explicit type,
unless that type is itself difficult to write. An example of the
latter is a function template return type that depends on template
parameters in a non-trivial way.
There are several contexts where types are deduced.
Function argument deduction. This is always permitted, and indeed
encouraged. It is nearly always better to allow the type of a
function template argument to be deduced rather than explicitly
specified.autovariable declarations
(n1984)
For local variables, this can be used to make the code clearer by
eliminating type information that is obvious or irrelevant. Excessive
use can make code much harder to understand.autofor non-type template parameters
(p0127r2)automay be used as a placeholder for the type of a non-type template
parameter. The type is deduced from the value provided in a template
instantiation.
Function return type deduction
(n3638)
Only use if the function body has a very small number ofreturn
statements, and generally relatively little other code.Class template argument deduction
(n3602, p0091r3)
The template arguments of a class template may be deduced from the arguments
to a constructor. This is similar to ordinary function argument deduction,
though partial deduction with only some template arguments explicitly
provided is not permitted for class template argument deduction. Deduction
guides may be used to provide additional control over the deduction. As withautovariable declarations, excessive use can make code harder to
understand, because explicit type information is lacking. But it can also
remove the need to be explicit about types that are either obvious, or that
are very hard to write. For example, these allow the addition of a scope-guard
mechanism with nice syntax; something like this
ScopeGuard guard{[&]{ ... cleanup code ... }};Also see lambda expressions.
decltype(auto)should be avoided, whether for variables, for non-type
template parameters, or for function return types. There are subtle and
complex differences between this placeholder type andauto. Any use would
need very careful explanation.
Expression SFINAE
Substitution Failure Is Not An Error (SFINAE)
is a template metaprogramming technique that makes use of
template parameter substitution failures to make compile-time decisions.
C++11 relaxed the rules for what constitutes a hard-error when
attempting to substitute template parameters with template arguments,
making most deduction errors be substitution errors; see
(n2634).
This makes SFINAE more powerful and easier to use. However, the
implementation complexity for this change is significant, and this
seems to be a place where obscure corner-case bugs in various
compilers can be found. So while this feature can (and indeed should)
be used (and would be difficult to avoid), caution should be used when
pushing to extremes.
Here are a few closely related example bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95468
https://developercommunity.visualstudio.com/content/problem/396562/sizeof-deduced-type-is-sometimes-not-a-constant-ex.html
Trailing return type syntax for functions
A function's return type may be specified after the parameters and qualifiers
(n2541).
In such a declaration the normal return type is auto and the return type is
indicated by -> followed by the type. Although both use auto in the
"normal" leading return type position, this differs from
function return type deduction,
in that the return type is explicit rather than deduced, but specified in a
trailing position.
Use of trailing return types is permitted. However, the normal, leading
position for the return type is preferred. A trailing return type should only
be used where it provides some benefit. Such benefits usually arise because a
trailing return type is in a different scope than a leading return type.
If the function identifier is a nested name specifier, then the trailing
return type occurs in the nested scope. This may permit simpler naming in the
return type because of the different name lookup context.The trailing return type is in the scope of the parameters, making their
types accessible viadecltype. For example
template<typename T, typename U> auto add(T t, U u) -> decltype(t + u);rather than
template<typename T, typename U> decltype((*(T*)0) + (*(U*)0)) add(T t, U u);- Complex calculated leading return types may obscure the normal syntactic
boundaries, making it more difficult for a reader to find the function name and
parameters. This is particularly common in cases where the return type is
being used for SFINAE. A trailing return type may be preferable in such
situations.
Non-type template parameter values
C++17 extended the arguments permitted for non-type template parameters
(n4268). The kinds of values (the parameter types)
aren't changed. However, the values can now be the result of arbitrary
constant expressions (with a few restrictions on the result), rather than a
much more limited and restrictive set of expressions. In particular, the
argument for a pointer or reference type parameter can now be the result of a
constexpr function.
enum
Where appropriate, scoped-enums should be used.
(n2347)
Use of unscoped-enums is permitted, though ordinary constants may be
preferable when the automatic initializer feature isn't used.
The underlying type (the enum-base) of an unscoped enum type should
always be specified explicitly. When unspecified, the underlying type
is dependent on the range of the enumerator values and the platform.
The underlying type of a scoped-enum should also be specified
explicitly if conversions may be applied to values of that type.
Due to bugs in certain (very old) compilers, there is widespread use
of enums and avoidance of in-class initialization of static integral
constant members. Compilers having such bugs are no longer supported.
Except where an enum is semantically appropriate, new code should use
integral constants.
alignas
Alignment-specifiers (alignas
n2341)
are permitted, with restrictions.
Alignment-specifiers are permitted when the requested alignment is a
fundamental alignment (not greater than alignof(std::max_align_t)
C++14 3.11/2).
Alignment-specifiers with an extended alignment (greater thanalignof(std::max_align_t)
C++14 3.11/3)
may only be used to align variables with static or automatic storage duration
(C++14 3.7.1, 3.7.3).
As a consequence, over-aligned types are forbidden; this may change if
HotSpot updates to using C++17 or later
(p0035r4).
Large extended alignments should be avoided, particularly for stack
allocated objects. What is a large value may depend on the platform and
configuration. There may also be hard limits for some platforms.
An alignment-specifier must always be applied to a definition
(C++14 10.6.2/6).
(C++ allows an alignment-specifier to optionally also be applied to a
declaration, so long as the definition has equivalent alignment. There isn't
any known benefit from duplicating the alignment in a non-definition
declaration, so such duplication should be avoided in HotSpot code.)
Enumerations are forbidden from having alignment-specifiers. Aligned
enumerations were originally permitted but insufficiently specified, and were
later (C++20) removed
(CWG 2354).
Permitting such usage in HotSpot now would just cause problems in the future.
Alignment-specifiers are forbidden in typedef and alias-declarations.
This may work or may have worked in some versions of some compilers, but was
later (C++14) explicitly disallowed
(CWG 1437).
The HotSpot macro ATTRIBUTE_ALIGNED provides similar capabilities for
platforms that define it. This macro predates the use by HotSpot of C++
versions providing alignas. New code should use alignas.
thread_local
Avoid use of thread_local
(n2659);
and instead, use the HotSpot macro THREAD_LOCAL, for which the initializer must
be a constant expression. When thread_local must be used, use the Hotspot macroAPPROVED_CPP_THREAD_LOCAL to indicate that the use has been given appropriate
consideration.
As was discussed in the review for
JDK-8230877,thread_local allows dynamic initialization and destruction
semantics. However, that support requires a run-time penalty for
references to non-function-local thread_local variables defined in a
different translation unit, even if they don't need dynamic
initialization. Dynamic initialization and destruction of
non-local thread_local variables also has the same ordering
problems as for ordinary non-local variables. So we avoid use ofthread_local in general, limiting its use to only those cases where dynamic
initialization or destruction are essential. See
JDK-8282469
for further discussion.
nullptr
Use nullptr
(n2431)
rather than NULL. See the paper for reasons to avoid NULL.
Don't use (constant expression or literal) 0 for pointers. Note that C++14
removed non-literal 0 constants from null pointer constants, though some
compilers continue to treat them as such.
<atomic>
Do not use facilities provided by the <atomic> header
(n2427),
(n2752);
instead, use the HotSpot Atomic class and related facilities.
Atomic operations in HotSpot code must have semantics which are
consistent with those provided by the JDK's compilers for Java. There
are platform-specific implementation choices that a C++ compiler might
make or change that are outside the scope of the C++ Standard, and
might differ from what the Java compilers implement.
In addition, HotSpot Atomic has a concept of "conservative" memory
ordering, which may differ from (may be stronger than) sequentially
consistent. There are algorithms in HotSpot that are believed to rely
on that ordering.
Variable Templates and Inline Variables
The use of variable templates (including static data member templates)
(N3651) is permitted. They provide parameterized
variables and constants in a simple and direct form, instead of requiring the
use of various workarounds.
Variables with static storage duration and variable templates may be declaredinline (p0386r2), and this usage is
permitted. This has similar effects as for declaring a function inline: it can
be defined, identically, in multiple translation units, must be defined in
every translation unit in which it is ODR used, and the behavior of the
program is as if there is exactly one variable.
Declaring a variable inline allows the complete definition to be in a header
file, rather than having a declaration in a header and the definition in a
.cpp file. The guidance on
initialization of such
variables still applies. Inline variables with dynamic initializations can
make initialization order problems worse. The few ordering constraints
that exist for non-inline variables don't apply, as there isn't a single
program-designated translation unit containing the definition.
A constexpr static data member or static data member template
is implicitly inline. As a consequence, an
ODR use of such a member doesn't require a definition in some .cpp
file. (This is a change from pre-C++17. Beginning with C++17, such a
definition is considered a duplicate definition, and is deprecated.)
Declaring a thread_local variable template or inline variable is forbidden
in HotSpot code. The use of thread_local is already
heavily restricted.
Initializing variables with static storage duration
Variables with static storage duration and dynamic initialization
C++14 3.6.2).
should be avoided, unless an implementation is permitted to perform the
initialization as a static initialization. The order in which dynamic
initializations occur is incompletely specified. Initialization order
problems can be difficult to deal with and lead to surprises.
Variables with static storage duration and non-trivial destructors should be
avoided. HotSpot doesn't generally try to cleanup on exit, and running
destructors at exit can lead to problems.
Some of the approaches used in HotSpot to avoid dynamic initialization
include:
Use the
DeferredStatic<T>class template. Add a call to its initialization
function at an appropriate place during VM initialization. The underlying
object is never destroyed.For objects of class type, use a variable whose value is a pointer to the
class, initialized tonullptr. Provide an initialization function that sets
the variable to a dynamically allocated object. Add a call to that function at
an appropriate place during VM initialization. Such objects are usually never
destroyed.
Uniform Initialization
The use of uniform initialization
(n2672),
also known as brace initialization, is permitted.
Some relevant sections from cppreference.com:
- initialization
- value initialization
- direct initialization
- list initialization
- aggregate initialization
Although related, the use of std::initializer_list remains forbidden, as
part of the avoidance of the C++ Standard Library in HotSpot code.
Mandatory Copy Elision
Copy elision
(or here)
is a compiler optimization used to avoid potentially expensive copies in
certain situations. It is critical to making practical the performance of
return by value or pass by value. It is also unusual in not following the
as-if rule for optimizations - copy elision can be applied even if doing so
bypasses side-effects of copying/moving the object. The C++ standard
explicitly permits this.
However, because it's an optional optimization, the relevant copy/move
constructor must be available and accessible, in case the compiler chooses to
not apply the optimization even in a situation where permitted.
C++17 changed some cases of copy elision so that there is never a copy/move in
these cases (p0135r1). The interesting cases
involve a function that returns an unnamed temporary object, and constructors.
In such cases the object being initialized from the temporary is always direct
initialized, with no copy/move ever involved; see RVO and more specifically
URVO.
Since this is now standard behavior it can't be avoided in the covered
situations. This could change the behavior of code that relied on side effects
by constructors, but that's both uncommon and was already problematic because
of the previous optional copy elision. But HotSpot code can, and should,
explicitly take advantage of this newly required behavior where it makes sense
to do so.
For example, it may be beneficial to delay construction of the result of a
function until the return statement, rather than having a local variable that
is modified into the desired state and then returned. (Though NRVO may apply
in that case.)
It is also now possible to define a factory function for a class that is
neither movable nor copyable, if it can be written in a way that makes use of
this feature.
Local Function Objects
- Local function objects, including lambda expressions, may be used.
- Lambda expressions must only be used as a downward value.
- Prefer
[&]as the capture list of a lambda expression. - Return type deduction for lambda expressions is permitted, and indeed encouraged.
- An empty parameter list for a lambda expression may be elided.
- A lambda expression must not be
mutable. - Generic lambda expressions are permitted.
- Lambda expressions should be relatively simple.
- Anonymous lambda expressions should not overly clutter the enclosing expression.
- An anonymous lambda expression must not be directly invoked.
- Bind expressions are forbidden.
Single-use function objects can be defined locally within a function,
directly at the point of use. This is an alternative to having a function
or function object class defined at class or namespace scope.
This usage was somewhat limited by C++03, which does not permit such a class
to be used as a template parameter. That restriction was removed by C++11
(n2657). Use of this feature is permitted.
Many HotSpot protocols involve "function-like" objects that involve some
named member function rather than a call operator. For example, a function
that performs some action on all threads might be written as
void do_something() {
struct DoSomething : public ThreadClosure {
virtual void do_thread(Thread* t) {
... do something with t ...
}
} closure;
Threads::threads_do(&closure);
}HotSpot code has historically usually placed the DoSomething class at
namespace (or sometimes class) scope. This separates the function's code
from its use, often to the detriment of readability. It requires giving the
class a globally unique name (if at namespace scope). It also loses the
information that the class is intended for use in exactly one place, and
does not have any subclasses. (However, the latter can now be indicated by
declaring it final.) Often, for simplicity, a local class will skip
things like access control and accessor functions, giving the enclosing
function direct access to the implementation and eliminating some
boilerplate that might be provided if the class is in some outer (more
accessible) scope. On the other hand, if there is a lot of surrounding code
in the function body or the local class is of significant size, defining it
locally can increase clutter and reduce readability.
C++11 added lambda expressions as a new way to write a function object.
Simple lambda expressions can be significantly more concise than a function
object, eliminating a lot of boiler-plate. On the other hand, a complex
lambda expression may not provide much, if any, readability benefit compared
to an ordinary function object. Also, while a lambda can encapsulate a call
to a "function-like" object, it cannot be used in place of such.
A common use for local functions is as one-use RAII objects. The amount
of boilerplate for a function object class (local or not) makes such usage
somewhat clumsy and verbose. But with the help of a small amount of
supporting utility code, lambdas work particularly well for this use case.
Another use for local functions is partial application. Again
here, lambdas are typically much simpler and less verbose than function
object classes.
A lambda is a constexpr function if either the parameter declaration clause is
followed by constexpr, or it satisfies the requirements for a constexpr
function (p0170r1). Thus, using a lambda to package up some computation
doesn't incur unnecessary overhead or prevent use in a context required to be
compile-time evaluated (such as an array size).
Because of these benefits, lambda expressions are permitted in HotSpot code,
with some restrictions and usage guidance. An anonymous lambda is one which
is passed directly as an argument. A named lambda is the value of a
variable, which is its name.
Lambda expressions should only be passed downward. In particular, a lambda
should not be returned from a function or stored in a global variable,
whether directly or as the value of a member of some other object. Lambda
capture is syntactically subtle (by design), and propagating a lambda in
such ways can easily pass references to captured values to places where they
are no longer valid. In particular, members of the enclosing this object
are effectively captured by reference, even if the default capture is
by-value. For such uses-cases a function object class should be used to
make the desired value capturing and propagation explicit.
Limiting the capture list to [&] (implicitly capture by reference) is a
simplifying restriction that still provides good support for HotSpot usage,
while reducing the cases a reader must recognize and understand.
Many common lambda uses require reference capture. Not permitting it
would substantially reduce the utility of lambdas.Referential transparency. Implicit reference capture makes variable
references in the lambda body have the same meaning they would have in the
enclosing code. There isn't a semantic barrier across which the meaning of
a variable changes.Explicit reference capture introduces significant clutter, especially when
lambda expressions are relatively small and simple, as they should be in
HotSpot code.There are a number of reasons why by-value capture might be used, but for
the most part they don't apply to HotSpot code, given other usage restrictions.A primary use-case for by-value capture is to support escaping uses,
where values captured by-reference might become invalid. That use-case
doesn't apply if only downward lambdas are used.By-value capture can also make a lambda-local copy for mutation, which
requires making the lambdamutable; see below.By-value capture might be viewed as an optimization, avoiding any
overhead for reference capture of cheap to copy values. But the
compiler can often eliminate any such overhead.By-value capture by a non-
mutablelambda makes the captured values
const, preventing any modification by the lambda and making the captured
value unaffected by modifications to the outer variable. But this only
applies to captured auto variables, not member variables, and is
inconsistent with referential transparency.
By-value capture of
this(using a capture list like[*this](p0018r3))
is also not permitted. One of the motivating use-cases is when the lifetime of
the lambda exceeds the lifetime of the object for the containing member
function. That is, we have an upward lambda that is capturingthisof the
enclosing method. But again, that use-case doesn't apply if only downward
lambdas are used.
Another use-case is when we simply want the lambda to be operating on a copy
ofthisfor some reason. This is sufficiently uncommon that it can be
handled by manual copying, so readers don't need to understand this rare
syntax.Non-capturing lambdas (with an empty capture list -
[]) have limited
utility. There are cases where no captures are required (pure functions,
for example), but if the function is small and simple then that's obvious
anyway.Capture initializers (a C++14 feature - N3649) are not permitted.
Capture initializers inherently increase the complexity of the capture list,
and provide little benefit over an additional in-scope local variable.The use of
mutablelambda expressions is forbidden because there don't
seem to be many, if any, good use-cases for them in HotSpot. A lambda
expression needs to be mutable in order to modify a by-value captured value.
But with only downward lambdas, such usage seems likely to be rare and
complicated. It is better to use a function object class in any such cases
that arise, rather than requiring all HotSpot developers to understand this
relatively obscure feature.
While it is possible to directly invoke an anonymous lambda expression, that
feature should not be used, as such a form can be confusing to readers.
Instead, name the lambda and call it by name.
Some reasons to prefer a named lambda instead of an anonymous lambda are
The body contains non-trivial control flow or declarations or other nested
constructs.Its role in an argument list is hard to guess without examining the
function declaration. Give it a name that indicates its purpose.It has an unusual capture list.
It has a complex explicit return type or parameter types.
Lambda expressions, and particularly anonymous lambda expressions, should be
simple and compact. One-liners are good. Anonymous lambdas should usually
be limited to a couple lines of body code. More complex lambdas should be
named. A named lambda should not clutter the enclosing function and make it
long and complex; do continue to break up large functions via the use of
separate helper functions.
An anonymous lambda expression should either be a one-liner in a one-line
expression, or isolated in its own set of lines. Don't place part of a
lambda expression on the same line as other arguments to a function. The
body of a multi-line lambda argument should be indented from the start of
the capture list, as if that were the start of an ordinary function
definition. The body of a multi-line named lambda should be indented one
step from the variable's indentation.
Some examples:
foo([&] { ++counter; });foo(x, [&] { ++counter; });foo([&] { if (predicate) ++counter; });foo([&] { auto tmp = process(x); tmp.f(); return tmp.g(); })Separate one-line lambda from other arguments:
textfoo(c.begin(), c.end(), [&] (const X& x) { do_something(x); return x.value(); });Indentation for multi-line lambda:
textc.do_entries([&] (const X& x) { do_something(x, a); do_something1(x, b); do_something2(x, c); });Separate multi-line lambda from other arguments:
textfoo(c.begin(), c.end(), [&] (const X& x) { do_something(x, a); do_something1(x, b); do_something2(x, c); });Multi-line named lambda:
textauto do_entry = [&] (const X& x) { do_something(x, a); do_something1(x, b); do_something2(x, c); };
Item 4, and especially items 6 and 7, are pushing the simplicity limits for
anonymous lambdas. Item 6 might be better written using a named lambda:
c.do_entries(do_entry);Note that C++11 also added bind expressions as a way to write a function
object for partial application, using std::bind and related facilities
from the Standard Library. std::bind generalizes and replaces some of the
binders from C++03. Bind expressions are not permitted in HotSpot code.
They don't provide enough benefit over lambdas or local function classes in
the cases where bind expressions are applicable to warrant the introduction
of yet another mechanism in this space into HotSpot code.
References:
- Local and unnamed types as template parameters (n2657)
- New wording for C++0x lambdas (n2927)
- Generalized lambda capture (init-capture) (N3648)
- Generic (polymorphic) lambda expressions (N3649)
References from C++17
References from C++20
- Allow lambda capture [=, this] (p0409r2)
- Familiar template syntax for generic lambdas (p0428r2)
- Simplifying implicit lambda capture (p0588r1)
- Default constructible and assignable stateless lambdas (p0624r2)
- Lambdas in unevaluated contexts (p0315r4)
- Allow pack expansion in lambda init-capture (p0780r2) (p2095r0)
- Deprecate implicit capture of this via [=] (p0806r2)
References from C++23
- Make () more optional for lambdas (p1102r2)
Inheriting constructors
Do not use inheriting constructors
(n2540).
C++11 provides simple syntax allowing a class to inherit the constructors of a
base class. Unfortunately there are a number of problems with the original
specification, and C++17 contains significant revisions (p0136r1 opens with
a list of 8 Core Issues). Although those issues have been addressed, the
benefits from this feature are small compared to the complexity. Because of
this, HotSpot code must not use inherited constructors.
Attributes
The use of some attributes
(n2761)
(listed below) is permitted. (Note that some of the attributes defined in
that paper didn't make it into the final specification.)
Attributes are syntactically permitted in a broad set of locations, but
specific attributes are only permitted in a subset of those locations. In
some cases an attribute that appertains to a given element may be placed in
any of several locations with the same meaning. In those cases HotSpot has a
preferred location.
- An attribute that appertains to a function is placed at the beginning of the
function's declaration, rather than between the function name and the parameter
list.
p0068r0 is the initial proposal for the attributes
added by C++17.)
Only the following attributes are permitted:
The following attributes are expressly forbidden:
[[carries_dependency]]- Related tomemory_order_consume.[[deprecated]]- Not relevant in HotSpot code.
Direct use of non-standard (and presumably scoped) attributes in shared code
is also forbidden. Using such would depend on the C++17 feature that an
attribute not recognized by the implementation is ignored
(p0283r2). If such an attribute is needed in
shared code, the well-established technique of providing an ATTRIBUTE_XXX
macro with per-compiler definitions (sometimes empty) should be
used. Compilers may warn about unrecognized attributes (whether by name or by
location), in order to report typos or misuse. Disabling such warnings
globally would not be desirable.
The use of using directives in attribute lists is also forbidden.
(p0028r0)
(p0028r4)
We don't generally use scoped attributes in attribute lists with other
attributes. Rather, uses of scoped attributes (which are implementation
defined) are generally hidden behind a portability macro that includes the
surrounding brackets.
noexcept
Use of noexcept exception specifications
(n3050)
are permitted with restrictions described below.
- Only the argument-less form of
noexceptexception specifications are
permitted. - Allocation functions that may return
nullptrto indicate allocation
failure must be declarednoexcept. - All other uses of
noexceptexception specifications are forbidden. noexceptexpressions are forbidden.- Dynamic exception specifications are forbidden.
HotSpot is built with exceptions disabled, e.g. compile with -fno-exceptions
(gcc, clang) or no /EH option (MSVC++). So why do we need to considernoexcept at all? It's because noexcept exception specifications serve two
distinct purposes.
The first is to allow the compiler to avoid generating code or data in support
of exceptions being thrown by a function. But this is unnecessary, because
exceptions are disabled.
The second is to allow the compiler and library code to choose different
algorithms, depending on whether some function may throw exceptions. This is
only relevant to a certain set of functions.
Some allocation functions (
operator newandoperator new[]) returnnullptrto indicate allocation failure. If anewexpression calls such an
allocation function, it must check for and handle that possibility. Declaring
such a functionnoexceptinforms the compiler thatnullptris a possible
result. If an allocation function is not declarednoexceptthen the compiler
may elide that checking and handling for anewexpression calling that
function.Certain Standard Library facilities (notably containers) provide different
guarantees for some operations (and may choose different algorithms to
implement those operations), depending on whether certain functions
(constructors, copy/move operations, swap) are nothrow or not. They detect
this using type traits that test whether a function is declarednoexcept.
This can have a significant performance impact if, for example, copying is
chosen over a potentially throwing move. But this isn't relevant, since
HotSpot forbids the use of most Standard Library facilities.
HotSpot code can assume no exceptions will ever be thrown, even from functions
not declared noexcept. So HotSpot code doesn't ever need to check, either
with conditional exception specifications or with noexcept expressions.
The exception specification is part of the type of a function
(p0012r1. This likely has little impact on HotSpot
code, since the use of noexcept is expected to be rare.
Dynamic exception specifications were deprecated in C++11. C++17 removed all
but throw(), with that remaining a deprecated equivalent to noexcept.
Enhanced selection statements
C++17 modified the condition part of if and switch statements, permitting
an init-statement to be included
(p0305r1).
Use of this feature is permitted. (However, complex uses may interfere with
readability.) Limiting the scope of a variable involved in the condition,
while also making the value available to the statement's body, can improve
readability. The alternative method of scope-limiting by introducing a nested
scope isn't very popular and is rarely used.
This new syntax is in addition to the condition being a declaration with a
brace-or-equal-initializer. For an if statement this new sytax gains that
benefit without violating the long-standing guidance against using
implicit conversions to bool,
which still stands.
For example, uses of Unified Logging sometimes explicitly check whether aLogTarget is enabled. Instead of
LogTarget(...) lt;
if (lt.is_enabled()) {
LogStream log(lt);
... use log ...
}
... lt is accessible but probably not needed here ...using this feature one could write
if (LogTarget(...) lt; lt.is_enabled()) {
LogStream log(lt);
... use log ...
}C++17 also added compile-time if statements
(p0292r2). Use of if constexpr is
permitted. This feature can replace and (sometimes vastly) simplify many uses
of SFINAE. The same declaration and initialization guidance for the
condition part apply here as for ordinary if statements.
Expression Evaluation Order
C++17 tightened up the evaluation order for some kinds of subexpressions
(p0138r2). Note, however, that the Alternate
Evaluation Order for Function Calls alternative in that paper was adopted,
rather than the strict left to right order of evaluation for function call
arguments that was proposed in the main body of the paper.
The primary purpose of this change seems to be to make certain kinds of call
chaining well defined. That's not a style widely used in HotSpot. In general
it is better to continue to avoid questions in this area by isolating
operations with side effects from other statements. In particular, continue to
avoid modifying a value in an expression where it is also used.
Compatibility with C11
C++17 refers to C11 rather than C99. This means that C11 libraries and
functions may be used in HotSpot. There may be limitations because of
differing levels of compatibility among various compilers and versions of
those compilers.
Note that the C parts of the JDK have been built with C11 selected for some
time (JDK-8292008).
Additional Permitted Features
alignof
(n2341)Sized deallocation
(n3778)Static assertions
(n1720)
(n3928)
Both the original (C++11) two-argument form and the new (C++17)
single-argument form are permitted.Right angle brackets
(n1757)Default template arguments for function templates
(CWG D226)Template aliases
(n2258)Delegating constructors
(n1986)Explicit conversion operators
(n2437)Standard Layout Types
(n2342)Defaulted and deleted functions
(n2346)Dynamic initialization and destruction with concurrency
(n2660)finalvirtual specifiers for classes and virtual functions
(n2928),
(n3206),
(n3272)overridevirtual specifiers for virtual functions
(n2928),
(n3206),
(n3272)Unrestricted Unions
(n2544)Hexadecimal Floating-Point Literals
(p0245r1)Construction Rules for
enum classValues
(p0138r2)Allow
typenamein template template parameter
(n4051) — template template parameters are
barely used (if at all) in HotSpot, but there's no reason to artificially
forbid this syntactic regularization in any such uses.
Forbidden Features
Structured Bindings
The use of structured bindings p0217r3 is
forbidden. Preferred approaches for handling functions with multiple return
values include
Return a named class/struct intended for that purpose, with named and typed
members/accessors.Return a value along with out parameters (usually pointers, sometimes
references).Designate a sentinel "failure" value in the normal return value type, with
some out of band location for additional information. For example, this is
the model typically used witherrno, where a function returns a normal
result, or -1 to indicate an error, with additional error information inerrno.
There is a strong preference for names and explicit types, as opposed to
offsets and implicit types. For example, there are folks who strongly dislike
that some of the Standard Library functions return std::pair because first
and second members don't carry any useful information.
File System Library
The use of the File System library is forbidden. HotSpot doesn't do very much
with files, and already has adequate mechanisms for its needs. Rewriting in
terms of this new library doesn't provide any obviously significant
benefits. Having a mix of the existing usage and uses of this new library
would be confusing.
n4100
p0218r0
p0219r1
p0317r1
p0392r0
p0430r2
p0492r2
p1164r1
Aggregate Extensions
Aggregates with base classes are forbidden. C++17 allows aggregate
initialization for classes with base classes
(p0017r1). HotSpot makes very little use of
aggregate classes, preferring explicit constructors even for very simple
classes.
Additional Forbidden Features
<algorithm>, ``,<numeric>
Not useful without standard containers or similar classes in HotSpot.`` - Overlap with HotSpot
BitMap.<cassert>,assert.h- HotSpot has its ownassertmacro.<exception>,<stdexcept>- Use of exceptions is not
permitted.Thread support - ``,
<mutex>,<shared_mutex>,<condition_varible>,<future>
HotSpot has its own threading support.Streams - HotSpot doesn't use the C++ I/O library.
<scoped_allocator>- Not useful without specialized allocators.<string>- Requires allocator support, similar to standard containers.<typeinfo>,<typeindex>
Use of runtime type information is not permitted.<valarray>- May allocate, but is not allocator-aware.New string and character literals
- New character types
(n2249) - Unicode string literals
(n2442) - Raw string literals
(n2442) - Universal character name literals
(n2170)
HotSpot doesn't need any of the new character and string literal
types.- New character types
User-defined literals
(n2765) —
User-defined literals should not be added casually, but only
through a proposal to add a specific UDL.Inline namespaces
(n2535) —
HotSpot makes very limited use of namespaces.using namespacedirectives. In particular, don't useusing namespace std;to avoid needing to qualify Standard Library names.Propagating exceptions
(n2179) —
HotSpot does not permit the use of exceptions, so this feature isn't useful.Avoid most operator overloading, preferring named functions. When
operator overloading is used, ensure the semantics conform to the
normal expected behavior of the operation.Avoid most implicit conversion constructors and (implicit or explicit)
conversion operators. Conversion tobooloperators aren't needed
because of the
no implicit boolean
guideline.)Avoid
gotostatements.Attributes for namespaces and enumerators
(n4266 —
The only applicable attribute is[[deprecated]], which is
forbidden.Variadic
usingdeclarations
(p0195r2)std::variant<>
(p0088r3) —
Even if more of the C++ Standard Library is permitted, this class will remain
forbidded. Invalid accesses are indicated by throwing exceptions.std::any
(p0220r1) —
Even if more of the C++ Standard Library is permitted, this class will remain
forbidden. It may require allocation, and always uses the standard
allocator. It requires RTTI.std::as_const()
(p0007r1) —
If sufficiently useful, HotSpot could add such a function. It would likely be
added to globalDefinitions.hpp, where there are already some similar small
utilities.std::clamp()
(p002501) —
This function is already provided in globalDefinitions.hpp.Parallel STL Algorithms
(p0024r2) —
Even if more of the C++ Standard Library is permitted, these will remain
forbidden. They are built on the standard C++ threading mechanisms. HotSpot
doesn't use those mechanisms, instead providing and using its own.Cache Line Sizes
p0154r1 —
HotSpot has its own mechanisms for this, using values likeDEFAULT_CACHE_LINE_SIZE. The platform-specific implementation of the HotSpot
mechanisms might use these library functions, but there is no reason to move
away from the current approach. Quoting from JOSUTTIS: "... if you know better,
use specific values, but using these values is better than any assumed fixed
size for code supporting multiple platforms."registerstorage class removal
p0001r1 —
Theregisterstorage class has been removed.registeris still a keyword,
so still can't be used for normal purposes. Also, this doesn't affect the use
ofregisterfor gcc-style extended asm code; that's a different syntactic
element with a different meaning.Value of
__cplusplus—
Testing whether__cplusplusis defined or not is permitted, and indeed
required. But the value should not need to be examined. The value is changed
with each revision of the Standard. But we build HotSpot and (most of) the
rest of the JDK with a specifically selected version of the Standard. The
value of__cplusplusshould be known and unchanging until we change the
project's build configuration again. So examining the value shouldn't ever be
necessary.Removal of
++forbool
(p0003r1)Removal of trigraphs
(n4086)
Undecided Features
This list is incomplete; it serves to explicitly call out some
features that have not yet been discussed.
Some features are undecided (so implicitly forbidden) because we don't expect
to use them at all. This might be reconsidered if someone finds a good use
case.
Some Standard Library features are undecided (so implicitly forbidden)
because, while this Style Guide forbids the use of such, they may be
sufficiently useful that we want to permit them anyway. Doing so may require
some idiomatic mechanism for addressing things like assert incompatibility,
incompatibility with HotSpot's FORBID_C_FUNCTION mechanism, and the like.
std::optional<>
It is undecided whether to permit the use of std::optional<>
(p0220r1). It may be sufficiently useful that it
should be permitted despite the usual prohibition against using Standard
Library facilities. Use of the value() member function must be forbidden, as
it reports an invalid access by throwing an exception.
std::byte
It is undecided whether to permit the use of the std::byte type
(p0298r3). It may be sufficiently useful that it
should be permitted despite the usual prohibition against using Standard
Library facilities.
It has been suggested that changing the HotSpot address type to usestd::byte has some benefits. That is, replace
typedef u_char* address;
typedef const u_char* const_address;using address = std::byte*;
using const_address = const std::byte*;in globalDefinitions.hpp.
A specific benefit that was mentioned is that it might improve the horrible
way that gdb handles our current definition of the address type.
#include <cstddef>
typedef unsigned char* address;
typedef std::byte* address_b;
int main() {
char* mem;
address addr = (address)mem;
address_b addr_b = (address_b)mem;
return 0;
}(gdb) p addr
$1 = (address) 0x7ffff7fe4fa0 <dl_main> "\363\017\036\372Uf\017\357\300H\211\345AWI\211\377AVAUATSH\201\354\210\002"
(gdb) p addr_b
$2 = (address_b) 0x7ffff7fe4fa0 <dl_main>This needs to be explored. Some folks have said they will do so.
String Views
It is undecided whether to permit the use of std::string_view
(p0220r1).
HotSpot doesn't use std::string, but uses char* strings a lot. Wrapping
such in a std::string_view to enable the use of various algorithms could be
useful. But since HotSpot also doesn't permit use of <algorithm> and the
like, that only gets the limited set of algorithms provided by the view class
directly.
There is also the issue of NUL termination; string views are not necessarilyNUL terminated. Moreover, if one goes to the work of making one that isNUL terminated, that terminator is included in the size.
There are other caveats. Permitting use of string views would require
discussion of those.
Substring and Subsequence Searching
In addition to simple substring searching, the Standard Library now includes
Boyer-Moore and Boyer-Moore-Horspool searchers, in case someone wants to
search really large texts. That seems an unlikely use-case for HotSpot. See
p0220r1.
`new` and `delete` with Over-Aligned Data
It is undecided whether to permit the use of dynamic allocation of overaligned
types (n3396).
HotSpot currently only has a couple of over-aligned types that are dynamically
allocated. These are handled manually, not going through new expressions, as
that couldn't work before C++17.
One of the ways an over-aligned type might arise is by aligning a data member.
This might be done to avoid destructive interference for concurrent accesses.
But HotSpot uses a different approach, using explicit padding. Again, this is
in part because new and delete of overaligned types didn't work. But we
might prefer to continue this approach.
We would need to add operator new overloads to CHeapObj<> and possibly in
other places in order to support this. However, it has been suggested that
implementing it (efficiently) on top of NMT might be difficult. Note thatposix_memalign / _aligned_malloc don't help here, because of NMT's use of
malloc headers.
If we don't support it we may want to add operator new overloads that are
deleted, to prevent attempted uses.
Alignment usage in non-HotSpot parts of the OpenJDK:
alignasused once in harfbuzz, to align a variable.libpipewire has
#define SPA_ALIGNEDmacro using gccalignedattribute,
but doesn't use it.libsleef has
#define ALIGNEDmacro using gccalignedattribute. It is
not used for class or member declarations.
`std::to_chars()` and `std::from_chars`
It is undecided whether to permit the use of std::to_chars() andstd::from_chars() (p0067r5).
These functions provide low-level conversions between character sequences and
numeric values. This seems like a good candidate for use in HotSpot,
potentially replacing various clumsy or less performant alternatives. There is
no memory allocation. Parsing failures are indicated via error codes rather
than exceptions. Various other nice for HotSpot properties.
Note that the published C++17 Standard puts these in ``, but a defect
report moved them to <charconv>. This also needs <system_error>.
This would require upgrading the minimum gcc version to 11.1 for floating
point conversion support. The minimum Visual Studio version is already
sufficient. The minimum clang version requirement hasn't been determined yet.
`std::launder()`
It is undecided whether to permit the use of std::launder()
(p0137r1).
Change to permitted if we discover a place where we need it. Or maybe we
should just permit it, but hope we don't need it.
Also, C++20 revised the relevant part of Object Lifetime in a way that seems
more permissive and with less need of laundering. We don't know if
implementations of prior versions take advantage of the difference.
See Object Lifetime: C++17 6.8/8, C++20 6.7.3/8
Additional Undecided Features
Member initializers and aggregates
(n3653)Rvalue references and move semantics
Shorthand for nested namespaces
(n4230) —
HotSpot makes very little use of namespaces, so this seemingly innocuous
feature probably isn't useful to us.Direct list initialization with
auto
(n3681) —
This change fixed some issues with direct list initialization andauto. But
we don't use that feature much, if at all. And perhaps shouldn't be using it.UTF-8 Character Literals
(n4267) —
Do we have a use-case for this?Fold Expressions
(n4295) —
Provides a simple way to apply operators to a parameter pack. HotSpot doesn't
use variadic templates very much. That makes it questionable that developers
should need to know about this feature. But if someone does come up with a
good use-case, it's likely that the alternatives are significantly worse,
because pack manipulation without this can be complicated.<tuple>—
Prefer named access to class objects, rather than indexed access
to anonymous heterogeneous sequences. In particular, a standard-layout
class is preferred to a tuple.std::invoke<>()
(n4169)<chrono>—
The argument for chrono is that our existing APIs aren't serving us well.
chrono provides strong type safety. We've had multiple cases of mistakes like
a double seconds being treated as double milliseconds or vice versa, and other
similar errors. But it would be a large effort to adopt chrono. We'd also need
to decide whether to use the predefined clocks or hook up chrono to our
clocks. It may be that using the predefined clocks is fine, but it's a
question that needs careful study.`` —
The potential ambiguity between some forms of direct initialization and
initializer list initialization, and the resolution of that ambiguity, is
unfortunate.<ratio>—<ratio>is a compile-time rational arithmetic package. It's also fixed
(though parameterized) precision. It's not a general purpose rational
arithmetic facility. It appears to have started out as an implementation
detail of chrono, and was extracted and promoted to a public facility in the
belief that it has broader utility.<system_error>—
We don't really have a generally agreed upon mechanism for managing
errors. Instead, we have a plethora of bespoke ad hoc mechanisms. Managing
errors is a topic of substantial discussion.<system_error>might end up
being a part of a result from that discussion.
Doc Hotspot Unit Tests (`doc/hotspot-unit-tests.md`)
% Native/Unit Test Development Guidelines
The purpose of these guidelines is to establish a shared vision on
what kind of native tests and how we want to develop them for Hotspot
using GoogleTest. Hence these guidelines include style items as well
as test approach items.
First section of this document describes properties of good tests
which are common for almost all types of test regardless of language,
framework, etc. Further sections provide recommendations to achieve
those properties and other HotSpot and/or GoogleTest specific
guidelines.
Good test properties
Lightness
Use the most lightweight type of tests.
In Hotspot, there are 3 different types of tests regarding their
dependency on a JVM, each next level is slower than previous
TEST: a test does not depend on a JVMTEST_VM: a test does depend on an initialized JVM, but are
supposed not to break a JVM, i.e. leave it in a workable state.TEST_OTHER_VM: a test depends on a JVM and requires a freshly
initialized JVM or leaves a JVM in non-workable state
Isolation
Tests have to be isolated: not to have visible side-effects,
influences on other tests results.
Results of one test should not depend on test execution order, other
tests, otherwise it is becoming almost impossible to find out why a
test failed. Due to hotspot-specific, it is not so easy to get a full
isolation, e.g. we share an initialized JVM between all TEST_VM tests,
so if your test changes JVM's state too drastically and does not
change it back, you had better consider TEST_OTHER_VM.
Atomicity and self-containment
Tests should be atomic and self-contained at the same time.
One test should check a particular part of a class, subsystem,
functionality, etc. Then it is quite easy to determine what parts of a
product are broken basing on test failures. On the other hand, a test
should test that part more-or-less entirely, because when one sees a
test FooTest::bar, they assume all aspects of bar from Foo are tested.
However, it is impossible to cover all aspects even of a method, not
to mention a subsystem. In such cases, it is recommended to have
several tests, one for each aspect of a thing under test. For example
one test to tests how Foo::bar works if an argument is null, another
test to test how it works if an argument is acceptable but Foo is not
in the right state to accept it and so on. This helps not only to make
tests atomic, self-contained but also makes test name self-descriptive
(discussed in more details in Test names).
Repeatability
Tests have to be repeatable.
Reproducibility is very crucial for a test. No one likes sporadic test
failures, they are hard to investigate, fix and verify a fix.
In some cases, it is quite hard to write a 100% repeatable test, since
besides a test there can be other moving parts, e.g. in case ofTEST_VM there are several concurrently running threads. Despite this,
we should try to make a test as reproducible as possible.
Informativeness
In case of a failure, a test should be as informative as possible.
Having more information about a test failure than just compared values
can be very useful for failure troubleshooting, it can reduce or even
completely eliminate debugging hours. This is even more important in
case of not 100% reproducible failures.
Achieving this property, one can easily make a test too verbose, so it
will be really hard to find useful information in the ocean of useless
information. Hence they should not only think about how to provide
good information, but also
when to do it.
Testing instead of visiting
Tests should test.
It is not enough just to "visit" some code, a test should check that
code does that it has to do, compare return values with expected
values, check that desired side effects are done, and undesired are
not, and so on. In other words, a test should contain at least one
GoogleTest assertion and do not rely on JVM asserts.
Generally speaking to write a good test, one should create a model of
the system under tests, a model of possible bugs (or bugs which one
wants to find) and design tests using those models.
Nearness
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 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.
Asserts
Several checks
Prefer EXPECT over ASSERT if possible.
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 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 bothASSERT/EXPECT.
When it is possible to make several different checks, but impossible
to continue test execution if at least one check fails, you can
use ::testing::Test::HasNonfatalFailure() function. The recommended
way to express that isASSERT_FALSE(::testing::Test::HasNonfatalFailure()). Besides making it
clear why a test is aborted, it also allows you to provide more
information about a failure.
First parameter is expected value
In all equality assertions, expected values should be passed as the
first parameter.
This convention is adopted by GoogleTest, and there is a slight
difference in how GoogleTest treats parameters, the most important one
is null detection. Due to different reasons, null detection is enabled
only for the first parameter, that is to said EXPECT_EQ(NULL, object)
checks that object is null, while EXPECT_EQ(object, NULL) checks that
object equals to NULL, GoogleTest is very strict regarding types of
compared values so the latter will generates a compile-time error.
Floating-point comparison
Use floating-point special macros to compare float/double values.
Because of floating-point number representations and round-off errors,
regular equality comparison will not return true in most cases. There
are special EXPECT_FLOAT_EQ/EXPECT_DOUBLE_EQ assertions which check
that the distance between compared values is not more than 4 ULPs,
there is also EXPECT_NEAR(v1, v2, eps) which checks that the absolute
value of the difference between v1 and v2 is not greater than eps.
C string comparison
Use string special macros for C strings comparisons.
EXPECT_EQ just compares pointers' values, which is hardly what one
wants comparing C strings. GoogleTest provides EXPECT_STREQ andEXPECT_STRNE macros to compare C string contents. There are also
case-insensitive versions EXPECT_STRCASEEQ, EXPECT_STRCASENE.
Error messages
Provide informative, but not too verbose error messages.
All GoogleTest asserts print compared expressions and their values, so
there is no need to have them in error messages. Asserts print only
compared values, they do not print any of interim variables, e.g.ASSERT_TRUE((val1 == val2 && isFail(foo(8))) || i == 18) prints only
one value. If you use some complex predicates, please considerEXPECT_PRED* or EXPECT_FORMAT_PRED assertions family, they check that
a predicate returns true/success and print out all parameters values.
However in some cases, default information is not enough, a commonly
used example is an assert inside a loop, GoogleTest will not print
iteration values (unless it is an assert's parameter). Other
demonstrative examples are printing error code and a corresponding
error message; printing internal states which might have an impact on
results. One should add this information to assert message using <<
operator.
Uncluttered output
Print information only if it is needed.
Too verbose tests which print all information even if they pass are
very bad practice. They just pollute output, so it becomes harder to
find useful information. In order not print information till it is
really needed, one should consider saving it to a temporary buffer and
pass to an assert.
https://git.openjdk.org/jdk/blob/master/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp
has a good example how to do that.
Failures propagation
Wrap a subroutine call into EXPECT_NO_FATAL_FAILURE macro to
propagate failures.
ASSERT and FAIL abort only the current function, so if you have them
in a subroutine, a test will not be aborted after the subroutine even
if ASSERT or FAIL fails. You should call such subroutines inASSERT_NO_FATAL_FAILURE macro to propagate fatal failures and abort a
test. (EXPECT|ASSERT)_NO_FATAL_FAILURE can also be used to provide
more information.
Due to obvious reasons, there are no(EXPECT|ASSERT)_NO_NONFATAL_FAILURE macros. However, if you need to
check if a subroutine generated a nonfatal failure (failed an EXPECT),
you can use ::testing::Test::HasNonfatalFailure function,
or ::testing::Test::HasFailure function to check if a subroutine
generated any failures, see Several checks.
Naming and Grouping
Test group names
Test group names should be in CamelCase, start and end with a letter.
A test group should be named after tested class, functionality,
subsystem, etc.
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 so forth.
Filename
A test file must have test_ prefix and .cpp suffix.
Both are actually requirements from the current build system to
recognize your tests.
File location
Test file location should reflect a location of the tested part of the product.
All unit tests for a class from
foo/bar/baz.cppshould be placedfoo/bar/test_baz.cppin thetest/hotspot/gtest/directory. Having all
tests for a class in one file is a common practice for unit tests, it
helps to see all existing tests at once, share functions and/or
resources without losing encapsulation.For tests which test more than one class, directory hierarchy should
be the same as product hierarchy, and file name should reflect the
name of the tested subsystem/functionality. For example, if a
sub-system under tests belongs togc/g1, tests should be placed ingc/g1directory.
Please note that framework prepends directory name to a test group
name. For example, if TEST(foo, check_this) and TEST(bar, check_that)
are defined in test/hotspot/gtest/gc/shared/test_foo.cpp file, they
will be reported as gc/shared/foo::check_this andgc/shared/bar::check_that.
Test names
Test names should be in small_snake_case, start and end with a letter.
A test name should reflect that a test checks.
Such naming makes tests self-descriptive and helps a lot during the
whole test life cycle. It is easy to do test planning, test inventory,
to see what things are not tested, to review tests, to analyze test
failures, to evolve a test, etc. For examplefoo_return_0_if_name_is_null is better than foo_sanity or foo_basic or
just foo, humongous_objects_can_not_be_moved_by_young_gc is better
than ho_young_gc.
Actually using underscore is against GoogleTest project convention,
because it can lead to illegal identifiers, however, this is too
strict. Restricting usage of underscore for test names only and
prohibiting test name starts or ends with an underscore are enough to
be safe.
Fixture classes
Fixture classes should be named after tested classes, subsystems, etc
(follow Test group names rule) and haveTest suffix to prevent class name conflicts.
Friend classes
All test purpose friends should have either Test or Testable suffix.
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 evil to get testability.
OS/CPU specific tests
Guard OS/CPU specific tests by #ifdef and have OS/CPU name in filename.
For the time being, we do not support separate directories for OS,
CPU, OS-CPU specific tests, in case we will have lots of such tests,
we will change directory layout and build system to support that in
the same way it is done in hotspot.
Miscellaneous
Hotspot style
Abide the norms and rules accepted in Hotspot style guide.
Tests are a part of Hotspot, so everything (if applicable) we use for
Hotspot, should be used for tests as well. Those guidelines cover
test-specific things.
Code/test metrics
Coverage information and other code/test metrics are quite useful to
decide what tests should be written, what tests should be improved and
what can be removed.
For unit tests, widely used and well-known coverage metric is branch
coverage, which provides good quality of tests with relatively easy
test development process. For other levels of testing, branch coverage
is not as good, and one should consider others metrics, e.g.
transaction flow coverage, data flow coverage.
Access to non-public members
Use explicit friend class to get access to non-public members.
We do not use GoogleTest macro to declare friendship relation,
because, from our point of view, it is less clear than an explicit
declaration.
Declaring a test fixture class as a friend class of a tested test is
the easiest and the clearest way to get access. However, it has some
disadvantages, here is some of them:
- Each test has to be declared as a friend
- Subclasses do not inheritance friendship relation
In other words, it is harder to share code between tests. Hence if you
want to share code or expect it to be useful in other tests, you
should consider making members in a tested class protected and
introduce a shared test-only class which expose those members via
public functions, or even making members publicly accessible right
away in a product class. If it is not an option to change members
visibility, one can create a friend class which exposes members.
Death tests
You can not use death tests inside TEST_OTHER_VM and TEST_VM_ASSERT*.
We tried to make Hotspot-GoogleTest integration as transparent as
possible, however, due to the current implementation of TEST_OTHER_VM
and TEST_VM_ASSERT* tests, you cannot use death test functionality in
them. These tests are implemented as GoogleTest death tests, and
GoogleTest does not allow to have a death test inside another death
test.
External flags
Passing external flags to a tested JVM is not supported.
The rationality of such design decision is to simplify both tests and
a test framework and to avoid failures related to incompatible flags
combination till there is a good solution for that. However there are
cases when one wants to test a JVM with specific flags combination,_JAVA_OPTIONS environment variable can be used to do that. Flags from_JAVA_OPTIONS will be used in TEST_VM, TEST_OTHER_VM andTEST_VM_ASSERT* tests.
Test-specific flags
Passing flags to a tested JVM in TEST_OTHER_VM and TEST_VM_ASSERT*
should be possible, but is not implemented yet.
Facility to pass test-specific flags is needed for system, regression
or other types of tests which require a fully initialized JVM in some
particular configuration, e.g. with Serial GC selected. There is no
support for such tests now, however, there is a plan to add that in
upcoming releases.
For now, if a test depends on flags values, it should have if (!<flag>) { return } guards in the very beginning and @requires
comment similar to jtreg @requires directive right before test macros.
https://git.openjdk.org/jdk/blob/master/test/hotspot/gtest/gc/g1/test_g1IHOPControl.cpp
ha an example of this temporary workaround. It is important to follow
that pattern as it allows us to easily find all such tests and update
them as soon as there is an implementation of flag passing facility.
In long-term, we expect jtreg to support GoogleTest tests as first
class citizens, that is to say, jtreg will parse @requires comments
and filter out inapplicable tests.
Flag restoring
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
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 class, which sometimes is too wordy. The
simpler facilities like FLAG_GUARD macro or *FlagSetting classes could
be used in such cases to restore/set values.
Caveats:
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 order to
maintain invariants) so it is hard to predict what flags will be
changed and it makes restoring all changed flags a nontrivial task.
Thus in case one usesFLAG_SET_*macros, they should useTEST_OTHER_VM
test type.
GoogleTest documentation
In case you have any questions regarding GoogleTest itself, its
asserts, test declaration macros, other macros, etc, please consult
its documentation.
TODO
Although this document provides guidelines on the most important parts
of test development using GTest, it still misses a few items:
Examples, esp for access to non-public members
test types: purpose, drawbacks, limitation
TEST_VMTEST_VM_FTEST_OTHER_VMTEST_VM_ASSERTTEST_VM_ASSERT_MSG
Miscellaneous
- Test libraries
- where to place
- how to write
- how to use
- test your tests
- how to run tests in random order
- how to run only specific tests
- how to run each test separately
- check that a test can find bugs it is supposed to by introducing them
- mocks/stubs/dependency injection
- setUp/tearDown
- vs c-tor/d-tor
- empty test to test them
- internal (declared in .cpp) struct/classes
- Test libraries
Doc Ide (`doc/ide.md`)
% IDE support in the JDK
Introduction
When you are familiar with building and testing the JDK, you may want to
configure an IDE to work with the source code. The instructions differ a bit
depending on whether you are interested in working with the native (C/C++) or
the Java code.
IDE support for native code
There are a few ways to generate IDE configuration for the native sources,
depending on which IDE to use.
Visual Studio Code
The make system can generate a Visual Studio Code
workspace that has C/C++ source indexing configured correctly, as well as
launcher targets for tests and the Java launcher. After configuring, a workspace
for the configuration can be generated using:
make vscode-projectThis creates a file called jdk.code-workspace in the build output folder. The
full location will be printed after the workspace has been generated. To use it,
choose File -> Open Workspace... in Visual Studio Code.
Alternative indexers
The main vscode-project target configures the default C++ support in Visual
Studio Code. There are also other source indexers that can be installed, that
may provide additional features. It's currently possible to generate
configuration for three such indexers, clangd,
ccls
and rtags. These can be configured by
appending the name of the indexer to the make target, such as:
make vscode-project-clangdAdditional instructions for configuring the given indexer will be displayed
after the workspace has been generated.
Visual Studio
The make system can generate a Visual Studio project for the Hotspot
native source. After configuring, the project is generated using:
make hotspot-ide-projectThis creates a file named jvm.vcxproj in ide\hotspot-visualstudio
subfolder of the build output folder. The file can be opened in Visual Studio
via File -> Open -> Project/Solution.
Eclipse CDT
The make system can generate an Eclipse CDT Workspace that enables Eclipse
indexing for the C and C++ sources throughout the entire codebase, as well as
registering all common make targets to be runnable from the Eclipse explorer.
This can be done after configuring by running:
make eclipse-native-envAfter this is run, simply open and import the workspace in Eclipse throughFile -> Import -> Projects from Folder or Archive and atImport source click on the directory ide\eclipse, which can be
found in the build output folder.
If this doesn't work, you can also tryFile -> Import -> Existing Projects into Workspace
instead.
Setting up an Eclipse Workspace is relatively lightweight compared to other
supported IDEs, but requires that your CDT installation has Cross GCC support
enabled at the moment, even if you aren't cross compiling. The Visual C++
compiler is, at present, not supported as an indexer.
If desired, you can instead request make to only include indexing support for
just the Java Virtual Machine instead of the entire native codebase, by running:
make eclipse-hotspot-envIf you think your particular Eclipse installation can handle the strain, the
make system also supports generating a combined Java and C/C++ Workspace for
Eclipse which can then conveniently switch between Java and C/C++ natures
during development by running:
make eclipse-mixed-envDo note that this generates all features that come with both Java and C/C++
natures.
Eclipse support in the JDK is relatively new, so do keep in mind that not
everything may work at the moment. As such, the resulting Workspace also
has compilation database parsing support enabled, so you can pass Eclipse
the compile commands file (see below) if all else fails.
Compilation Database
The make system can generate generic native code indexing support in the form of
a Compilation Database
that can be used by many different IDEs and source code indexers.
make compile-commandsIt's also possible to generate the Compilation Database for the HotSpot source
code only, which is a bit faster as it includes less information.
make compile-commands-hotspotIDE support for Java code
IntelliJ IDEA
The JDK project has a script that can be used for indexing the project
with IntelliJ. After configuring and building the JDK, an IntelliJ workspace
can be generated by running the following command in the top-level folder
of the cloned repository:
bash bin/idea.shTo use it, choose File -> Open... in IntelliJ and select the folder where
you ran the above script.
Next, configure the project SDK in IntelliJ. OpenFile -> Project Structure -> Project and select build/<config>/images/jdk
as the SDK to use.
In order to run the tests from the IDE, you can use the JTReg plugin.
Instructions for building and using the plugin can be found
here.
Eclipse
Eclipse JDT is a widely used Java IDE and has been for a very long time, being
a popular choice alongside IntelliJ IDEA for Java development. Likewise, the
JDK now includes support for developing its Java sources with Eclipse, which
can be achieved by setting up a Java Workspace by running:
make eclipse-java-envAfter the workspace has been generated you can import it in the same way as
you would with Eclipse CDT:
Follow File -> Import -> Projects from Folder or Archive and select theide\eclipse directory in the build output folder to import the newly created
Java Workspace.
If doing so results in an error, you can also import the JDK viaFile -> Import -> Existing Projects into Workspace
as a last resort.
As mentioned above for Eclipse CDT, you can create a combined Java and C/C++
Workspace which can conveniently switch between Java and C/C++ natures during
development by running:
make eclipse-mixed-envDoc Starting Next Release (`doc/starting-next-release.md`)
% Explanation of start of release changes
Overview
The start of release changes, the changes that turn JDK N into JDK
(N+1), are primarily small updates to various files along with new files to
store symbol information to allow javac --release N ... to run on
JDK (N+1).
The updates include changes to files holding meta-data about the
release, files under the src directory for API and tooling updates,
and incidental updates under the test directory.
Details and file updates
As a matter of policy, there are a number of semantically distinct
concepts which get incremented separately at the start of a new
release:
- Feature value of
Runtime.version() - Highest source version modeled by
javax.lang.model.SourceVersion - Highest class file format major version recognized by the platform
- Highest
-source/-target/--releaseargument recognized byjavacand related tools
The expected file updates are listed below. Additional files may need
to be updated for a particular release.
Meta-data files
jcheck/conf: update meta-data used byjcheckand the Skara toolingmake/conf/version-numbers.conf: update to meta-data used in the build
`src` files
src/hotspot/share/classfile/classFileParser.cpp: add a#define
for the new versionsrc/java.base/share/classes/java/lang/classfile/ClassFile.java:
add a constant for the new class file format versionsrc/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java:
add anenumconstant for the new class file format versionsrc/java.compiler/share/classes/javax/lang/model/SourceVersion.java:
add anenumconstant for the new source versionsrc/java.compiler/share/classes/javax/lang/model/util/*visitors: Update@SupportedSourceVersionannotations to latest value. Note this update
is done in lieu of introducing another set of visitors for each Java
SE release.src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java:
add anenumconstant for the new source version internal tojavacsrc/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java:
add anenumconstant for the new class file format version internal tojavacsrc/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java:
add anenumconstant for the new target version internal tojavacsrc/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
update printing processor to support the new source version- The symbol information for
--releaseis stored as new text files in thesrc/jdk.compiler/share/data/symbolsdirectory, one file per
module. The README file in that directory contains directions on how
to create the files.
`test` files
test/langtools/tools/javac/api/TestGetSourceVersions.java: add newSourceVersionconstant to test matrix.test/langtools/tools/javac/classfiles/ClassVersionChecker.java: add new enum constant for the new class file versiontest/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java
update annotation processor extended byjavactests to cover the new source versiontest/langtools/tools/javac/preview/classReaderTest/Client.nopreview.outandtest/langtools/tools/javac/preview/classReaderTest/Client.preview.out: update expected messages for preview errors and warningstest/langtools/tools/javac/versions/Versions.java: add new source version to the set of valid sources and add new enum constant for the new class file version.
Doc Testing (`doc/testing.md`)
% Testing the JDK
Overview
The bulk of JDK tests use jtreg, a regression
test framework and test runner built for the JDK's specific needs. Other test
frameworks are also used. The different test frameworks can be executed
directly, but there is also a set of make targets intended to simplify the
interface, and figure out how to run your tests for you.
Running tests locally with `make test`
This is the easiest way to get started. Assuming you've built the JDK locally,
execute:
$ make testThis will run a default set of tests against the JDK, and present you with the
results. make test is part of a family of test-related make targets which
simplify running tests, because they invoke the various test frameworks for
you. The "make test framework" is simple to start with, but more complex ad-hoc
combination of tests is also possible. You can always invoke the test
frameworks directly if you want even more control.
Some example command-lines:
$ make test-tier1
$ make test-jdk_lang JTREG="JOBS=8"
$ make test TEST=jdk_lang
$ make test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
$ make test TEST="hotspot:hotspot_gc" JTREG="JOBS=1;TIMEOUT_FACTOR=8;JAVA_OPTIONS=-XshowSettings -Xlog:gc+ref=debug"
$ make test TEST="jtreg:test/hotspot:hotspot_gc test/hotspot/jtreg/native_sanity/JniVersion.java"
$ make test TEST="micro:java.lang.reflect" MICRO="FORK=1;WARMUP_ITER=2"
$ make exploded-test TEST=tier2"tier1" and "tier2" refer to tiered testing, see further down. "TEST" is a test
selection argument which the make test framework will use to try to find the
tests you want. It iterates over the available test frameworks, and if the
test isn't present in one, it tries the next one. The main target test uses
the jdk-image as the tested product. There is also an alternate target
exploded-test that uses the exploded image instead. Not all tests will run
successfully on the exploded image, but using this target can greatly improve
rebuild times for certain workflows.
Previously, make test was used to invoke an old system for running tests, andmake run-test was used for the new test framework. For backward compatibility
with scripts and muscle memory, run-test and variants likeexploded-run-test or run-test-tier1 are kept as aliases.
Configuration
To be able to run JTReg tests, configure needs to know where to find the
JTReg test framework. If it is not picked up automatically by configure, use
the --with-jtreg= option to point to the JTReg framework.
Note that this option should point to the JTReg home, i.e. the top directory,
containing lib/jtreg.jar etc. (An alternative is to set the JT_HOME
environment variable to point to the JTReg home before running configure.)
To be able to run microbenchmarks, configure needs to know where to find the
JMH dependency. Use --with-jmh= to point to a directory
containing the core JMH and transitive dependencies. The recommended
dependencies can be retrieved by running sh make/devkit/createJMHBundle.sh,
after which --with-jmh=build/jmh/jars should work.
When tests fail or timeout, jtreg runs its failure handler to capture necessary
data from the system where the test was run. This data can then be used to
analyze the test failures. Collecting this data involves running various
commands (which are listed in files residing intest/failure_handler/src/share/conf) and some of these commands use sudo.
If the system's sudoers file isn't configured to allow running these
commands, then it can result in password being prompted during the failure
handler execution. Typically, when running locally, collecting this additional
data isn't always necessary. To disable running the failure handler, use--enable-jtreg-failure-handler=no when running configure. If, however, you
want to let the failure handler to run and don't want to be prompted for sudo
password, then you can configure your sudoers file appropriately. Please read
the necessary documentation of your operating system to see how to do that;
here we only show one possible way of doing that - edit the/etc/sudoers.d/sudoers file to include the following line:
johndoe ALL=(ALL) NOPASSWD: /sbin/dmesgThis line configures sudo to not prompt for password for the /sbin/dmesg
command (this is one of the commands that is listed in the files attest/failure_handler/src/share/conf), for the user johndoe. Here johndoe
is the user account under which the jtreg tests are run. Replace the username
with a relevant user account of your system.
Test selection
All functionality is available using the test make target. In this use case,
the test or tests to be executed is controlled using the TEST variable. To
speed up subsequent test runs with no source code changes, test-only can be
used instead, which do not depend on the source and test image build.
For some common top-level tests, direct make targets have been generated. This
includes all JTReg test groups, the hotspot gtest, and custom tests (if
present). This means that make test-tier1 is equivalent to make test TEST="tier1", but the latter is more tab-completion friendly. For more complex
test runs, the test TEST="x" solution needs to be used.
The test specifications given in TEST is parsed into fully qualified test
descriptors, which clearly and unambiguously show which tests will be run. As
an example, :tier1 will expand to include all subcomponent test directories
that define tier1, for example: jtreg:$(TOPDIR)/test/hotspot/jtreg:tier1 jtreg:$(TOPDIR)/test/jdk:tier1 jtreg:$(TOPDIR)/test/langtools:tier1 .... You
can always submit a list of fully qualified test descriptors in the TEST
variable if you want to shortcut the parser.
Common Test Groups
Ideally, all tests are run for every change but this may not be practical due
to the limited testing resources, the scope of the change, etc.
The source tree currently defines a few common test groups in the relevantTEST.groups files. There are test groups that cover a specific component, for
example hotspot_gc. It is a good idea to look into TEST.groups files to get
a sense what tests are relevant to a particular JDK component.
Component-specific tests may miss some unintended consequences of a change, so
other tests should also be run. Again, it might be impractical to run all
tests, and therefore tiered test groups exist. Tiered test groups are not
component-specific, but rather cover the significant parts of the entire JDK.
Multiple tiers allow balancing test coverage and testing costs. Lower test
tiers are supposed to contain the simpler, quicker and more stable tests.
Higher tiers are supposed to contain progressively more thorough, slower, and
sometimes less stable tests, or the tests that require special configuration.
Contributors are expected to run the tests for the areas that are changed, and
the first N tiers they can afford to run, but at least tier1.
A brief description of the tiered test groups:
tier1: This is the most fundamental test tier. Roughly speaking, a failure
of a test in this tier has the potential to indicate a problem that would
affect many Java programs. Tests intier1include tests of HotSpot, core
APIs in thejava.basemodule, and thejavaccompiler. Multiple developers
run these tests every day. Because of the widespread use, the tests intier1are carefully selected and optimized to run fast, and to run in the
most stable manner. As a guideline, nearly all individual tests intier1
are expected to run to completion in ten seconds or less when run on common
configurations used for development. Long-running tests, even of core
functionality, should occur in higher tiers or be covered in other kinds of
testing. The test failures intier1are usually followed up on quickly,
either with fixes, or adding relevant tests to problem list. GitHub Actions
workflows, if enabled, runtier1tests.tier2: This test group covers even more ground. These contain, among other
things, tests that either run for too long to be attier1, or may require
special configuration, or tests that are less stable, or cover the broader
range of non-core JVM and JDK features/components (for example, XML).tier3: This test group includes more stressful tests, the tests for corner
cases not covered by previous tiers, plus the tests that require GUIs. As
such, this suite should either be run with low concurrency (TEST_JOBS=1),
or without headful tests(JTREG_KEYWORDS=\!headful), or both.tier4: This test group includes every other test not covered by previous
tiers. It includes, for example,vmTestbasesuites for Hotspot, which run
for many hours even on large machines. It also runs GUI tests, so the sameTEST_JOBSandJTREG_KEYWORDScaveats apply.
JTReg
JTReg tests can be selected either by picking a JTReg test group, or a
selection of files or directories containing JTReg tests. Documentation can be
found at https://openjdk.org/jtreg/, note
especially the extensive FAQ.
JTReg test groups can be specified either without a test root, e.g. :tier1
(or tier1, the initial colon is optional), or with, e.g. hotspot:tier1,test/jdk:jdk_util or $(TOPDIR)/test/hotspot/jtreg:hotspot_all. The test
root can be specified either as an absolute path, or a path relative to the JDK
top directory, or the test directory. For simplicity, the hotspot JTReg test
root, which really is hotspot/jtreg can be abbreviated as just hotspot.
When specified without a test root, all matching groups from all test roots
will be added. Otherwise, only the group from the specified test root will be
added.
Individual JTReg tests or directories containing JTReg tests can also be
specified, like test/hotspot/jtreg/native_sanity/JniVersion.java orhotspot/jtreg/native_sanity. Just like for test root selection, you can
either specify an absolute path (which can even point to JTReg tests outside
the source tree), or a path relative to either the JDK top directory or thetest directory. hotspot can be used as an alias for hotspot/jtreg here as
well.
As long as the test groups or test paths can be uniquely resolved, you do not
need to enter the jtreg: prefix. If this is not possible, or if you want to
use a fully qualified test descriptor, add jtreg:, e.g.jtreg:test/hotspot/jtreg/native_sanity.
Gtest
Note: To be able to run the Gtest suite, you need to configure your build
to be able to find a proper version of the gtest source. For details, see the
section "Running Tests" in the build
documentation (html, markdown).
Since the Hotspot Gtest suite is so quick, the default is to run all tests.
This is specified by just gtest, or as a fully qualified test descriptorgtest:all.
If you want, you can single out an individual test or a group of tests, for
instance gtest:LogDecorations or gtest:LogDecorations.level_test_vm. This
can be particularly useful if you want to run a shaky test repeatedly.
For Gtest, there is a separate test suite for each JVM variant. The JVM variant
is defined by adding /<variant> to the test descriptor, e.g.gtest:Log/client. If you specify no variant, gtest will run once for each JVM
variant present (e.g. server, client). So if you only have the server JVM
present, then gtest:all will be equivalent to gtest:all/server.
Microbenchmarks
Which microbenchmarks to run is selected using a regular expression following
the micro: test descriptor, e.g., micro:java.lang.reflect. This delegates
the test selection to JMH, meaning package name, class name and even benchmark
method names can be used to select tests.
Using special characters like | in the regular expression is possible, but
needs to be escaped multiple times: micro:ArrayCopy\\\\\|reflect.
Special tests
A handful of odd tests that are not covered by any other testing framework are
accessible using the special: test descriptor. Currently, this includesfailure-handler and make.
Failure handler testing is run using
special:failure-handleror justfailure-handleras test descriptor.Tests for the build system, including both makefiles and related
functionality, is run usingspecial:makeor justmakeas test
descriptor. This is equivalent tospecial:make:all.A specific make test can be run by supplying it as argument, e.g.
special:make:idea. As a special syntax, this can also be expressed asmake-idea, which allows for command lines asmake test-make-idea.
Test results and summary
At the end of the test run, a summary of all tests run will be presented. This
will have a consistent look, regardless of what test suites were used. This is
a sample summary:
==============================
Test summary
==============================
TEST TOTAL PASS FAIL ERROR
>> jtreg:jdk/test:tier1 1867 1865 2 0 <<
jtreg:langtools/test:tier1 4711 4711 0 0
jtreg:nashorn/test:tier1 133 133 0 0
==============================
TEST FAILURETests where the number of TOTAL tests does not equal the number of PASSed tests
will be considered a test failure. These are marked with the >> ... << marker
for easy identification.
The classification of non-passed tests differs a bit between test suites. In
the summary, ERROR is used as a catch-all for tests that neither passed nor are
classified as failed by the framework. This might indicate test framework
error, timeout or other problems.
In case of test failures, make test will exit with a non-zero exit value.
All tests have their result stored in build/$BUILD/test-results/$TEST_ID,
where TEST_ID is a path-safe conversion from the fully qualified test
descriptor, e.g. for jtreg:jdk/test:tier1 the TEST_ID isjtreg_jdk_test_tier1. This path is also printed in the log at the end of the
test run.
Additional work data is stored in build/$BUILD/test-support/$TEST_ID. For
some frameworks, this directory might contain information that is useful in
determining the cause of a failed test.
Test suite control
It is possible to control various aspects of the test suites using make control
variables.
These variables use a keyword=value approach to allow multiple values to be
set. So, for instance, JTREG="JOBS=1;TIMEOUT_FACTOR=8" will set the JTReg
concurrency level to 1 and the timeout factor to 8. This is equivalent to
setting JTREG_JOBS=1 JTREG_TIMEOUT_FACTOR=8, but using the keyword format
means that the JTREG variable is parsed and verified for correctness, soJTREG="TMIEOUT_FACTOR=8" would give an error, while JTREG_TMIEOUT_FACTOR=8
would just pass unnoticed.
To separate multiple keyword=value pairs, use ; (semicolon). Since the shell
normally eats ;, the recommended usage is to write the assignment inside
quotes, e.g. JTREG="...;...". This will also make sure spaces are preserved,
as in JTREG="JAVA_OPTIONS=-XshowSettings -Xlog:gc+ref=debug".
(Other ways are possible, e.g. using backslash:JTREG=JOBS=1\;TIMEOUT_FACTOR=8. Also, as a special technique, the string%20 will be replaced with space for certain options, e.g.JTREG=JAVA_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug. This can be useful if
you have layers of scripts and have trouble getting proper quoting of command
line arguments through.)
As far as possible, the names of the keywords have been standardized between
test suites.
General keywords (TEST_OPTS)
Some keywords are valid across different test suites. If you want to run tests
from multiple test suites, or just don't want to care which test suite specific
control variable to use, then you can use the general TEST_OPTS control
variable.
There are also some keywords that applies globally to the test runner system,
not to any specific test suites. These are also available as TEST_OPTS
keywords.
JOBS
Currently only applies to JTReg.
TIMEOUT_FACTOR
Currently only applies to JTReg -timeoutFactor.
JAVA_OPTIONS
Applies to JTReg, GTest and Micro.
VM_OPTIONS
Applies to JTReg, GTest and Micro.
JCOV
This keyword applies globally to the test runner system. If set to true, it
enables JCov coverage reporting for all tests run. To be useful, the JDK under
test must be run with a JDK built with JCov instrumentation (configure --with-jcov=, make jcov-image).
The simplest way to run tests with JCov coverage report is to use the special
target jcov-test instead of test, e.g. make jcov-test TEST=jdk_lang. This
will make sure the JCov image is built, and that JCov reporting is enabled.
To include JCov coverage for just a subset of all modules, you can use the--with-jcov-modules arguments to configure, e.g.--with-jcov-modules=jdk.compiler,java.desktop.
For more fine-grained control, you can pass arbitrary filters to JCov using--with-jcov-filters, and you can specify a specific JDK to instrument
using --with-jcov-input-jdk.
The resulting coverage is written intobuild/$BUILD/test-results/jcov-output/result.xml.
The JCov report is stored in build/$BUILD/test-results/jcov-output/report.
Please note that running with JCov reporting can be very memory intensive.
JCov scales
JCov scales make it possible to record which tests cover each part of the
instrumented code. To collect coverage with scales, set JCOV_SCALES=true,
for example:
$ make jcov-test TEST=jdk_lang TEST_OPTS="JCOV_SCALES=true"The resulting coverage data contains the association between covered code and
the tests that covered it. A corresponding testlist.txt file, which contains
the test names, is generated in the same directory.
The JCov report displays the names of the tests that cover each class.
Collecting coverage scales forces jtreg tests to be run in othervm mode,
which takes longer than ordinary JCov collection. The coverage data is also
larger because it includes scale information, and the generated report is
larger because it includes test names.
JCOV_DIFF_CHANGESET
While collecting code coverage with JCov, it is also possible to find coverage
for only recently changed code. JCOV_DIFF_CHANGESET specifies a source
revision. A textual report will be generated showing coverage of the diff
between the specified revision and the repository tip.
The report is stored inbuild/$BUILD/test-results/jcov-output/diff_coverage_report file.
AOT_JDK
See Testing Ahead-of-time optimizations.
JTReg keywords
JOBS
The test concurrency (-concurrency).
Defaults to TEST_JOBS (if set by --with-test-jobs=), otherwise it defaults to
JOBS, except for Hotspot, where the default is number of CPU cores/2, but
never more than memory size in GB/2.
TIMEOUT_FACTOR
The TIMEOUT_FACTOR is forwarded to JTReg framework itself
(-timeoutFactor). Also, some test cases that programmatically wait a
certain amount of time will apply this factor. If we run in forced
compilation mode (-Xcomp), the build system will automatically
adjust this factor to compensate for less performance. Defaults to 4.
FAILURE_HANDLER_TIMEOUT
Sets the argument -timeoutHandlerTimeout for JTReg. The default value is 0.
This is only valid if the failure handler is built.
TEST_THREAD_FACTORY
Sets the -testThreadFactory for JTReg. It should be the fully qualified
classname of a class which implements java.util.concurrent.ThreadFactory. One
such implementation class, named Virtual, is currently part of the JDK build in
the test/jtreg_test_thread_factory/ directory. This class gets compiled
during the test image build. The implementation of the Virtual class creates a
new virtual thread for executing each test class.
VALUE_CLASS_PLUGIN
Enables the ValueClassPlugin javac plugin when compiling and running JTReg
tests. This is a temporary mode intended for use while value classes
(JEP 401) are a preview feature. The long-term plan is to replace classes
annotated with @jdk.test.lib.valueclass.AsValueClass with plainvalue class declarations once value classes are finalized.
In the meantime, this mode allows test sources to compile and run as either
value classes or regular identity classes without source-level changes.
When set to any non-empty value, the following options are appended to every
JTReg invocation:
-cpa:<valueClassPlugin.jar>— appends the plugin JAR to the compile-time
classpath (only when the JAR is present in the test image underjtreg_value_class_plugin/valueClassPlugin.jar).-vmoption:--enable-preview— enables JVM preview features at runtime.-javacoption:-XDaccessInternalAPI— grants the compiler access to internal
APIs required by the plugin.-javacoption:--source <version> --enable-preview— enables preview language
features at compile time.-javacoption:-Xplugin:ValueClassPlugin— activates the plugin.
The plugin scans each compilation unit after parsing and converts any class
annotated with @jdk.test.lib.valueclass.AsValueClass into a value class by
setting the internal VALUE_CLASS modifier flag and clearing theIDENTITY_TYPE flag. This transformation only takes effect when--enable-preview is active; without it the annotation is a no-op and the
class compiles as an ordinary identity class, so the same test source can
exercise both code paths.
Example:
$ make test TEST=jdk_lang JTREG="VALUE_CLASS_PLUGIN=true"JVMTI_STRESS_AGENT
Executes JTReg tests with JVM TI stress agent. The stress agent is the part of
test library and located in test/lib/jdk/test/lib/jvmti/libJvmtiStressAgent.cpp.
The value of this argument is set as JVM TI agent options.
This mode uses ProblemList-jvmti-stress-agent.txt as an additional exclude list.
TEST_MODE
The test mode (agentvm or othervm).
Defaults to agentvm.
ASSERT
Enable asserts (-ea -esa, or none).
Set to true or false. If true, adds -ea -esa. Defaults to true, except
for hotspot.
VERBOSE
The verbosity level (-verbose).
Defaults to fail,error,summary.
RETAIN
What test data to retain (-retain).
Defaults to fail,error.
MAX_MEM
Limit memory consumption (-Xmx and -vmoption:-Xmx, or none).
Limit memory consumption for JTReg test framework and VM under test. Set to 0
to disable the limits.
Defaults to 512m, except for hotspot, where it defaults to 0 (no limit).
MAX_OUTPUT
Set the property javatest.maxOutputSize for the launcher, to change the
default JTReg log limit.
KEYWORDS
JTReg keywords sent to JTReg using -k. Please be careful in making sure that
spaces and special characters (like !) are properly quoted. To avoid some
issues, the special value %20 can be used instead of space.
EXTRA_PROBLEM_LISTS
Use additional problem lists file or files, in addition to the default
ProblemList.txt located at the JTReg test roots.
If multiple file names are specified, they should be separated by space (or, to
help avoid quoting issues, the special value %20).
The file names should be either absolute, or relative to the JTReg test root of
the tests to be run.
RUN_PROBLEM_LISTS
Use the problem lists to select tests instead of excluding them.
Set to true or false. If true, JTReg will use -match: option, otherwise-exclude: will be used. Default is false.
OPTIONS
Additional options to the JTReg test framework.
Use JTREG="OPTIONS=--help all" to see all available JTReg options.
JAVA_OPTIONS
Additional Java options for running test classes (sent to JTReg as-javaoption).
VM_OPTIONS
Additional Java options to be used when compiling and running classes (sent to
JTReg as -vmoption).
This option is only needed in special circumstances. To pass Java options to
your test classes, use JAVA_OPTIONS.
LAUNCHER_OPTIONS
Additional Java options that are sent to the java launcher that starts the
JTReg harness.
RETRY_COUNT
Retry failed tests up to a set number of times, until they pass. This allows to
pass the tests with intermittent failures. Defaults to 0.
REPEAT_COUNT
Repeat the tests up to a set number of times, stopping at first failure. This
helps to reproduce intermittent test failures. Defaults to 0.
REPORT
Use this report style when reporting test results (sent to JTReg as -report).
Defaults to files.
MANUAL
Set to true to execute manual tests only.
Gtest keywords
REPEAT
The number of times to repeat the tests (--gtest_repeat).
Default is 1. Set to -1 to repeat indefinitely. This can be especially useful
combined with OPTIONS=--gtest_break_on_failure to reproduce an intermittent
problem.
OPTIONS
Additional options to the Gtest test framework.
Use GTEST="OPTIONS=--help" to see all available Gtest options.
Microbenchmark keywords
FORK
Override the number of benchmark forks to spawn. Same as specifying -f <num>.
ITER
Number of measurement iterations per fork. Same as specifying -i <num>.
TIME
Amount of time to spend in each measurement iteration, in seconds. Same as
specifying -r <num>
WARMUP_ITER
Number of warmup iterations to run before the measurement phase in each fork.
Same as specifying -wi <num>.
WARMUP_TIME
Amount of time to spend in each warmup iteration. Same as specifying -w <num>.
RESULTS_FORMAT
Specify to have the test run save a log of the values. Accepts the same values
as -rff, i.e., text, csv, scsv, json, or latex.
TEST_JDK
The path to the JDK that will be used to run the benchmarks.
Defaults to build/<CONF-NAME>/jdk.
BENCHMARKS_JAR
The path to the JAR containing the benchmarks.
Defaults to test/micro/benchmarks.jar.
VM_OPTIONS
Additional VM arguments to provide to forked off VMs. Same as -jvmArgs <args>
OPTIONS
Additional arguments to send to JMH.
Notes for Specific Tests
Docker Tests
Docker tests with default parameters may fail on systems with glibc versions
not compatible with the one used in the default docker image (e.g., Oracle
Linux 7.6 for x86). For example, they pass on Ubuntu 16.04 but fail on Ubuntu
18.04 if run like this on x86:
$ make test TEST="jtreg:test/hotspot/jtreg/containers/docker"To run these tests correctly, additional parameters for the correct docker
image are required on Ubuntu 18.04 by using JAVA_OPTIONS.
$ make test TEST="jtreg:test/hotspot/jtreg/containers/docker" \
JTREG="JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu
-Djdk.test.docker.image.version=latest"Non-US locale
If your locale is non-US, some tests are likely to fail. To work around this
you can set the locale to US. On Unix platforms simply setting LANG="en_US"
in the environment before running tests should work. On Windows or macOS,
setting JTREG="VM_OPTIONS=-Duser.language=en -Duser.country=US" helps for
most, but not all test cases.
For example:
$ export LANG="en_US" && make test TEST=...
$ make test JTREG="VM_OPTIONS=-Duser.language=en -Duser.country=US" TEST=...PKCS11 Tests
It is highly recommended to use the latest NSS version when running PKCS11
tests. Improper NSS version may lead to unexpected failures which are hard to
diagnose. For example, sun/security/pkcs11/Secmod/AddTrustedCert.java may fail
on Ubuntu 18.04 with the default NSS version in the system. To run these tests
correctly, the system property jdk.test.lib.artifacts.<NAME> is required on
Ubuntu 18.04 to specify the alternative NSS lib directory. The <NAME>
component should be replaced with the name element of the appropriate@Artifact class. (See test/jdk/sun/security/pkcs11/PKCS11Test.java)
For example:
$ make test TEST="jtreg:sun/security/pkcs11/Secmod/AddTrustedCert.java" \
JTREG="JAVA_OPTIONS=-Djdk.test.lib.artifacts.nsslib-linux_aarch64=/path/to/NSS-libs"For more notes about the PKCS11 tests, please refer to
test/jdk/sun/security/pkcs11/README.
SCTP Tests
The SCTP tests require the SCTP runtime library, which is often not installed
by default in popular Linux distributions. Without this library, the SCTP tests
will be skipped. If you want to enable the SCTP tests, you should install the
SCTP library before running the tests.
For distributions using the .deb packaging format and the apt tool
(such as Debian, Ubuntu, etc.), try this:
sudo apt install libsctp1
sudo modprobe sctp
lsmod | grep sctpFor distributions using the .rpm packaging format and the dnf tool
(such as Fedora, Red Hat, etc.), try this:
sudo dnf install -y lksctp-tools
sudo modprobe sctp
lsmod | grep sctpTesting Ahead-of-time Optimizations
One way to improve test coverage of ahead-of-time (AOT) optimizations in
the JDK is to run existing jtreg test cases in a special "AOT_JDK" mode.
Example:
$ make test JTREG="AOT_JDK=onestep" \
TEST=open/test/hotspot/jtreg/runtime/invokedynamicIn this testing mode, we first perform an AOT training run
(see https://openjdk.org/jeps/483) of a special test program
(test/setup_aot/TestSetupAOT.java)
that accesses about 5,0000 classes in the JDK core libraries.
Optimization artifacts for these classes (such as pre-linked
lambda expressions, execution profiles, and pre-generated native code)
are stored into an AOT cache file, which will be used by all the JVMs
launched by the selected jtreg test cases.
When the jtreg tests call into the core libraries classes that are in
the AOT cache, we will be able to test the AOT optimizations that were
used on those classes.
Please note that not all existing jtreg test cases can be executed with
the AOT_JDK mode. See
test/hotspot/jtreg/ProblemList-AotJdk.txt
and test/jdk/ProblemList-AotJdk.txt.
Also, test cases that were written specifically to test AOT, such as the tests
under test/hotspot/jtreg/runtime/cds,
cannot be executed with the AOT_JDK mode.
Valid values for AOT_JDK are onestep and twostep. These control how
the AOT cache is generated. See https://openjdk.org/jeps/514 for details.
All other values are ignored.
Testing with alternative security providers
Some security tests use a hardcoded provider for KeyFactory, Cipher,KeyPairGenerator, KeyGenerator, AlgorithmParameterGenerator,KeyAgreement, Mac, MessageDigest, SecureRandom, Signature,AlgorithmParameters, Configuration, Policy, or SecretKeyFactory objects.
Specify the -Dtest.provider.name=NAME property to use a different provider for
the service(s).
Client UI Tests
System key shortcuts
Some Client UI tests use key sequences which may be reserved by the operating
system. Usually that causes the test failure. So it is highly recommended to
disable system key shortcuts prior testing. The steps to access and disable
system key shortcuts for various platforms are provided below.
macOS
Choose Apple menu; System Preferences, click Keyboard, then click Shortcuts;
select or deselect desired shortcut.
For example,
test/jdk/javax/swing/TooltipManager/JMenuItemToolTipKeyBindingsTest/JMenuItemToolTipKeyBindingsTest.java
fails on macOS because it uses CTRL + F1 key sequence to show or hide tooltip
message but the key combination is reserved by the operating system. To run the
test correctly the default global key shortcut should be disabled using the
steps described above, and then deselect "Turn keyboard access on or off"
option which is responsible for CTRL + F1 combination.
Linux
Open the Activities overview and start typing Settings; Choose Settings, click
Devices, then click Keyboard; set or override desired shortcut.
Windows
Type gpedit in the Search and then click Edit group policy; navigate to User
Configuration -> Administrative Templates -> Windows Components -> File
Explorer; in the right-side pane look for "Turn off Windows key hotkeys" and
double click on it; enable or disable hotkeys.
Note: restart is required to make the settings take effect.
Robot API
Most automated Client UI tests use Robot API to control the UI. Usually, the
default operating system settings need to be adjusted for Robot to work
correctly. The detailed steps how to access and update these settings for
different platforms are provided below.
macOS
Robot is not permitted to control your Mac by default since macOS 10.15. To
allow it, choose Apple menu -> System Settings, click Privacy & Security; then
click Accessibility and ensure the following apps are allowed to control your
computer: Java and Terminal. If the tests are run from an IDE, the IDE
should be granted this permission too.
Windows
On Windows if Cygwin terminal is used to run the tests, there is a delay in
focus transfer. Usually it causes automated UI test failure. To disable the
delay, type regedit in the Search and then select Registry Editor; navigate
to the following key: HKEY_CURRENT_USER\Control Panel\Desktop; make sure theForegroundLockTimeout value is set to 0.
Additional information about Client UI tests configuration for various
operating systems can be obtained at Automated client GUI testing system set
up
requirements
Editing this document
If you want to contribute changes to this document, edit doc/testing.md and
then run make update-build-docs to generate the same changes indoc/testing.html.
Override some definitions in the global css file that are not optimal for
this document.
header-includes:
- ''
Doc Value Class Preview (`doc/value-class-preview.md`)
% Migration of JDK Classes to Value Classes
Introduction
The Value Objects feature introduces value objects and migrates suitable classes
to value classes. This means that when preview features are enabled, different
class files are used for the migrated classes in the Java class library.
To accomplish this, a built JDK uses preview-specific files in META-INF/preview,
which overrides the regular files of the same name. For example,META-INF/preview/java/lang/Integer.class overrides java/lang/Integer.class.
The JDK generates preview-specific source files (they may use preview language
features), compiles class files from them, and distributes these class files inMETA-INF/preview.
The Build Process
The Custom Handling for the Value Objects JEP
The Value Objects JEP requires a few select classes in the java.base module
to become value classes when preview features are enabled.
The build of java.base module first creates the source code of those value
classes, done inGensrcValueClasses.gmk.
A hardcoded list of regular source files are selected for preview-specific
generation.Extract the content of each regular source file, search for any occurrences
of/*value*/ classor/*value*/ record, and replace withvalue class
orvalue record.The replaced contents are written to the preview-specific generated files,
located insupport/gensrc-valueclasses/java.base/. The regular source
files remain unchanged in their original locations.The general preview source to binary build pipeline recognizes the
support/gensrc-valueclasses/java.base/directory as where thejava.base
module places its preview-specific source files.
The General Preview Source to Binary Pipeline
Once the preview-specific source files are ready, they are picked up by the
build system into a fully automated pipeline handling all modules and all
outcome images.
The
GENERATED_PREVIEW_SUBDIRSvariable inmake/common/Modules.gmk
indicates where the source files are found.For each module that has preview-specific source files, a goal is created
to compile these source files into class files.The class files from each of these tasks reside in
support/preview/<module>
for each module.These preview-specific class files and other resources are copied to the
META-INF/previewdirectory of the regular output directory.At run-time, jimage will pick up the preview-specific overrides from
META-INF/previewonly when preview features are enabled.The interim javac used by the build system cannot pick up the
preview-specific overrides; they must be supplied explicitly with the
following javac flag for every single module where overrides are significant:text--patch-module <module>=$(SUPPORT_OUTPUTDIR)/preview/<module>See
BuildMicroBenchmarks.gmkfor an example.
Non-Goals
The Value Objects JEP only plans to introduce value classes that are:
In the
java.basemodule.There's no plan to migrate other classes in other modules.
Migrated from existing classes.
These classes are available as identity classes when preview features are
disabled. There's no plan to introduce completely new value classes.
Support for other value classes would require significant changes to the build
system.
Testing
In addition to tests that require preview features to be enabled, tests that do
not depend on preview features wish to run with preview features enabled to
ensure compatibility:
Some tests wish to run against the Java SE class library with value classes.
The jtreg tests may be run with
JTREG=VM_OPTIONS=--enable-preview.Some tests wish to run against their own classes migrated to value classes.
The jtreg VALUE_CLASS_PLUGIN allows tests
to migrate their own classes to value classes when running with the plugin.
Wrapper Class Caches
Currently, wrapper class caches are retained even when preview features are
enabled to address performance losses. They have no semantic impact to value
objects.
In interpreter or C1 execution in Hotspot, allocations of a value object to the
heap as a full object with header happen when a value object is:
- Loaded from a flat storage (field or array)
- Created by a constructor
- If C2 uses scalarized calling convention, at C2 to C1/interpreter calls and returns
Ideally, C2 can eliminate such allocations, but this does not work if the
resulting object is stored into references. Unfortunately, many uses of boxing
conversions store the resulting wrapper objects as references.
For the uses that store wrapper objects to references, if the boxing
conversion is:
- Returning a value object from a flat cache array
- Calling the value class constructor
Then we would have heap allocation on every single use.
To avoid the allocations, we fall back to returning a value object from a
reference cache array, from which the loaded reference is directly storable
into a destination that wants a reference without any allocation.
Since Hotspot may create flat arrays if an array of value objects is requested
by regular Java array creation mechanisms, we use ValueClass.newReferenceArray
to ensure we always create a reference cache array.
The cache array for value objects may be removed without notice if the
performance losses from allocations are no longer significant.
Editing This Document
If you want to contribute changes to this document, edit doc/value-class-preview.md
and then run make update-build-docs to generate the same changes indoc/value-class-preview.html.
Override styles from the base CSS file that are not ideal for this document.
header-includes:
- ''
Test Docs ProblemList (`test/docs/ProblemList.txt`)
###########################################################################
Copyright (c) 2024, 2026, 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
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
or visit www.oracle.com if you need additional information or have any
questions.
###########################################################################
#############################################################################
List of quarantined tests -- tests that should not be run by default, because
they may fail due to known reason. The reason (CR#) must be mandatory specified.
List items are testnames followed by labels, all MUST BE commented
as to why they are here and use a label:
generic-all Problems on all platforms
generic-ARCH Where ARCH is one of: x64, i586, ppc64, ppc64le, s390x etc.
OSNAME-all Where OSNAME is one of: linux, windows, macosx, aix
OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. macosx-x64
OSNAME-REV Specific on to one OSNAME and REV, e.g. macosx-10.7.4
More than one label is allowed but must be on the same line.
#############################################################################
#############################################################################
Preview project specific failures go here at the end of the file.
These are NOT failures that occur with the '--enable-preview' option
specified in the task definition; those go in the appropriate
ProblemList-enable-preview.txt file.
These are failures that occur WITHOUT the '--enable-preview' option
specified in the task definition OR the '--enable-preview' option
MAY BE specified in the test itself. In either case, the failure
occurs because of some issue with preview project code, in either
implementation or test code.
#############################################################################
Test Docs Jdk Javadoc Doccheck ExtLinksJdk (`test/docs/jdk/javadoc/doccheck/ExtLinksJdk.txt`)
This file is used to check external links in the JDK generated documentation
to prevent broken links from backsliding into the JDK source.
The file serves as a "whitelist" of links that have been checked to be working as intended
and JDK developers should add external links to this file whenever they add them to their documentation.
The links in this file are checked before every release.
http://cldr.unicode.org/
http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf
http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf
http://docs.oracle.com/javase/feedback.html
http://docs.oracle.com/javase/jndi/tutorial/index.html
http://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-12.html
http://docs.oracle.com/javase/tutorial/collections/index.html
http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html
http://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html
http://docs.oracle.com/javase/tutorial/jdbc/
http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html
http://docs.oracle.com/javase/tutorial/jdbc/basics/rowset.html
http://docs.oracle.com/javase/tutorial/uiswing/dnd/index.html
http://en.wikipedia.org/wiki/Skip_list
http://jclark.com/xml/xmlns.htm
http://jcp.org/en/jsr/detail?id=173
http://jcp.org/en/jsr/detail?id=268
http://relaxng.org/spec-20011203.html
http://sax.sourceforge.net/?selected=get-set
http://standards.iso.org/iso/9075/2002/12/sqlxml.xsd
http://svn.python.org/projects/python/trunk/Objects/listsort.txt
http://tools.ietf.org/html/rfc1421
http://tools.ietf.org/html/rfc5869
http://unicode.org/reports/tr35/
http://unicode.org/reports/tr35/tr35-numbers.html
http://web.archive.org/web/20051219043731/http://archive.ncsa.uiuc.edu/SDG/Software/Mosaic/Demo/url-primer.html
http://www.cl.cam.ac.uk/~mgk25/time/utc-sls/
http://www.cs.rochester.edu/~scott/papers/1996_PODC_queues.pdf
http://www.iana.org/
http://www.iana.org/assignments/character-sets
http://www.iana.org/assignments/character-sets/character-sets.xhtml
http://www.iana.org/assignments/media-types/
http://www.iana.org/assignments/uri-schemes.html
http://www.ietf.org/
https://www.ietf.org/rfc/rfc793.txt
https://www.ietf.org/rfc/rfc822.txt
http://www.ietf.org/rfc/rfc1122.txt
http://www.ietf.org/rfc/rfc1123.txt
http://www.ietf.org/rfc/rfc1323.txt
http://www.ietf.org/rfc/rfc1349.txt
http://www.ietf.org/rfc/rfc1521.txt
http://www.ietf.org/rfc/rfc1522.txt
http://www.ietf.org/rfc/rfc1918.txt
http://www.ietf.org/rfc/rfc1950.txt
http://www.ietf.org/rfc/rfc1950.txt.pdf
http://www.ietf.org/rfc/rfc1951.txt
http://www.ietf.org/rfc/rfc1951.txt.pdf
http://www.ietf.org/rfc/rfc1952.txt
http://www.ietf.org/rfc/rfc1952.txt.pdf
http://www.ietf.org/rfc/rfc1964.txt
http://www.ietf.org/rfc/rfc2045.txt
http://www.ietf.org/rfc/rfc2046.txt
http://www.ietf.org/rfc/rfc2078.txt
http://www.ietf.org/rfc/rfc2104.txt
http://www.ietf.org/rfc/rfc2109.txt
http://www.ietf.org/rfc/rfc2222.txt
http://www.ietf.org/rfc/rfc2236.txt
http://www.ietf.org/rfc/rfc2245.txt
http://www.ietf.org/rfc/rfc2246.txt
http://www.ietf.org/rfc/rfc2251.txt
http://www.ietf.org/rfc/rfc2253.txt
http://www.ietf.org/rfc/rfc2254.txt
http://www.ietf.org/rfc/rfc2255.txt
http://www.ietf.org/rfc/rfc2268.txt
http://www.ietf.org/rfc/rfc2278.txt
http://www.ietf.org/rfc/rfc2279.txt
http://www.ietf.org/rfc/rfc2296.txt
http://www.ietf.org/rfc/rfc2365.txt
http://www.ietf.org/rfc/rfc2373.txt
http://www.ietf.org/rfc/rfc2396.txt
http://www.ietf.org/rfc/rfc2440.txt
http://www.ietf.org/rfc/rfc2474.txt
http://www.ietf.org/rfc/rfc2609.txt
http://www.ietf.org/rfc/rfc2616.txt
https://www.ietf.org/rfc/rfc2696.txt
http://www.ietf.org/rfc/rfc2710.txt
http://www.ietf.org/rfc/rfc2732.txt
http://www.ietf.org/rfc/rfc2743.txt
http://www.ietf.org/rfc/rfc2781.txt
http://www.ietf.org/rfc/rfc2782.txt
http://www.ietf.org/rfc/rfc2830.txt
http://www.ietf.org/rfc/rfc2831.txt
http://www.ietf.org/rfc/rfc2853.txt
http://www.ietf.org/rfc/rfc2891.txt
http://www.ietf.org/rfc/rfc2898.txt
http://www.ietf.org/rfc/rfc2965.txt
http://www.ietf.org/rfc/rfc3023.txt
http://www.ietf.org/rfc/rfc3111.txt
http://www.ietf.org/rfc/rfc3275.txt
http://www.ietf.org/rfc/rfc3279.txt
http://www.ietf.org/rfc/rfc3296.txt
http://www.ietf.org/rfc/rfc3330.txt
http://www.ietf.org/rfc/rfc3376.txt
http://www.ietf.org/rfc/rfc3454.txt
http://www.ietf.org/rfc/rfc3490.txt
http://www.ietf.org/rfc/rfc3491.txt
http://www.ietf.org/rfc/rfc3492.txt
http://www.ietf.org/rfc/rfc3530.txt
http://www.ietf.org/rfc/rfc3720.txt
http://www.ietf.org/rfc/rfc3720.txt.pdf
http://www.ietf.org/rfc/rfc3758.txt
http://www.ietf.org/rfc/rfc3810.txt
http://www.ietf.org/rfc/rfc3986.txt
http://www.ietf.org/rfc/rfc4120.txt
http://www.ietf.org/rfc/rfc4122.txt
http://www.ietf.org/rfc/rfc4366.txt
http://www.ietf.org/rfc/rfc4512.txt
http://www.ietf.org/rfc/rfc4648.txt
http://www.ietf.org/rfc/rfc5116.txt
http://www.ietf.org/rfc/rfc5280.txt
http://www.ietf.org/rfc/rfc5890.txt
http://www.ietf.org/rfc/rfc6066.txt
http://www.ietf.org/rfc/rfc7301.txt
http://www.ietf.org/rfc/rfc790.txt
http://www.ietf.org/rfc/rfc793.txt
http://www.ietf.org/rfc/rfc822.txt
http://www.ietf.org/rfc/rfc919.txt
http://www.info-zip.org/doc/appnote-19970311-iz.zip
http://www.ioplex.com/utilities/keytab.txt
http://www.iso.org/iso/home/standards/currency_codes.htm
http://www.jcp.org
http://www.jcp.org/en/jsr/detail?id=203
http://www.jpeg.org
http://www.libpng.org/pub/png/spec/
http://www.microsoft.com/typography/otspec/
http://www.midi.org
http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss
http://www.opengroup.org
http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html
http://www.oracle.com/technetwork/java/architecture-142923.html
http://www.oracle.com/technetwork/java/javase/documentation/serialized-criteria-137781.html
http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html
http://www.oracle.com/technetwork/java/javase/javasecarootcertsprogram-1876540.html
http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html
http://www.oracle.com/technetwork/java/painting-140037.html
http://www.oracle.com/technetwork/java/persistence2-141443.html
http://www.oracle.com/technetwork/java/persistence3-139471.html
http://www.oracle.com/technetwork/java/persistence4-140124.html
http://www.oreilly.com/catalog/regex/
http://www.oreilly.com/catalog/regex3/
http://www.reactive-streams.org/
http://www.relaxng.org/
http://www.rfc-editor.org/rfc/bcp/bcp47.txt
http://www.saxproject.org
http://www.saxproject.org/
http://www.unicode.org
http://www.unicode.org/
http://www.unicode.org/glossary/
http://www.unicode.org/reports/tr15/
http://www.unicode.org/reports/tr18/
http://www.unicode.org/reports/tr24/
http://www.unicode.org/reports/tr27/
http://www.unicode.org/reports/tr36/
http://www.unicode.org/reports/tr44/
http://www.unicode.org/standard/standard.html
http://www.w3.org/2000/09/xmldsig
http://www.w3.org/2000/xmlns/
http://www.w3.org/2001/04/xmldsig-more
http://www.w3.org/2001/04/xmlenc
http://www.w3.org/2001/05/xmlschema-errata
http://www.w3.org/2001/10/xml-exc-c14n
http://www.w3.org/2002/06/xmldsig-filter2
http://www.w3.org/2007/05/xmldsig-more
http://www.w3.org/2009/xmldsig11
http://www.w3.org/2021/04/xmldsig-more
http://www.w3.org/Graphics/GIF/spec-gif89a.txt
http://www.w3.org/TR/1998/REC-CSS2-19980512
http://www.w3.org/TR/1999/REC-html401-19991224/
http://www.w3.org/TR/1999/REC-xml-names-19990114/
http://www.w3.org/TR/1999/REC-xpath-19991116
http://www.w3.org/TR/1999/REC-xslt-19991116
http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113
http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113
http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113
http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113
http://www.w3.org/TR/2000/REC-DOM-Level-2-Views-20001113
http://www.w3.org/TR/2001/REC-xml-c14n-20010315
http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/
http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107
http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109
http://www.w3.org/TR/2003/REC-SVG11-20030114/
http://www.w3.org/TR/2003/REC-xptr-framework-20030325/
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html
http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407
http://www.w3.org/TR/2004/REC-DOM-Level-3-Val-20040127/
http://www.w3.org/TR/2004/REC-xml-20040204
http://www.w3.org/TR/2004/REC-xml-infoset-20040204
http://www.w3.org/TR/2004/REC-xml-infoset-20040204/
http://www.w3.org/TR/2004/REC-xml-names11-20040204/
http://www.w3.org/TR/2004/REC-xml11-20040204/
http://www.w3.org/TR/DOM-Level-2
http://www.w3.org/TR/DOM-Level-2-Core/
http://www.w3.org/TR/DOM-Level-3-Core
http://www.w3.org/TR/DOM-Level-3-LS
http://www.w3.org/TR/ElementTraversal/
http://www.w3.org/TR/NOTE-datetime
http://www.w3.org/TR/REC-CSS1
http://www.w3.org/TR/REC-html32.html
http://www.w3.org/TR/REC-xml
http://www.w3.org/TR/REC-xml-names
http://www.w3.org/TR/REC-xml-names/
http://www.w3.org/TR/REC-xml/
http://www.w3.org/TR/html4/
http://www.w3.org/TR/html40/appendix/notes.html
http://www.w3.org/TR/xinclude/
http://www.w3.org/TR/xml-exc-c14n/
http://www.w3.org/TR/xml-names11/
http://www.w3.org/TR/xml-stylesheet/
http://www.w3.org/TR/xml11/
http://www.w3.org/TR/xmldsig-core/
http://www.w3.org/TR/xmldsig-filter2
http://www.w3.org/TR/xmldsig-filter2/
http://www.w3.org/TR/xmlschema-1
http://www.w3.org/TR/xmlschema-1/
http://www.w3.org/TR/xmlschema-2/
http://www.w3.org/TR/xpath
http://www.w3.org/TR/xpath-datamodel
http://www.w3.org/TR/xpath/
http://www.w3.org/TR/xslt
http://www.w3.org/XML/1998/namespace
http://www.w3.org/XML/Schema
http://www.w3.org/XML/xml-V10-2e-errata
http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html
http://www.w3.org/pub/WWW/Protocols/
http://xmlns.jcp.org/xml/ns//jdbc/webrowset.xsd
https://bugreport.java.com/bugreport/
https://bugs.openjdk.org/secure/attachment/75649/JVM_CodeHeap_StateAnalytics_V2.pdf
https://cldr.unicode.org/index/downloads
https://csrc.nist.gov/publications/PubsFIPS.html
https://csrc.nist.gov/publications/fips/archive/fips186-2/fips186-2.pdf
https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
https://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf
https://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
https://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
https://csrc.nist.gov/publications/fips/fips81/fips81.htm
https://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf
https://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf
https://csrc.nist.gov/pubs/fips/203/final
https://csrc.nist.gov/pubs/fips/204/final
https://datatracker.ietf.org/doc/html/rfc5646
https://datatracker.ietf.org/doc/html/rfc8017
https://developer.apple.com/documentation
https://docs.oracle.com/en/java/javase/11/tools/java.html
https://docs.oracle.com/en/java/javase/12/language/index.html
https://docs.oracle.com/en/java/javase/12/tools/java.html
https://docs.oracle.com/en/java/javase/12/vm/compiler-control1.html
https://docs.oracle.com/en/java/javase/13/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/14/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/15/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/16/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/18/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/19/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/20/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/21/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/22/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Double.html
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/math/BigDecimal.html
https://docs.oracle.com/en/java/javase/23/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/24/docs/specs/man/java.html
https://docs.oracle.com/en/java/javase/@@JAVASE_VERSION@@/docs/api/java.base/java/lang/String.html
https://docs.oracle.com/en/java/javase/@@JAVASE_VERSION@@/docs/specs/javadoc/javadoc-search-spec.html
https://docs.oracle.com/en/java/javase/@@JAVASE_VERSION@@/docs/specs/man/javadoc.html
https://docs.oracle.com/en/java/javase/index.html
https://docs.oracle.com/javase/10/tools/java.htm
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html
https://docs.oracle.com/javase/9/tools/java.htm
https://docs.oracle.com/javase/specs/
https://docs.oracle.com/javase/specs/jls/se10/html/index.html
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
https://docs.oracle.com/javase/specs/jls/se12/html/index.html
https://docs.oracle.com/javase/specs/jls/se13/html/index.html
https://docs.oracle.com/javase/specs/jls/se14/html/index.html
https://docs.oracle.com/javase/specs/jls/se15/html/index.html
https://docs.oracle.com/javase/specs/jls/se16/html/index.html
https://docs.oracle.com/javase/specs/jls/se17/html/index.html
https://docs.oracle.com/javase/specs/jls/se18/html/index.html
https://docs.oracle.com/javase/specs/jls/se19/html/index.html
https://docs.oracle.com/javase/specs/jls/se20/html/index.html
https://docs.oracle.com/javase/specs/jls/se21/html/index.html
https://docs.oracle.com/javase/specs/jls/se22/html/index.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-13.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-14.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-15.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-17.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-3.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-4.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-5.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-6.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-8.html
https://docs.oracle.com/javase/specs/jls/se22/html/jls-9.html
https://docs.oracle.com/javase/specs/jls/se23/html
https://docs.oracle.com/javase/specs/jls/se23/html/index.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-10.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-11.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-12.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-14.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-15.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-16.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-18.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-2.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-3.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-4.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-5.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-6.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-7.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-8.html
https://docs.oracle.com/javase/specs/jls/se23/html/jls-9.html
https://docs.oracle.com/javase/specs/jls/se24/html/index.html
https://docs.oracle.com/javase/specs/jls/se24/html/jls-9.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/index.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-10.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-11.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-12.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-13.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-14.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-15.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-17.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-18.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-3.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-4.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-5.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-6.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-7.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-8.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/html/jls-9.html
https://docs.oracle.com/javase/specs/jls/se@@JAVASE_VERSION@@/jls@@JAVASE_VERSION@@.pdf
https://docs.oracle.com/javase/specs/jls/se6/html/j3TOC.html
https://docs.oracle.com/javase/specs/jls/se7/html/index.html
https://docs.oracle.com/javase/specs/jls/se8/html/index.html
https://docs.oracle.com/javase/specs/jls/se9/html/index.html
https://docs.oracle.com/javase/specs/jvms/se10/html/index.html
https://docs.oracle.com/javase/specs/jvms/se11/html/index.html
https://docs.oracle.com/javase/specs/jvms/se12/html/index.html
https://docs.oracle.com/javase/specs/jvms/se13/html/index.html
https://docs.oracle.com/javase/specs/jvms/se14/html/index.html
https://docs.oracle.com/javase/specs/jvms/se15/html/index.html
https://docs.oracle.com/javase/specs/jvms/se16/html/index.html
https://docs.oracle.com/javase/specs/jvms/se17/html/index.html
https://docs.oracle.com/javase/specs/jvms/se18/html/index.html
https://docs.oracle.com/javase/specs/jvms/se19/html/index.html
https://docs.oracle.com/javase/specs/jvms/se20/html/index.html
https://docs.oracle.com/javase/specs/jvms/se21/html/index.html
https://docs.oracle.com/javase/specs/jvms/se22/html/index.html
https://docs.oracle.com/javase/specs/jvms/se23/html
https://docs.oracle.com/javase/specs/jvms/se23/html/index.html
https://docs.oracle.com/javase/specs/jvms/se23/html/jvms-5.html
https://docs.oracle.com/javase/specs/jvms/se24/html/index.html
https://docs.oracle.com/javase/specs/jvms/se24/html/jvms-4.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/html/index.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/html/jvms-1.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/html/jvms-2.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/html/jvms-3.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/html/jvms-4.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/html/jvms-5.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/html/jvms-6.html
https://docs.oracle.com/javase/specs/jvms/se@@JAVASE_VERSION@@/jvms@@JAVASE_VERSION@@.pdf
https://docs.oracle.com/javase/specs/jvms/se7/html/index.html
https://docs.oracle.com/javase/specs/jvms/se8/html/index.html
https://docs.oracle.com/javase/specs/jvms/se9/html/index.html
https://docs.oracle.com/javase/tutorial/
https://docs.oracle.com/javase/tutorial/2d/text/fonts.html
https://docs.oracle.com/javase/tutorial/extra/fullscreen/index.html
https://docs.oracle.com/javase/tutorial/index.html
https://docs.oracle.com/javase/tutorial/javabeans/
https://docs.oracle.com/javase/tutorial/javabeans/writing/properties.html
https://docs.oracle.com/javase/tutorial/sound/
https://docs.oracle.com/javase/tutorial/uiswing/
https://docs.oracle.com/javase/tutorial/uiswing/components/applet.html
https://docs.oracle.com/javase/tutorial/uiswing/components/border.html
https://docs.oracle.com/javase/tutorial/uiswing/components/button.html
https://docs.oracle.com/javase/tutorial/uiswing/components/colorchooser.html
https://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html
https://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html
https://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html
https://docs.oracle.com/javase/tutorial/uiswing/components/frame.html
https://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html
https://docs.oracle.com/javase/tutorial/uiswing/components/icon.html
https://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html
https://docs.oracle.com/javase/tutorial/uiswing/components/jcomponent.html
https://docs.oracle.com/javase/tutorial/uiswing/components/label.html
https://docs.oracle.com/javase/tutorial/uiswing/components/layeredpane.html
https://docs.oracle.com/javase/tutorial/uiswing/components/list.html
https://docs.oracle.com/javase/tutorial/uiswing/components/menu.html
https://docs.oracle.com/javase/tutorial/uiswing/components/panel.html
https://docs.oracle.com/javase/tutorial/uiswing/components/progress.html
https://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html
https://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html
https://docs.oracle.com/javase/tutorial/uiswing/components/slider.html
https://docs.oracle.com/javase/tutorial/uiswing/components/spinner.html
https://docs.oracle.com/javase/tutorial/uiswing/components/splitpane.html
https://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html
https://docs.oracle.com/javase/tutorial/uiswing/components/table.html
https://docs.oracle.com/javase/tutorial/uiswing/components/text.html
https://docs.oracle.com/javase/tutorial/uiswing/components/textfield.html
https://docs.oracle.com/javase/tutorial/uiswing/components/toolbar.html
https://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html
https://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html
https://docs.oracle.com/javase/tutorial/uiswing/components/tree.html
https://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html
https://docs.oracle.com/javase/tutorial/uiswing/dnd/index.html
https://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/componentlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/containerlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/focuslistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/index.html
https://docs.oracle.com/javase/tutorial/uiswing/events/internalframelistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/itemlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/mouselistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/mousemotionlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/treeexpansionlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/treemodellistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/treeselectionlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/treewillexpandlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/events/windowlistener.html
https://docs.oracle.com/javase/tutorial/uiswing/index.html
https://docs.oracle.com/javase/tutorial/uiswing/layout/box.html
https://docs.oracle.com/javase/tutorial/uiswing/layout/spring.html
https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
https://docs.oracle.com/javase/tutorial/uiswing/misc/action.html
https://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html
https://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html
https://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=GUID-FE2D2E28-C991-4EF9-9DBE-2A4982726313
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=homepage
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=i18n_overview
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=imf_overview
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=jndi_ldap_gl_prop
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=jndi_overview
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=logging_overview
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=monitoring_and_management_using_jmx_technology
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=rmi_guide
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=secure_coding_guidelines_javase
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_impl_provider
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_jca
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_jca_provider
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_jdk_providers
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_jgss_tutorial
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_overview
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_pki
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_sasl
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=security_guide_tools
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=serialization_filter_guide
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=serialver_tool_reference
https://docs.oracle.com/pls/topic/lookup?ctx=javase@@JAVASE_VERSION@@&id=using_jconsole
https://ftp.pwg.org/pub/pwg/candidates/cs-ippoutputbin10-20010207-5100.2.pdf
https://ftp.pwg.org/pub/pwg/standards/temp_archive/pwg5100.3.pdf
https://github.github.com/gfm/
https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles
https://html.spec.whatwg.org
https://html.spec.whatwg.org/multipage/
https://html.spec.whatwg.org/multipage/introduction.html
https://html.spec.whatwg.org/multipage/sections.html
https://html.spec.whatwg.org/multipage/semantics.html
https://jcp.org/aboutJava/communityprocess/maintenance/jsr924/index.html
https://jcp.org/aboutJava/communityprocess/maintenance/jsr924/index2.html
https://jcp.org/aboutJava/communityprocess/mrel/jsr160/index2.html
https://jcp.org/en/jsr/detail?id=14
https://jcp.org/en/jsr/detail?id=175
https://jcp.org/en/jsr/detail?id=201
https://jcp.org/en/jsr/detail?id=221
https://jcp.org/en/jsr/detail?id=269
https://jcp.org/en/jsr/detail?id=334
https://jcp.org/en/jsr/detail?id=335
https://jcp.org/en/jsr/detail?id=376
https://jcp.org/en/jsr/detail?id=41
https://jcp.org/en/procedures/jcp2
https://mermaid.js.org
https://msdn.microsoft.com/en-us/library/cc236621.aspx
https://msdn.microsoft.com/en-us/library/dd183391.aspx
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf
https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
https://openjdk.org/jeps/11
https://openjdk.org/jeps/12
https://openjdk.org/jeps/181
https://openjdk.org/jeps/213
https://openjdk.org/jeps/225
https://openjdk.org/jeps/261
https://openjdk.org/jeps/286
https://openjdk.org/jeps/306
https://openjdk.org/jeps/323
https://openjdk.org/jeps/361
https://openjdk.org/jeps/371
https://openjdk.org/jeps/378
https://openjdk.org/jeps/394
https://openjdk.org/jeps/395
https://openjdk.org/jeps/396
https://openjdk.org/jeps/403
https://openjdk.org/jeps/409
https://openjdk.org/jeps/421
https://openjdk.org/jeps/440
https://openjdk.org/jeps/441
https://openjdk.org/jeps/454
https://openjdk.org/jeps/456
https://openjdk.org/jeps/458
https://openjdk.org/jeps/467
https://openjdk.org/jeps/478
https://openjdk.org/jeps/487
https://openjdk.org/jeps/488
https://openjdk.org/jeps/492
https://openjdk.org/jeps/494
https://openjdk.org/jeps/495
https://openjdk.org/jeps/499
https://prismjs.com
https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_addr.html
https://relaxng.org/
https://reproducible-builds.org/
https://spec.commonmark.org/0.31.2
https://spec.commonmark.org/0.31.2/
https://standards.ieee.org/ieee/754/6210/
https://standards.iso.org/ittf/PubliclyAvailableStandards/c055982_ISO_IEC_19757-3_2016.zip
https://standards.iso.org/ittf/PubliclyAvailableStandards/index.html
https://support.pkware.com/pkzip/appnote
https://tools.ietf.org/html/rfc1319
https://tools.ietf.org/html/rfc1321
https://tools.ietf.org/html/rfc1779
https://tools.ietf.org/html/rfc2040
https://tools.ietf.org/html/rfc2104
https://tools.ietf.org/html/rfc2195
https://tools.ietf.org/html/rfc2222
https://tools.ietf.org/html/rfc2246
https://tools.ietf.org/html/rfc2253
https://tools.ietf.org/html/rfc2595
https://tools.ietf.org/html/rfc2616
https://tools.ietf.org/html/rfc2712
https://tools.ietf.org/html/rfc2818
https://tools.ietf.org/html/rfc2830
https://tools.ietf.org/html/rfc2831
https://tools.ietf.org/html/rfc3217
https://tools.ietf.org/html/rfc3278
https://tools.ietf.org/html/rfc3394
https://tools.ietf.org/html/rfc3986
https://tools.ietf.org/html/rfc4086
https://tools.ietf.org/html/rfc4121
https://tools.ietf.org/html/rfc4162
https://tools.ietf.org/html/rfc4178
https://tools.ietf.org/html/rfc4234
https://tools.ietf.org/html/rfc4279
https://tools.ietf.org/html/rfc4346
https://tools.ietf.org/html/rfc4347
https://tools.ietf.org/html/rfc4492
https://tools.ietf.org/html/rfc4512
https://tools.ietf.org/html/rfc4647
https://tools.ietf.org/html/rfc4785
https://tools.ietf.org/html/rfc4960
https://tools.ietf.org/html/rfc5054
https://tools.ietf.org/html/rfc5061
https://tools.ietf.org/html/rfc5084
https://tools.ietf.org/html/rfc5246
https://tools.ietf.org/html/rfc5280
https://tools.ietf.org/html/rfc5288
https://tools.ietf.org/html/rfc5289
https://tools.ietf.org/html/rfc5469
https://tools.ietf.org/html/rfc5487
https://tools.ietf.org/html/rfc5489
https://tools.ietf.org/html/rfc5639
https://tools.ietf.org/html/rfc5646
https://tools.ietf.org/html/rfc5649
https://tools.ietf.org/html/rfc5746
https://tools.ietf.org/html/rfc5932
https://tools.ietf.org/html/rfc6209
https://tools.ietf.org/html/rfc6347
https://tools.ietf.org/html/rfc6367
https://tools.ietf.org/html/rfc6454
https://tools.ietf.org/html/rfc6455
https://tools.ietf.org/html/rfc6655
https://tools.ietf.org/html/rfc6931
https://tools.ietf.org/html/rfc7230
https://tools.ietf.org/html/rfc7231
https://tools.ietf.org/html/rfc7251
https://tools.ietf.org/html/rfc7292
https://tools.ietf.org/html/rfc7507
https://tools.ietf.org/html/rfc7539
https://tools.ietf.org/html/rfc7540
https://tools.ietf.org/html/rfc7748
https://tools.ietf.org/html/rfc7905
https://tools.ietf.org/html/rfc7919
https://tools.ietf.org/html/rfc8017
https://tools.ietf.org/html/rfc8018
https://tools.ietf.org/html/rfc8032
https://tools.ietf.org/html/rfc8103
https://tools.ietf.org/html/rfc8353
https://tools.ietf.org/html/rfc8422
https://tools.ietf.org/html/rfc8446
https://tools.ietf.org/html/rfc8554
https://tools.ietf.org/id/draft-kaukonen-cipher-arcfour-03.txt
https://tools.ietf.org/rfc/rfc5280.txt
https://tools.ietf.org/rfc/rfc8017.txt
https://unicode.org/reports/tr31/
https://unicode.org/reports/tr35/
https://unicode.org/reports/tr35/tr35-dates.html
https://unicode.org/reports/tr35/tr35-numbers.html
https://unicode.org/reports/tr51/
https://web.mit.edu/kerberos/
https://webhome.phy.duke.edu/~rgb/General/dieharder.php
https://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf
https://www.color.org
https://www.color.org/ICC1V42.pdf
https://www.iana.org/assignments/kerberos-parameters/kerberos-parameters.xhtml
https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
https://www.iana.org/time-zones
https://www.ietf.org/rfc/rfc2616.txt
https://www.ietf.org/rfc/rfc2818.txt
https://www.ietf.org/rfc/rfc6931.txt
https://www.ietf.org/rfc/rfc6943.html
https://www.iso.org/home.html
https://www.iso.org/iso-4217-currency-codes.html
https://www.iso.org/iso-8601-date-and-time-format.html
https://www.iso.org/standard/18114.html
https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf
https://www.itu.int/rec/T-REC-X.509/en
https://www.netlib.org/fdlibm/
https://www.oasis-open.org
https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html
https://www.oracle.com/java/javase/terms/license/java@@JAVASE_VERSION@@speclicense.html
https://www.oracle.com/java/technologies/a-swing-architecture.html
https://www.oracle.com/java/technologies/javase/seccodeguide.html
https://www.oracle.com/java/technologies/javase/training-support.html
https://www.oracle.com/pls/topic/lookup?ctx=en/java/javase&id=security_guide_implement_provider_jca
https://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html
https://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-plat-419418.html
https://www.oracle.com/technetwork/java/redist-137594.html
https://www.oracle.com/technetwork/java/seccodeguide-139067.html
https://www.owasp.org
https://www.rfc-editor.org/info/rfc1122
https://www.rfc-editor.org/info/rfc1123
https://www.rfc-editor.org/info/rfc1323
https://www.rfc-editor.org/info/rfc1349
https://www.rfc-editor.org/info/rfc1738
https://www.rfc-editor.org/info/rfc1779
https://www.rfc-editor.org/info/rfc1918
https://www.rfc-editor.org/info/rfc1950
https://www.rfc-editor.org/info/rfc1951
https://www.rfc-editor.org/info/rfc1952
https://www.rfc-editor.org/info/rfc2040
https://www.rfc-editor.org/info/rfc2045
https://www.rfc-editor.org/info/rfc2046
https://www.rfc-editor.org/info/rfc2109
https://www.rfc-editor.org/info/rfc2236
https://www.rfc-editor.org/info/rfc2246
https://www.rfc-editor.org/info/rfc2253
https://www.rfc-editor.org/info/rfc2268
https://www.rfc-editor.org/info/rfc2278
https://www.rfc-editor.org/info/rfc2279
https://www.rfc-editor.org/info/rfc2296
https://www.rfc-editor.org/info/rfc2306
https://www.rfc-editor.org/info/rfc2365
https://www.rfc-editor.org/info/rfc2368
https://www.rfc-editor.org/info/rfc2373
https://www.rfc-editor.org/info/rfc2396
https://www.rfc-editor.org/info/rfc2474
https://www.rfc-editor.org/info/rfc2560
https://www.rfc-editor.org/info/rfc2616
https://www.rfc-editor.org/info/rfc2710
https://www.rfc-editor.org/info/rfc2732
https://www.rfc-editor.org/info/rfc2781
https://www.rfc-editor.org/info/rfc2898
https://www.rfc-editor.org/info/rfc2911
https://www.rfc-editor.org/info/rfc2965
https://www.rfc-editor.org/info/rfc3279
https://www.rfc-editor.org/info/rfc3330
https://www.rfc-editor.org/info/rfc3376
https://www.rfc-editor.org/info/rfc3454
https://www.rfc-editor.org/info/rfc3490
https://www.rfc-editor.org/info/rfc3491
https://www.rfc-editor.org/info/rfc3492
https://www.rfc-editor.org/info/rfc3530
https://www.rfc-editor.org/info/rfc3720
https://www.rfc-editor.org/info/rfc3810
https://www.rfc-editor.org/info/rfc3986
https://www.rfc-editor.org/info/rfc4007
https://www.rfc-editor.org/info/rfc4086
https://www.rfc-editor.org/info/rfc4122
https://www.rfc-editor.org/info/rfc4234
https://www.rfc-editor.org/info/rfc4366
https://www.rfc-editor.org/info/rfc4512
https://www.rfc-editor.org/info/rfc4647
https://www.rfc-editor.org/info/rfc4648
https://www.rfc-editor.org/info/rfc5116
https://www.rfc-editor.org/info/rfc5280
https://www.rfc-editor.org/info/rfc5646
https://www.rfc-editor.org/info/rfc5869
https://www.rfc-editor.org/info/rfc5890
https://www.rfc-editor.org/info/rfc6066
https://www.rfc-editor.org/info/rfc7301
https://www.rfc-editor.org/info/rfc7539
https://www.rfc-editor.org/info/rfc790
https://www.rfc-editor.org/info/rfc793
https://www.rfc-editor.org/info/rfc8017
https://www.rfc-editor.org/info/rfc8032
https://www.rfc-editor.org/info/rfc822
https://www.rfc-editor.org/info/rfc919
https://www.rfc-editor.org/info/rfc9231
https://www.rfc-editor.org/rfc/rfc2315.txt
https://www.rfc-editor.org/rfc/rfc5208.html
https://www.rfc-editor.org/rfc/rfc5280.html
https://www.rfc-editor.org/rfc/rfc5646
https://www.rfc-editor.org/rfc/rfc5646.html
https://www.rfc-editor.org/rfc/rfc5869
https://www.rfc-editor.org/rfc/rfc6943.html
https://www.rfc-editor.org/rfc/rfc8017
https://www.rfc-editor.org/rfc/rfc8017.html
https://www.rfc-editor.org/rfc/rfc9180
https://www.schneier.com/blowfish.html
https://www.secg.org/sec2-v2.pdf
https://www.unicode.org/reports/tr15
https://www.unicode.org/reports/tr15/
https://www.unicode.org/reports/tr18
https://www.unicode.org/reports/tr24
https://www.unicode.org/reports/tr27
https://www.unicode.org/reports/tr29/
https://www.unicode.org/reports/tr31
https://www.unicode.org/reports/tr35
https://www.unicode.org/reports/tr35/
https://www.unicode.org/reports/tr35/tr35-collation.html
https://www.unicode.org/reports/tr35/tr35-dates.html
https://www.unicode.org/reports/tr35/tr35-general.html
https://www.unicode.org/reports/tr35/tr35.html
https://www.unicode.org/reports/tr36
https://www.unicode.org/reports/tr44
https://www.unicode.org/reports/tr44/
https://www.usno.navy.mil/USNO
https://www.usno.navy.mil/USNO/time/master-clock/systems-of-time
https://www.w3.org
https://www.w3.org/Daemon/User/Config/Logging.html
https://www.w3.org/TR/1998/REC-html40-19980424/
https://www.w3.org/TR/1999/REC-xpath-19991116/
https://www.w3.org/TR/2001/REC-xml-c14n-20010315
https://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/
https://www.w3.org/TR/2002/REC-xmldsig-filter2-20021108/
https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html
https://www.w3.org/TR/CSS22
https://www.w3.org/TR/CSS22/syndata.html
https://www.w3.org/TR/DOM-Level-3-XPath/
https://www.w3.org/TR/NOTE-datetime
https://www.w3.org/TR/REC-CSS1
https://www.w3.org/TR/REC-html32.html
https://www.w3.org/TR/REC-xml-names/
https://www.w3.org/TR/html4
https://www.w3.org/TR/html52
https://www.w3.org/TR/html52/dom.html
https://www.w3.org/TR/html52/syntax.html
https://www.w3.org/TR/xml
https://www.w3.org/TR/xml-c14n11/
https://www.w3.org/TR/xml/
https://www.w3.org/TR/xmldsig-core/
https://www.w3.org/TR/xmlschema-2
https://www.w3.org/WAI/standards-guidelines/wcag/
https://www.w3.org/XML/Schema
https://www.w3.org/XML/xml-names-19990114-errata.html
https://www.wapforum.org/what/technical/SPEC-WAESpec-19990524.pdf
--- METRICS ---
- Files Extracted: 10
- Estimated Token Budget: ~75031 tokens
- Canonical Reference: https://codewiki.google/github.com/openjdk/jdk