Building OpenJDK Java Releases on Oracle Solaris/SPARC
Starting with Java SE 8, Oracle created the concept of Long-Term-Support (LTS) releases, which are expected to be used and supported for an extended amount of time and for production purposes. Oracle Java SE 8 and Java SE 11 are LTS releases and are available and supported for Oracle Solaris – subject to licensing and support requirements detailed here https://blogs.oracle.com/solaris/update-on-oracle-java-on-oracle-solaris and here https://www.oracle.com/technetwork/java/java-se-support-roadmap.html. Oracle Java SE 9 and Java SE 10 were considered a cumulative set of implementation enhancements of Java SE 8. Once a new feature release is made available, any previous non‑LTS release are considered superseded. The LTS releases are designed to be in production environments while the non-LTS releases provide access to new features ahead of their appearance in a LTS release.
The vast majority of users rely on Java SE 8 and Java SE 11 for their production use. However, Oracle also makes available OpenJDK builds that allow users to test and deploy the latest Java innovations. If you find a need to run a development release of Java on Oracle Solaris, you can access the freely available OpenJDK Java releases http://openjdk.java.net/, under an open source license http://openjdk.java.net/legal/gplv2+ce.html. This article will describe how to build a Java 12 JDK from OpenJDK sources on a recent Oracle Solaris 11.4SRU6 installation on a Oracle SPARC T8-1 system.
Preparing the Operating System
The first step to prepare the OS installaton for development purposes would be to check if the right facet had been installed:
root@t8-1-001:~# pkg facet
FACET VALUE SRC
devel True local
...
Make sure that the “devel” facet is set to true (if it wasn’t packages like system/header would not install the full set of include files and thus one would not be able to compile). In case your operating system installation has it set to false, a simple pkg change-facet "facet.devel=True" will fix this, Oracle Solaris will install all the missing files, among others those you would miss in /usr/include.
The OpenJDK website maintains a list of suggested and sometimes tested build enviroments on https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms, for most Java versions Oracle Solaris Studio 12.4 has been used. We will also use version 12.4, although the latest version according to the list of build environments should work as well.
The build process also needs a few more development tools, namely the GNU binutils suite, the Oracle Solaris assembler, and mercurial to clone the development tree from OpenJDK:
root@t8-1-001:~# pkg install mercurial developer/assembler cc@12.4 c++@12.4 autoconf gnu-binutils
...
Building a JDK from OpenJDK sources also requires a so called “boot JDK” which usually is a JDK one version older than the JDK that is to be built. In our case we need a JDK11 which is available from Oracle’s Technology Network pages, https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html. It doesn’t need not be installed as root, in our example it was installed right into the home directory of a user “oracle” used to build the JDK12.
Now the system is ready to be used as a build environment for OpenJDK.
Building the JDK
An OpenJDK build is similar to many other open source builds, one first has to “configure” the enviroment, and then do the actual build. Note, it is important to use the GNU variant of make, gmake , the “normal” make is not able to process the Makefiles generated during the “configure” step.
But we haven’t downloaded the sources yet, these are provided as a mercurial repository. To download the source tree the repository has to be cloned:
oracle@t8-1-001:~$ hg clone http://hg.openjdk.java.net/jdk/jdk12 jdk12-build
This way the OpenJDK 12 build tree is cloned into the directory “jdk12-build”. This process takes a few minutes, depending on the speed of your network connection.
The configure step is straightforward and sets up the build directory for the actual build process:
oracle@t8-1-001:~/jdk12-build$ chmod +x configure
oracle@t8-1-001:~/jdk12-build$ ./configure --with-devkit=/opt/solarisstudio12.4/ --with-boot-jdk=/export/home/oracle/jdk-11.0.2/
If one now issues a gmake one would run into a compile error, src/hotspot/os/solaris/os_solaris.cpp references the undefined constant “EM_486”. Oracle Solaris 11.4 removed EM_486 from sys/elf.h , one of the ways to fix this is to delete the corresponding line in os_solaris.cpp .
Now the source tree is ready for building OpenJDK 12 on Oracle Solaris 11.4, gmake will build a Java 12 JDK.
the result will end up in the directory build/solaris-sparcv9-server-release/jdk/ inside the build directory jdk12-build.
Testing the JDK
Now that you have successfully built Java 12 you might want to test it. The resulting JDK12 did end up in build/solaris-sparcv9-server-release/jdk/ n your build directory, jdk12-build in our example. Simply execute
oracle@t8-1-001:~/jdk12-build$ ./build/solaris-sparcv9-server-release/jdk/bin/java -version
openjdk version "12-internal" 2019-03-19
OpenJDK Runtime Environment (build 12-internal+0-adhoc..jdk12-build)
OpenJDK 64-Bit Server VM (build 12-internal+0-adhoc..jdk12-build, mixed mode)
to check that your newly built java can do something. Another way would be to compile a “Hello World” Java program:
oracle@t8-1-001:~$ cat HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Compile and execute will not create big surprises:
oracle@t8-1-001:~$ ./jdk12-build/build/solaris-sparcv9-server-release/jdk/bin/javac HelloWorld.java
oracle@t8-1-001:~$ ./jdk12-build/build/solaris-sparcv9-server-release/jdk/bin/java HelloWorld
Hello, World