25
25
package com .oracle .svm .core .jdk ;
26
26
27
27
import com .oracle .svm .core .annotate .Alias ;
28
+ import com .oracle .svm .core .annotate .Delete ;
28
29
import com .oracle .svm .core .annotate .RecomputeFieldValue ;
29
30
import com .oracle .svm .core .annotate .Substitute ;
30
31
import com .oracle .svm .core .annotate .TargetClass ;
31
- import com .oracle .svm .core .annotate .TargetElement ;
32
32
import com .oracle .svm .core .util .VMError ;
33
33
34
34
@ TargetClass (className = "java.lang.Shutdown" )
@@ -45,23 +45,41 @@ public final class Target_java_lang_Shutdown {
45
45
hooks [Util_java_lang_Shutdown .NATIVE_IMAGE_SHUTDOWN_HOOKS_SLOT ] = RuntimeSupport ::executeShutdownHooks ;
46
46
}
47
47
48
- @ Substitute
49
- static void beforeHalt () {
50
- }
51
-
52
48
/**
53
49
* Invoked by the JNI DestroyJavaVM procedure when the last non-daemon thread has finished.
54
50
* Unlike the exit method, this method does not actually halt the VM.
55
51
*/
56
52
@ Alias
57
53
static native void shutdown ();
58
54
55
+ @ Delete
56
+ private static native void logRuntimeExit (int status );
57
+
58
+ @ Delete
59
+ static native void beforeHalt ();
60
+
61
+ /**
62
+ * This substitution makes a few modifications to {@code Shutdown#exit}:
63
+ * <ul>
64
+ * <li>it omits {@code logRuntimeExit} (exit logging is disabled: GR-45418/JDK-8301627).</li>
65
+ * <li>it omits {@code beforeHalt} (not implemented).</li>
66
+ * <li>it runs teardown hooks after running shutdown hooks and before halting.</li>
67
+ * </ul>
68
+ */
59
69
@ Substitute
60
- @ TargetElement
61
- @ SuppressWarnings ("unused" )
62
- private static void logRuntimeExit (int status ) {
63
- // Disable exit logging (GR-45418/JDK-8301627)
70
+ static void exit (int status ) {
71
+ synchronized (Target_java_lang_Shutdown .class ) {
72
+ runHooks ();
73
+ RuntimeSupport .executeTearDownHooks ();
74
+ halt (status );
75
+ }
64
76
}
77
+
78
+ @ Alias
79
+ static native void runHooks ();
80
+
81
+ @ Alias
82
+ static native void halt (int status );
65
83
}
66
84
67
85
/** Utility methods for Target_java_lang_Shutdown. */
0 commit comments