OpenJDK

Migrating from one software solution to another is a reality that all good software developers need to plan for. Having a plan helps to drive innovation at a continuous pace, whether you are developing software for in-house use or you are acquiring software from a vendor. In either case, never anticipating or planning for migration endangers the entire innovation value proposition. And in today's ever-changing world of software, everyone who wants to benefit from the success of the cloud has to ensure that cloud innovation is continuous. Therefore, maintaining a stack that is changing along with technological advancements is a necessity.

In this article, we will take a look at the impact of moving to OpenJDK and the results will aid in drawing further conclusions and in planning. It's quite common to be using a proprietary version of JDK, and this article addresses how to use Red Hat Application Migration Toolkit to analyze your codebase to understand the impact of migrating to OpenJDK.

What is Red Hat Application Migration Toolkit?

Red Hat Application Migration Toolkit is a customizable and extensible rules-based tool that looks for common resources and highlights technologies and known potential impact areas when migration is required. It can be used with tools like Maven, and it generates reports from its runs that you can view in a browser. It also has browser-based tooling for doing the same.

The goal is to provide a high-level view of the use of technologies like Java and how they can be migrated to the latest versions of OpenJDK or Red Hat JBoss Enterprise Application Platform or even from other containers. The goal is to give a general impact analysis that will aid in estimates, documentation, and migration. For more details on Red Hat Application Migration Toolkit, please visit the see the documentation.

Getting started with Red Hat Application Migration Toolkit

Red Hat Application Migration Toolkit has the following different interfaces. For the sake of simplicity, we will stick to the Maven example. In any case, the following links should help provide further information:

Let's get started. We will need to set up the prerequisites to run the Red Hat Application Migration Toolkit.

Installing OpenJDK

Red Hat Application Migration Toolkit has been tested on Linux, Windows, and macOS. Other operating systems with Java 8+ support should work equally well and Oracle JDK 8 will also work, assuming you have a running JDK setup.

If you are running Red Hat Enterprise Linux 7, rpms can be found in the rhel-7-server-rpms channel.

Run the following command to install OpenJDK:

$ sudo yum install java-1.8.0-openjdk-devel.x86_64

Detailed instructions on installing OpenJDK can also be found here.  (See this article if you need to enable sudo)

Installing Maven

Now we must also ensure that Maven is installed. First, download it here.

Once it is downloaded, follow the instructions below, which assume you are running it on Red Hat Enterprise Linux.

Extract the ZIP archive to the directory where you wish to install Maven.

Open your .bash_profile file in a terminal: vi ~/.bash_profile.

Add the M2_HOME environment variable to the file:

export M2_HOME=/path/to/your/maven (this is where you have extracted maven archive)

Now let's add the bin directory of Maven to our path so we can use it on our system:

export PATH=$M2_HOME/bin:$PATH

Make sure that JAVA_HOME is set to the location of your OpenJDK installation, for example:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk.x86_64

Make sure that $JAVA_HOME/bin is in your PATH environment variable.

Save the file and exit your text editor.

Open a new terminal and run the following command to verify that Maven is installed successfully on your machine:

$ mvn --version

If you have, for example, the epel-apache-maven repo, it also possible to install Maven via yum.

Now that there is a running Java and Maven installation, let's get right to using Red Hat Application Migration Toolkit.

If you have a current Java project that needs to be analyzed great; otherwise, the following example project can be downloaded here.

Running Red Hat Application Migration Toolkit

Let's run through the example project to familiarize ourselves with the setup.

To use Red Hat Application Migration Toolkit in a project, add the following plugin to the build section of the POM file. In the example project, this already exists.

<plugin>
<groupId>org.jboss.windup.plugin</groupId>
<artifactId>windup-maven-plugin</artifactId>
<version>4.2.0.Final</version>
<executions>
  <execution>
    <id>run-windup</id>
    <phase>package</phase>
    <goals>
      <goal>windup</goal>
    </goals>
  </execution>
</executions>
<configuration>
  <offlineMode>true</offlineMode>
  <windupVersion>4.2.0.Final</windupVersion>
</configuration>
</plugin>

This will allow Red Hat Application Migration Toolkit to run during the builds.

Via the terminal, navigate to the project directory and use the following command to execute the build on the terminal.

$ mvn clean install

Viewing the analysis report

The build could take some time depending on the source. It will ensure that Red Hat Application Migration Toolkit is downloaded and will execute the analysis ending with a nice report. Once the build is finished, the results can be accessed via the following directory in the project:

target/windup-report/index.html

Let's go through the results by opening the page in a browser:

Opening the results in a browser

In the browser, you can see areas of potential migration and also the application name. Click on “main,” which should navigate to the details page:

Details page

When migrating from Oracle JDK to OpenJDK there will be differences based on the version of JDK. In the report shown above, the incidents, that is, APIs that will not work with OpenJDK, are reported. In the above example, javafx from our application is reported, as are crypto and awt.

Let's take a more detailed look at what these incidents are by clicking the Issues tab.

Closer look at the incidences

The screenshot above shows clear explanations of incompatibilities when migrating from Oracle JDK to OpenJDK version 8. There are also details with links to the knowledge base as well as a description of what remedies can be made. These hints should give guidance and also help in estimating the efforts required to change the code on a class or per-line basis.

Taking it a bit further, as a project leader, you would also want to know the dependencies and how they map. Red Hat Application Migration Toolkit does that in detail for all the code it has analyzed. Following is another screenshot that illustrates this:

Dependencies and how they map

Conclusion

The example above showcases some of the affected areas during a migration and the usefulness of Red Hat Application Migration Toolkit for such project.

There are many more interesting features. To read further, visit the documentation page here.

If you would like to try the above example, it's also shared in the GitHub repo with the sample code and Maven POM file.

Additional Resources

Last updated: May 1, 2019