Java language architect Mark Reinhold proposed the creation of a new OpenJDK project named Leyden: for static binary applications with faster startup and lower memory. When approved and completed, this would allow developers to compile Java code (just-in-time) to get native applications (ahead-of-time), offering capabilities similar to GraalVM native mode.
The project benefits from conceptual support from Oracle via Mark Reinhold, as well as from RedHat. Following the project proposal, Andrew Haley, RedHat’s OpenJDK leader, said, “This is great news. It’s time to put the static AOT compilation in the fold. Let’s go!”. A similar sentiment came from Amazon, with Paul Hohensee saying “very happy to see this proposal”. RedHat is a member of the Java Community Process Executive Committee
and Amazon is an influential member of the community that runs a Java distribution, Amazon Corretto. Users of serverless frameworks like AWS Lambda and Azure Functions would benefit from Leyden, as operators pay per time used – fast startup and execution times could lower the cost of cold starts and lower per invocation charge to the threshold of minimum cost or lower them.
Leyden and GraalVM would work through a similar chain that developers follow to write and build apps:
- Developers write custom source code that connects and draws on the APIs of selected libraries, usually in JAR files.
- Custom code is compiled into bytecode which is packaged in one or more JAR files.
- Leyden would introduce a new split path for running apps:
- Applications could take the traditional course to run bytecode, optimizing application “hot spots” in native machine code while the application is running.
- A new opportunity to compile the application on operating system specific libraries to create a native application that runs on a single operating system similar to other native compilation tools.
The project would build on and enhance the capabilities present in Java today, used by developers to distribute applications.
- java packager is used to distribute applications with a built-in and customized JRE for a single application. End users do not need a Java installation on the system to run each application, as the application launch points pass through its supplied java executable.
- jaotc is an experimental compiler for some platforms that produce a native executable. Leyden can be grown directly on top of jaotc.
The advantages of applications compiled in native mode are already clearly visible in the RedHat Quarkus framework: Supersonic Subatomic Java. Quarks leverage the native image created via GraalVM to produce applications that are “supersonic” upon first request or boot as a serverless and “subatomic” function where the natively compiled application is smaller than Java bytecode original. Quarks’ home page lists these metrics in a readable graph on its home page with boxes for visual comparison:
- In JDK mode, a CRUD application used 145 MB of RAM.
- In native mode, a CRUD app uses 28MB of RAM, which is about 80% less.
- In JDK mode, the CRUD application took 2.033 seconds for the first HTTP response.
- In native mode, the CRUD app took 0.042 seconds, a decrease of about 98%.
No timeline exists for Leyden’s completion, allowing the project to focus on functionality rather than date. With Java’s six-month release cadence, review candidates will appear in a release to establish an effective feedback cycle.