RFR: 8344165: Trace exceptions with a complete call-stack [v7]
Ioi Lam
iklam at openjdk.org
Tue Jun 10 18:57:35 UTC 2025
On Tue, 10 Jun 2025 12:43:12 GMT, David Holmes <dholmes at openjdk.org> wrote:
> I'm not sure about the de-duplication checks. It isn't clear to me what code structures will cause you see to see a single stacktrace and which will cause you to see many stacktraces. For example, will a try/finally causes a repeated stacktrace? I think yes.
Yes, because a `finally` block looks like a `catch` block that has an `athrow` bytecode at the end. So with the latest version, the stack trace will be duplicated.
>From looking at javac output, it looks like `finally` blocks have this pattern:
try {
b();
} finally {
...
}
catch t0 #0; // <--- note that exception type is #0
stack_frame_type stack1;
stack_map class java/lang/Throwable;
.... body of finally ...
aload_0;
athrow; // <-- last bytecode is athrow
Whereas a `catch` block with an explicit `throw` statement at the end has a different pattern:
try {
b();
} catch (Throwable t) {
...
throw t;
}
catch t0 java/lang/Throwable;; // <--- note that exception type is NOT #0
stack_frame_type stack1;
stack_map class java/lang/Throwable;
.... body of catch ...
aload_0;
athrow;
So perhaps we can avoid printing stack traces if we can detect the `finally` blocks.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25522#issuecomment-2960295097
More information about the hotspot-dev
mailing list