The JRush web conference for Java engineers is coming soon! Register now and evolve your Java apps. Rush with us!

Liberica JDK offers native Java builds for Apple Silicon M1

Liberica JDK offers native Java builds for Apple Silicon M1


Published March 12, 2021


Starting with the January release, Liberica JDK now runs natively on Macs powered by the first processor of Apple’s design specifically for Macintosh computers, M1. This feature applies to both LTS’s (8, 11) and the current version. We are going to dive into this exciting topic and explore how support for Apple silicon is implemented in Liberica JDK.

Thinking different with Apple silicon

What do we understand by this concept? Well, it’s three things in one, each with its weight.

Primarily, it refers to Apple-designed chips and the company’s first ARM-based SoCs (systems on a chip) for Macs called M1. They are intended to replace the lineup of Core processors. Some people would mean specific devices with the said processor: Mac mini, as well as MacBook Pro 13 and MacBook Air, both Late 2020. The third possible denomination builds upon the latest operating system, macOS Big Sur. In this case, Apple silicon should be viewed as a hardware + software combination designed for ultimate speed and performance.

The overarching characteristic here is a transition to the arm64 architecture. This is right up BellSoft’s alley — we’ve been exploring this technology for many years (read more in my article for Java Magazine, Sep/Oct 2018). Its key difference between ARM and x86 CPUs is in their methods for building instruction set architectures (ISAs): CISC and RISC. While the first design, Complex Instruction Set Computing, focuses on complicated instructions to encode more than one operation, RISC (Reduced Instruction Set Computing) based one uses fixed-length instructions, each performing a single operation. Thus, ARM is optimal for mobile devices, and x86 is perfect for desktops. Or the things have been like this, for the longest time.

When arm64 moves to desktops, it shows significant advantages:

  • with ARM lower TDP (Thermal Design Power) per core, M1 is much more energy-efficient;
  • early benchmark tests already show how the new chips outclass Intel-made processors in previous Macs.

Here’s an illustration of why we need a native JVM for Apple silicon. We took several DaCapo benchmarks using default JVM parameters on two implementations: macOS-x86_64 on Rosetta 2 and macOS-aarch64. A few times difference in performance is the answer.

Apple Silicon DaCapo

Together with the new OS, Apple silicon is more powerful than ever. M1 plus Big Sur equals new graphical capabilities in visual design.

Liberica JDK on M1

Liberica JDK for M1 is a production-ready TCK-verified binary. Try BellSoft’s progressive Java runtime for modern deployments and fully experience its benefits for macOS users.

For the latest JDK release on macOS, BellSoft offers a choice between Liberica JDK for x86 and ARM. However, we recommend installing both runtimes on your M1 device in early 2021.

  1. Download the .zip package and unpack it. Change the name of the top-level directory to jdk-xx.xx.xx.jdk (e.g. jdk-11.0.10.jdk).
wget https://download.bell-sw.com/java/11.0.10+9/bellsoft-jdk11.0.10+9-macos-amd64.zip
unzip bellsoft-jdk11.0.10+9-macos-amd64.zip
  1. Download the second archive and unpack it without changes.
wget https://download.bell-sw.com/java/11.0.10+9/bellsoft-jdk11.0.10+9-macos-aarch64.zip
unzip bellsoft-jdk11.0.10+9-macos-aarch64.zip

DO NOT download and install DMG files if you want to run both x86 and ARM builds on one JDK version.

Alternatively, you may use DMG to install different versions of Liberica JDK (e.g. 15.0.2 for ARM + 11.0.10 for x86 ). Learn more about this process in the Install Guide.

Why is it important? Java™ is a cross-platform language, meaning that all Java applications should run on every system available. But large software often has native code compiled for a specific architecture, including x86_64, which had been the only option in desktop and laptop Macs.

Another reason is that many app developers have not yet moved their products to ARM. They will eventually; it’s just that too little time has passed since the announcement. Apple itself expects the transition to take about two years, during which it will still produce Intel-based machines. For the time being, older versions of software built for x86 can run under a special translation environment, Rosetta 2, bundled with Big Sur. This virtualization tool, in fact, makes both x86 and ARM builds of Liberica JDK work simultaneously.

Apple Silicon Infographic

Support for JVM features as part of the latest JDK release (8u282, 11.0.10, 15.0.2):

  • all necessary garbage collectors;
  • C1 and C2 just-in-time compilers required for normal operation.

Features specific to Liberica JDK

  • BellSoft provides a notarized runtime, which allows notarizing your Java or JavaFX applications. To learn more about how to use Liberica JDK with the Javapackager tool, follow our detailed notarization guide;
  • Serviceability Agent API in JDK 8 to monitor VM’s internal operations, a handy tool for advanced Java development;
  • Full Liberica JDK binaries include JavaFX for complex and appealing visual interfaces, complete with OpenJFX Graphics, Media (video and audio), Controls, and Webkit modules.

The following features are not yet supported:

  • Graal JIT Compiler;
  • Ahead-of-Time compilation, since it entirely depends on the previous feature;
  • Class Data Sharing, due to the security limitation imposed by Apple.

Prospects

We are working closely with other OpenJDK community members to find solutions to the issues mentioned above. One of BellSoft’s goals, for now, is to extend support for this platform to all the open source projects we are part of.

First, we’ve pointed out the changes needed to the WebKit port in OpenJFX for its operation on ARM-based devices. The second important endeavor was the launch of Liberica Native Image Kit in February 2021, made possible by our continuous participation in the Graal project. Whether or not AOT compilation gets native support in M1 chips particularly depends on this development.

Would you like to be among the first to get new features for Java on ARM? BellSoft is here to provide critical updates the day they roll out, respond to requests in 24 hours, and guide you in switching to Apple silicon. We understand how important it is for businesses to stay on top of their game. Fill out the form below and speak about High-Powered Support with one of our experts.

Conclusion

The ARM architecture has been a prominent trend during the past couple of years. We feel fortunate to have predicted its rise back in 2018. Thanks to that, BellSoft is now one of the few OpenJDK contributors who are actively involved in advancing Java on this platform. Apple M1 promises massive power shifts in the IT industry, and we’re looking to the future with interest and healthy optimism. While macOS app developers are slowly transitioning from x86, you may count on Liberica JDK to run seamlessly on every device and have your business covered.

Author image

Aleksei Voitylov

BellSoft CTO

 LinkedIn