For the most part, follow the instructions at https://github.com/openjdk/jdk/blob/jdk-21%2B35/doc/building.md#tldr-instructions-for-the-impatient.
- Clone the repository and get the tag you care about
-
git clone https://github.com/openjdk/jdk.git cd jdk git fetch origin tag jdk-21+35 git checkout jdk-21+35
- Note: this fetch fetched way more than I wanted. It was over 1GB, but whatever.
-
- Create your own branch so that you aren't in a detached state
-
git switch -c david-jdk-21
-
- Install Autoconf
-
brew install autoconf
-
- Install a "bootstrap JDK"
- I had a Temurin distribution of Java 21 installed via SDKMAN, and the Autoconf found it.
- Configure the system for building (like a pre-check)
-
bash configure
-
- (Optional) Clean up old builds
- If you had previously cloned the code and executed a build you will want to first clean the project. Execute the following command.
-
make clean
- Build
-
make images
- Note: you might have permissions problems.
- Wait for a few minutes (wow it was only 2-3 minutes on my M2 Pro, but I remember like an hour on my 2018 intel Macbook Air)
-
- Verify the built JDK
-
build/macosx-aarch64-server-release/images/jdk/bin/java --version
- SUCCESS
-
- (Optional) Link it with SDKMAN
- Link it as an SDKMAN candidate version with something like the following.
-
sdk install java 21_2024-03-20 /Users/dave/repos/opensource/jdk/build/macosx-aarch64-server-release/images/jdk