RFR: 8344165: Trace exceptions with a complete call-stack [v8]

Coleen Phillimore coleenp at openjdk.org
Fri Jun 20 13:35:29 UTC 2025


On Tue, 10 Jun 2025 18:34:00 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> This PR makes it easier to analyze exceptions without modifying the JVM or the app to print call stacks:
>> 
>> Excerpt from the test case ExceptionsTest.java. 
>> 
>> 
>> [0.038s][info][exceptions           ] Exception <a 'java/lang/RuntimeException'{0x0000000474019bd8}: Test exception 2 for logging>
>> [                                   ]  thrown in interpreter method <{method} {0x000074c408400810} 'baz2' '()V' in 'ExceptionsTest$InternalClass'>
>> [                                   ]  at bci 9 for thread 0x000074c46402c7b0 (main)
>> [0.038s][info][exceptions,stacktrace] 	at ExceptionsTest$InternalClass.baz2(ExceptionsTest.java:142)
>> [0.038s][info][exceptions,stacktrace] 	at ExceptionsTest$InternalClass.bar2(ExceptionsTest.java:135)
>> [0.038s][info][exceptions,stacktrace] 	at ExceptionsTest$InternalClass.foo2(ExceptionsTest.java:127)
>> [0.038s][info][exceptions,stacktrace] 	at ExceptionsTest$InternalClass.main(ExceptionsTest.java:110)
>> [0.038s][info][exceptions           ] Exception <a 'java/lang/RuntimeException'{0x0000000474019bd8}: Test exception 2 for logging>
>> [                                   ]  thrown in interpreter method <{method} {0x000074c408400748} 'bar2' '()V' in 'ExceptionsTest$InternalClass'>
>> [                                   ]  at bci 0 for thread 0x000074c46402c7b0 (main)
>> [0.038s][info][exceptions           ] Found matching handler for exception of type "java.lang.RuntimeException" in method "bar2" at BCI: 6
>> [0.038s][info][exceptions           ] Exception <a 'java/lang/RuntimeException'{0x0000000474019bd8}: Test exception 2 for logging>
>> [                                   ]  thrown in interpreter method <{method} {0x000074c408400748} 'bar2' '()V' in 'ExceptionsTest$InternalClass'>
>> [                                   ]  at bci 8 for thread 0x000074c46402c7b0 (main)
>> [0.038s][info][exceptions,stacktrace] 	at ExceptionsTest$InternalClass.bar2(ExceptionsTest.java:137)
>> [0.038s][info][exceptions,stacktrace] 	at ExceptionsTest$InternalClass.foo2(ExceptionsTest.java:127)
>> [0.038s][info][exceptions,stacktrace] 	at ExceptionsTest$InternalClass.main(ExceptionsTest.java:110)
>> [0.038s][info][exceptions           ] Exception <a 'java/lang/RuntimeException'{0x0000000474019bd8}: Test exception 2 for logging>
>> [                                   ]  thrown in interpreter method <{method} {0x000074c408400670} 'foo2' '()V' in 'ExceptionsTest$InternalClass'>
>> [                                   ]  at bci 0 for thread 0x000074c46402c7b0 (m...
>
> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
> 
>   @dholmes-ora comments -- removed printing of output.getStdout() from test

Changes requested by coleenp (Reviewer).

src/hotspot/share/utilities/exceptions.cpp line 619:

> 617: // We don't want to use an OopHandle, or else we may prevent this object from being collected.
> 618: // Whenever a GC happens, this will be cleared by Exceptions::clear_logging_cache().
> 619: static oop _last_logged_exception;

oh gosh I don't like this at all.  Save the exception string if anything.

-------------

PR Review: https://git.openjdk.org/jdk/pull/25522#pullrequestreview-2946209210
PR Review Comment: https://git.openjdk.org/jdk/pull/25522#discussion_r2159014991


More information about the hotspot-dev mailing list