The OpenJDK project is considering a significant addition with its proposal for Asynchronous Stack Trace VM API, aiming to introduce asynchronous stack trace support into Java. This enhancement would involve an AsyncGetStackTrace API to retrieve stack traces in real time, capturing both Java and native stack frames. The move is part of Java’s ongoing evolution to support better diagnostic tools for profiling and debugging, enabling more robust visibility across complex applications and hybrid Java-native codebases.
Key motivations for this API focus on enhancing support for performance profilers, which would leverage this tool to gather native stack frame data efficiently. Designed with asynchronous functionality, the API would also be suitable for non-standard usage scenarios, such as profiling from within signal handlers. While the API would require extensive testing to minimize potential crashes in the JVM, its integration into the OpenJDK library aims to ensure that memory and performance impacts remain negligible when the API is inactive.
As it stands, profiling tools often rely on AsyncGetCallTrace, an internal API that, while widely used, has limitations. This existing API is not exported in any header files and restricts visibility to Java method and bytecode data only. The proposed AsyncGetStackTrace API would surpass these limitations by providing information on the compilation level, inlined frames, and C/C++ frames, crucial for advanced profiling scenarios, especially those involving the Java Native Interface (JNI).
Should the AsyncGetStackTrace API be approved, it would reduce the challenges of building profiling tools that currently require complex workarounds to access additional diagnostic data from the HotSpot VM. In addition, it could bring substantial improvements for JVM tuning and hybrid applications, making it a highly anticipated tool among developers aiming for precise performance tuning and debugging capabilities across Java’s diverse runtime environments.