Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Micronaut 4.0.0 Brings Java Virtual Threads, GraalVM Support and Experimental HTTP/3 Features

Micronaut 4.0.0 Brings Java Virtual Threads, GraalVM Support and Experimental HTTP/3 Features

This item in japanese

The Micronaut Foundation has recently announced the general availability (GA) release of Micronaut Framework 4.0.0. This major release brings a plethora of updates and improvements to the popular JVM-based framework, enhancing its performance, modularity, and compatibility with other technologies.

One of the key updates in Micronaut Framework 4.0.0 is the upgrade of language baselines. The framework now supports Apache Groovy 4 and Kotlin 1.8, and sets the Java baseline to 17. This means that developers can leverage the latest features and improvements in these languages while building their Micronaut applications.

For developers using Kotlin, Micronaut Framework 4.0.0 introduces support for Kotlin Symbol Processing (KSP). KSP is a powerful tool that allows developers to create compiler plugins, providing faster performance, idiomatic processing of Kotlin programs, and read-only treatment of source code for clarity and safety. However, it's worth noting that KSP support is currently only available for Gradle.

The new version of Micronaut also brings improved support for GraalVM, a universal virtual machine that can run applications written in various languages. Micronaut Framework 4.0.0 supports the latest GraalVM release and has shifted to runtime initialization for GraalVM. This change ensures consistent behavior between Just-In-Time (JIT) and native applications, making it easier for developers to build high-performance, low-footprint applications.

Micronaut Framework 4.0.0 requires Gradle 8 for building Micronaut applications. Gradle is a powerful build tool that automates the building, testing, publishing, and deployment of software packages or other types of projects. By requiring Gradle 8, Micronaut ensures that developers can take advantage of the latest features and improvements in Gradle, such as the improved version catalog feature for dependency management.

Another significant addition in this release is the introduction of an expression language. This feature allows developers to put expressions in annotations, providing a powerful way to configure and customize the behavior of their applications. The Micronaut expression language is designed to be secure by default, with all expressions evaluated at compilation time, type-checked, and reflection-free.

For example, developers can use expressions with Micronaut's security annotations to implement complex security rules. Consider the following example of how to use an expression with the @Secured annotation:

@Secured("user.attributes.get('email') == 'sherlock@micronaut.example'")
public void someSecureMethod() {
    // ...

In this example, the someSecureMethod() method will only be accessible if the current user's email attribute is 'sherlock@micronaut.example'.

Java's Project Loom is an ongoing effort to add lightweight, efficient threads (known as "virtual threads") to the Java platform. Micronaut Framework 4.0.0 detects virtual thread support, available since Java 19, and uses it for the executor named "BLOCKING" if available. This means that Micronaut applications can automatically take advantage of virtual threads when running on a Java 19 or later runtime, leading to more efficient resource usage and potentially better performance.

Micronaut 4.0.0 also brings significant improvements to its HTTP layer. The HTTP layer has been rewritten to improve performance and reduce the presence of reactive stack frames if reactive programming is not used, such as with virtual threads. This can lead to more efficient handling of HTTP requests and responses and better overall performance of Micronaut applications.

In addition, Micronaut 4.0.0 includes experimental support for HTTP/3 and experimental support for io_uring via the Netty incubator project. HTTP/3 is the latest version of the HTTP protocol, offering improved performance, better handling of packet loss, and other benefits. io_uring is a new, high-performance I/O interface for Linux kernel system call. By providing experimental support for these technologies, Micronaut allows developers to experiment with them and potentially achieve better performance and efficiency in their applications.

The release also introduces annotation-based filters, a new implementation of the Micronaut HTTP client based on the Java HTTP client, and support for OpenAPI Spec code generation for both Gradle and Maven plugins. The transition to the jakarta namespace has been completed, replacing various javax packages with their Jakarta EE equivalents. Besides, several features have been split into separate modules for improved modularity.

Nonetheless, this release marks a significant milestone in the evolution of this popular JVM-based framework. With its numerous updates and improvements, it provides developers with a powerful, flexible, and efficient platform for building microservices and serverless applications.

For more details, developers can refer to the GitHub release notes and developers who are interested in upgrading can refer to the Upgrading to Micronaut Framework 4 guide.

About the Author

Rate this Article