RFR: 8367597: Runtime.exit logging failed: Cannot invoke "java.lang.Module.getClassLoader()" because "m" is null

Alan Bateman alanb at openjdk.org
Sat Sep 13 07:28:11 UTC 2025


On Sat, 13 Sep 2025 07:10:42 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Can I please get a review of this change which addresses the issue noted in https://bugs.openjdk.org/browse/JDK-8367597? 
> 
> As noted in that issue, on certain occasions, during shutdown of the JVM, the logging in `Runtime.exit()` generates a `NullPointerException`. The issue is due to the JVM not being fully initialized when (concurrently) the signal handler thread calls the `Runtime.exit()` code which then attempts to log a message.
> 
> The commit in this PR skips the logging from `Runtime.exit()` if the JVM isn't fully initialized at that point in time. I've manually verified that this change indeed addresses the issue by running the same tests on the hosts where this was previously failing. No new regressions tests have been introduced given the nature of the issue.
> 
> tier1 testing with this change completed without any related issues and additional tier testing is currently in progress.

src/java.base/share/classes/java/lang/Shutdown.java line 177:

> 175:     private static void logRuntimeExit(int status) {
> 176:         try {
> 177:             if (!VM.isBooted()) {

Can you move it to the top of the method so that the isBooted check isn't in the try-catch block? isBooted shouldn't throw but if it did then we wouldn't want the logging exception handler running.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27270#discussion_r2345997129


More information about the core-libs-dev mailing list