News, tips, partners, and perspectives for the Oracle Solaris operating system

Building OpenJDK 12 using JDK 8

Guest Author

Guest Author: Petr Sumbera

As you may know, a new OpenJDK 12 was released which you might want to try on Oracle Solaris. There are already some great blog posts out by Martin Mueller and Andrew Watkins describing how to build recent OpenJDK versions from sources.

But there is an issue. To build OpenJDK you will always need previous version as a boot JDK. Basically to build OpenJDK 12 you will need OpenJDK 11 and so on. For SPARC it's rather easy as you can download Java SE Development Kit 11 for Oracle Solaris on SPARC. But not for Oracle Solaris on x64. So you will need to start with JDK 8 which is bundled with Oracle Solaris.

Following are copy paste instructions which should build all OpenJDK versions from 9 till latest 12. You just need to have Oracle Solaris 11.4 with installed system header files, Mercurial and JDK 8:

pkg install mercurial system/header jdk-8

You might also want to check whether you have the facet.devel set to True or False. When set to False there are no C header files on system. So the correct setting is True:

 pkg facet | grep ^devel && pkg change-facet facet.devel=True

Note that a setting of None should default to True, i.e. have the same effect as True

As compiler you will need Oracle Solaris Studio 12.4 (ideally latest update). Installation guide is here.

After successful build procedure you should find your fresh OpenJDK tar archives in openjdk*/build/solaris-*-server-release/bundles/ directory.

So now copy and paste the following:

cat > build.sh <<EOF 
set -xe

# Oracle Developer Studio 12.4 and JDK 8 are needed.

# OpenJDK 12 has some issues:
# - https://bugs.openjdk.java.net/browse/JDK-8211081
# - shenandoahgc doesn't build on Solaris i386 (and is not supported on sparc)
CONFIG_OPTS_JDK12="--with-jvm-features=-shenandoahgc --disable-warnings-as-errors"

# EM_486 is no longer defined since Solaris 11.4
function fixsrc1 {
  for f in hotspot/src/os/solaris/vm/\$FILE src/hotspot/os/solaris/\$FILE; do
    [ ! -f "\$f" ] || gsed -i 's/EM_486/EM_IAMCU/' "\$f"

# caddr32_t is already defined in Solaris 11
function fixsrc2 {
  for f in "\$FILE" "jdk/\$FILE"; do
    [ ! -f "\$f" ] || gsed -i '/typedef.*caddr32_t;/d' "\$f"

for VERSION in {9..12}; do
  hg clone http://hg.openjdk.java.net/jdk-updates/jdk\${VERSION}u openjdk\${VERSION}
  cd openjdk\${VERSION}/
  # OpenJDK 9 uses script to download nested repositories
  test -f get_source.sh && bash get_source.sh
  # There are needed some source changes to build OpenJDK on Solaris 11.4.
  fixsrc1 ; fixsrc2
  # Oracle Solaris Studio 12.4 may fail while building hotspot-gtest (_stdio_file.h issue)
  PATH="\$JDK:\$STUDIO:/usr/bin/" bash ./configure --disable-hotspot-gtest \${CONFIGURE_OPTIONS}
  gmake bundles 2>&1 | tee build.log
  RELEASE_DIR=\`grep "^Finished building target" build.log | cut -d \' -f 4\`
  cd ..
bash build.sh

This should correctly build all the versions of OpenJDK from 9 to 12.

Have fun.

Join the discussion

Comments ( 1 )
  • Steffen Moser Monday, May 20, 2019
    Great! Works perfectly well on Solaris 11.4 SRU 8. Thank you very much for this little piece of script code.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.