Migrating to an OpenJDK with OpenJ9 is straightforward for most applications because they use the same stable and compatible APIs from the OpenJDK project, but with a superior execution engine. Both execution engines – the OpenJ9 VM and the HotSpot VM – implement the Java Virtual Machine Specification, which ensures that applications that run on HotSpot-based OpenJDK runtimes will also run on OpenJDK with OpenJ9.
However, because it is an independent implementation there are some slight differences to be aware of.
OpenJ9 implements its own command-line interface. Whilst many HotSpot options are recognized and accepted by OpenJ9 for compatibility, if you pass a lot of options on the command-line when you start your application, those that don’t apply to OpenJ9 get ignored. The VM won’t stop your application from starting, but you might need to do some fine tuning. You can get some help with that!
For a list of compatible options, see Switching to OpenJ9.
Garbage collection policies
Eclipse OpenJ9 has a set of GC policies designed around different types of applications and workloads. By default, OpenJ9 uses the Generational Concurrent (gencon) GC policy, which is best suited for transactional applications that have many short-lived objects. If your application currently uses the HotSpot ParallelGC policy, gencon is the natural replacement. If your application uses the HotSpot Garbage First (G1) policy, this is most similar to the OpenJ9 balanced GC policy.
If you have a different type of workload, you might want to select a different GC policy. For more information about the differences between OpenJ9 GC policies and how to choose the right one for your application, see Eclipse OpenJ9: Garbage collection tradeoffs and tuning with OpenJ9.
You might want to tune your Java resources once you’re up and running on an OpenJ9 GC policy. You can get some help with that!
There is one small use case that might require a code change. Does your application make use of the com.sun.management API? If so, you should note that some classes are specific to the HotSpot VM and any calls to these classes won’t work with OpenJ9. However, in some cases, OpenJ9 has its own MXBean extensions that perform similar operations.
- The com.sun.management interfaces that OpenJ9 does support include: GarbageCollectorMXBean, GarbageCollectionNotificationInfo, GcInfo, OperatingSystemMXBean, and UnixOperatingSystemMXBean.
- The com.sun.management interfaces that OpenJ9 doesn’t support are: HotSpotDiagnosticMXBean, MissionControl, MissionControlMXBean, ThreadMXBean, VMoption, and DiagnosticCommandMBean.
If your application calls an interface that OpenJ9 doesn’t support, you’ll need to switch to an alternative. You can get some help with that!
So, to get started with OpenJ9 simply:
- Check your Java command line
- Select your GC policy
- Check for any use of the com.sun.management interface
- Run your Java application!
In the vast majority of cases, getting your application up and running on OpenJDK with OpenJ9 should be straightforward, without changing your code.
Getting help and support
If you need some help to get started, why not join our slack workspace where you can chat directly with the OpenJ9 development community.
If you’re after commercial support for your OpenJDK with OpenJ9 runtime environment, including help to migrate, take a look at the IBM Runtimes for Business offering.
For more resources, see the OpenJ9 documentation.