From 0bc3705948b1bb8f327dc48c4dbd85d22d66f036 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Tue, 16 Sep 2025 13:16:48 +0000 Subject: [PATCH] 8367597: Runtime.exit logging failed: Cannot invoke "java.lang.Module.getClassLoader()" because "m" is null Reviewed-by: alanb, rriggs --- src/java.base/share/classes/java/lang/Shutdown.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Shutdown.java b/src/java.base/share/classes/java/lang/Shutdown.java index 36cf471a575..87c4732a5ce 100644 --- a/src/java.base/share/classes/java/lang/Shutdown.java +++ b/src/java.base/share/classes/java/lang/Shutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,8 +157,10 @@ class Shutdown { * which should pass a nonzero status code. */ static void exit(int status) { - logRuntimeExit(status); // Log without holding the lock; - + // log only if VM is fully initialized + if (VM.isBooted()) { + logRuntimeExit(status); // Log without holding the lock; + } synchronized (Shutdown.class) { /* Synchronize on the class object, causing any other thread * that attempts to initiate shutdown to stall indefinitely