JDK 25 introduces JEP 520, which enables precise method timing and tracing via the JDK Flight Recorder (JFR). This feature allows developers to identify the source of latency in specific methods without modifying source code or build processes.

The mechanism uses two event types: jdk.MethodTiming, which provides aggregate call counts and duration summaries, and jdk.MethodTrace, which records individual call durations, threads, and stack traces. JFR injects measurement code into bytecode during JVM runtime.

To use this feature, developers apply filters to the JVM startup command, specifying the class and method to monitor. For instance, using method-timing provides a summary, while method-trace captures detailed execution data for individual calls.

When analyzing performance, developers should compare traces before and after changes. JFR records include stack depth information, allowing users to trace a long-running call back to its origin, such as a specific read or refresh operation in a catalog service.

The tool is effective for identifying bottlenecks in high-load systems. If a method exceeds a defined threshold, the stack trace helps pinpoint the caller, enabling targeted optimization of the code path responsible for delays.