Skip to content

Commit c35cd9d

Browse files
committed
[GR-64194] Invoke teardown hooks in Shutdown#exit substitution.
PullRequest: graal/20540
2 parents ad09f80 + 5e35a3f commit c35cd9d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Shutdown.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,29 @@ static void beforeHalt() {
6262
private static void logRuntimeExit(int status) {
6363
// Disable exit logging (GR-45418/JDK-8301627)
6464
}
65+
66+
@Alias
67+
static native void runHooks();
68+
69+
@Alias
70+
static native void halt(int status);
71+
72+
/**
73+
* This substitution makes a few modifications to {@code Shutdown#exit}:
74+
* <ul>
75+
* <li>it omits {@code logRuntimeExit} (exit logging is disabled: GR-45418/JDK-8301627).</li>
76+
* <li>it omits {@code beforeHalt} (not implemented).</li>
77+
* <li>it runs teardown hooks after running shutdown hooks and before halting.</li>
78+
* </ul>
79+
*/
80+
@Substitute
81+
static void exit(int status) {
82+
synchronized (Target_java_lang_Shutdown.class) {
83+
runHooks();
84+
RuntimeSupport.executeTearDownHooks();
85+
halt(status);
86+
}
87+
}
6588
}
6689

6790
/** Utility methods for Target_java_lang_Shutdown. */

0 commit comments

Comments
 (0)