GraalVM 21

GraalVM 21.0: Introducing a New Way to Run Java

GraalVM has released a higher version 21.0 with a new element, Java on Truffle. This release was in development for a short time, however, it has some newly added interesting features for the entire GraalVM ecosystem. Before this release, running Java applications in GraalVM was only possible by utilizing the Java HotSpot VM with the GraalVM. With this announcement, Java on Truffle, a JVM written in Java employs the Truffle framework, to implement an additional option to run Java applications.

GraalVM is a high-performance multilingual virtual machine that presents a shared runtime to execute applications written in various languages like Python, JavaScript, and Java. It is created to facilitate the execution and performance of applications written in Java and other JVM languages. The abilities of GraalVM’s polyglot make it possible to merge multiple programming languages in a single application while excluding any international language call costs.

GraalVM 21.0 is available for download right now: GraalVM and GraalVM Enterprise. Here we will talk about some of the most important changes in GraalVM 21.0. There are several components added to GraalVM and each release shows different enhancements.

Install GraalVM 

Installing GraalVM is a ready-to-go process and takes only a few minutes. You can choose your platform – Windows, Linux, or macOS, and proceed with the installation.

Platform Updates

GraalVM Community Edition in 21.0 is based on OpenJDK version 11.0.10 and OpenJDK version 1.8.0_282, including the GraalVM Enterprise on Oracle JDK version 11.0.10 and Oracle JDK version 1.8.0_281.

Java on Truffle

The most interesting expansion in GraalVM 21.0 is the addition of a new component that implements Java on Truffle. Java on Truffle is currently listed as experimental. However, this initial release gives several interesting capabilities and makes Java with additional JVM languages possible to run through the infrastructure that powers each other GraalVM language.

Native Image

The use of Java serialization is now possible in the native image binaries. Just like the other dynamic feature, serialization also needs to be configured, and you should know the classes that can be serialized or deserialized during the build time.

This configuration can be produced utilizing the supported configuration with a Java agent, so you don’t need to create it from scratch.

Consider an example below, if you have a class like this:

It serializes and deserializes, and prints the Fibonacci numbers. The Java agent helps you to compile and run it:


java -agentlib:native-image-agent=config-output-dir=config/META-INF/native-image Main

Now in the config directory, we can see the JSON file showing which classes will be included for serialisation:

cat config/META-INF/native-image/serialization-config.json 

[{ "name":"java.lang.Long" },   

 { "name":"java.lang.Number" },   

 { "name":"java.util.ArrayList" } 


All that is left to build the native image is just running the command: native-image -cp .:config Main. The list of the Fibonacci numbers will be serialized/deserialized when you run the result.

In addition to this extremely significant development that provides native image capabilities to more Java programs much easier than earlier, version 21.0 has also an improved method to manage invocation support.

With the configuration provided by the configuration agent, you can create native images of Swing applications and the AWT on Linux. Other platforms aren’t supported though, yet this is an excellent initial step.


Compatibility has been always a number one priority, and this release allows the following ECMAScript 2021 features by default: Promise.any, String.prototype.replaceAll, Class fields, and Logical Assignment Operators.


Graalwasm interpreter has been optimized in the 21.0 version which makes the warmup better and also increases the overall peak performance of interpreting WebAssembly to 20x faster.

List of outstanding features and benefits provided by Java on Truffle:

  • It runs a version of Java bytecode that is different from the host JVM.
  • Leverages the improved HotSwap abilities to change lambdas, methods, and access modifiers of classes at runtime during a debugging session.
  • Divide the host JVM and the Java application running on Truffle to sandbox and run less trusted guest code.
  • Enable Java applications to instantly interoperate with non-JVM languages like Python and JavaScript, and pass data backward and forward in the same memory space.
  • Leverage the standard tools provided by the Truffle framework.


This release of GraalVM also comes with some compatibility and runtime improvements across Java, Python, Ruby, and LLVM distributions. GraalVM’s implementation of the WebAssembly language i.e. GraalWasm has been further optimized to improve the overall peak performance of interpreting WebAssembly and the warmup time. The Java versions in this announcement of the GraalVM version are updated and based on OpenJDK version 11.0.10 and OpenJDK 1.8.0_282. GraalVM 21.0 comes with an enhanced gu tool that provides easy version updates.