Getting started with OpenJDK development
The aim of this tutorial is to help you setup your working environment for editing, building, and testing OpenJDK.
Setting up JTREG
In order to test your changes in OpenJDK you will also need
installed as the path to
jtreg needs to be provided to the
script we will set it up before OpenJDK itself.
git clone https://github.com/openjdk/jtreg.git
Enter the directory and build it:
cd jtreg bash make/build.sh --jdk path/to/existing/jdk
This will create the directory
build/images/jtregwhich is the
(Optional but recommended) Install the
jtregplugin for IntelliJ IDEA
The jtreg repo also contains a plugin for the IntelliJ IDE. This is a convenience plugin which adds jtreg capabilities to the IntelliJ IDE. With this plugin, OpenJDK developers can write, run, and debug jtreg tests without leaving their IDE environment. For more details, see the file plugins/idea/README.md in this repo.
Setting up OpenJDK
git clone https://github.com/openjdk/jdk.git
Enter the directory and run
cd jdk bash configure --with-boot-jdk=path/to/existing/jdk --with-jtreg=path/to/jtreg/build/images/jtreg
Make sure to consult
doc/building.mdfor more info and options.
Congratulations, you should now have your own build of OpenJDK under
build/linux-x86_64-server-release/images/jdk. Note, that path might be different depending on your system and configuration.
- Start hacking… and recompile with
Now that we are all set up and know how to build and hack OpenJDK we should also make sure we don't break things :)
make run-test TEST="hotspot/jtreg"
You can confine the range of the tests to the ones related to your changes by choosing specific sub-directories, e.g.:
make run-test TEST="hotspot/jtreg/compiler/jvmci"
You can also increase the verbosity of
jtreg by setting
JTREG environment variable, e.g.:
make run-test JTREG="VERBOSE=all" TEST="hotspot/jtreg/compiler/jvmci"
For the list of available options one may run:
jterg -help "Verbose Options"
which will output something like the following:
Verbose Options These options control the amount of output written to the console while running tests -v | --v:<value> | -verbose | --verbose:<value> Increase the amount of output written to the console. A value, or selected combinations of values separated by commas, may be given to select the type of output desired. default Three lines of output per test: start, end, status summary One line of output per test: status, test name all Selected contents of JTR file for all tests (includes stdout/stderr) pass Selected contents of JTR file for passed tests fail Selected contents of JTR file for failed tests error Selected contents of JTR file for errored tests nopass Suppress output for tests that passed time Elapsed time per action multirun Updates for each testsuite when tests from more than one are being executed. -v1 Short for -verbose:summary -va Short for -verbose:all -ve Short for -verbose:error -vf Short for -verbose:fail -vp Short for -verbose:pass -vt Short for -verbose:time
For the complete list of
jtreg options please refer to
For more info about testing OpenJDK please refer to doc/testing.md