How GraalVM 24 Enables Premain Support for Java Agents and Boosts Performance

Oracle’s March 2025 release of JDK 24 and GraalVM 24 introduces a new Class‑File API and Premain support for Java agents, allowing static compilation of agents, improving observability, reducing native image size, and delivering measurable startup‑time and memory‑usage gains.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How GraalVM 24 Enables Premain Support for Java Agents and Boosts Performance

On March 18 2025 Oracle announced the simultaneous release of JDK 24 and GraalVM 24, bringing a suite of new features. JDK 24 replaces the ASM interface with a new Class‑File API, simplifying bytecode manipulation for Java agents. GraalVM 24 adds the long‑awaited Premain support, enabling Java agents to be used in native images.

Java agents dynamically modify bytecode at runtime without changing the application source, and are widely used for observability. Traditional GraalVM native images lack two essential capabilities: the JVM premain mechanism, which calls an agent’s premain method before the main application starts, and runtime bytecode transformation, which is impossible once the code is compiled to native form.

Implementation approach :

Compile‑time premain registration : during GraalVM compilation the tool scans for user‑defined premain functions, adds them to the compilation queue, and registers them as a premain entry point in the generated native image.

Shift agent transformation to compile time : the application is executed once with the agent attached, the transformed classes are dumped to disk, and those classes are then included in the native image build, making the runtime transformation unnecessary.

The solution was contributed by Alibaba Cloud’s Program Language & Compiler team and Observability team, the sole Chinese representative on the GraalVM Global Advisory Board. The new capability has been integrated into Alibaba Cloud’s ARMS (Application Real‑Time Monitoring Service) platform, allowing GraalVM applications to be observed without invasive changes.

Performance testing on a 32 vCPU / 64 GiB / 5 Mbps environment shows that GraalVM native images with the ARMS Java agent consume significantly less memory and start faster than their non‑instrumented counterparts. The article includes metric screenshots demonstrating these improvements.

In summary, GraalVM 24’s Premain support resolves the two missing pieces for Java‑agent‑based observability, and ARMS already provides end‑to‑end monitoring for GraalVM applications. Readers interested in the feature can refer to the linked documentation and try the integration.

Relevant links:

GraalVM 24 release notes: https://www.graalvm.org/release-notes/JDK_24/

JDK 24 release notes: https://jdk.java.net/24/release-notes

Class‑File API (JEP 484): https://openjdk.org/jeps/484

ARMS GraalVM integration guide: https://help.aliyun.com/zh/arms/application-monitoring/use-cases/connect-graalvm-applications-to-arms

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaPerformanceGraalVMnative-imageJava AgentARMS
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.