From 501d313da65667586f38801636c491a02dfde671 Mon Sep 17 00:00:00 2001 From: rwestberg Date: Tue, 13 Feb 2018 15:48:23 +0100 Subject: [PATCH] 8041626: Shutdown tracing event Reviewed-by: dholmes, alanb, rriggs --- make/mapfiles/libjava/mapfile-vers | 1 + src/share/classes/java/lang/Runtime.java | 1 + src/share/classes/java/lang/Shutdown.java | 6 +++++- src/share/javavm/export/jvm.h | 3 +++ src/share/native/java/lang/Shutdown.c | 7 ++++++- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/make/mapfiles/libjava/mapfile-vers b/make/mapfiles/libjava/mapfile-vers index 1168c7995..244540493 100644 --- a/make/mapfiles/libjava/mapfile-vers +++ b/make/mapfiles/libjava/mapfile-vers @@ -205,6 +205,7 @@ SUNWprivate_1.1 { Java_java_lang_SecurityManager_currentClassLoader0; Java_java_lang_SecurityManager_currentLoadedClass0; Java_java_lang_SecurityManager_getClassContext; + Java_java_lang_Shutdown_beforeHalt; Java_java_lang_Shutdown_halt0; Java_java_lang_String_intern; Java_java_lang_System_identityHashCode; diff --git a/src/share/classes/java/lang/Runtime.java b/src/share/classes/java/lang/Runtime.java index 9e53dc939..a64458e1e 100644 --- a/src/share/classes/java/lang/Runtime.java +++ b/src/share/classes/java/lang/Runtime.java @@ -272,6 +272,7 @@ public class Runtime { if (sm != null) { sm.checkExit(status); } + Shutdown.beforeHalt(); Shutdown.halt(status); } diff --git a/src/share/classes/java/lang/Shutdown.java b/src/share/classes/java/lang/Shutdown.java index 7ce64ffae..959493eb9 100644 --- a/src/share/classes/java/lang/Shutdown.java +++ b/src/share/classes/java/lang/Shutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, 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 @@ -130,6 +130,9 @@ class Shutdown { } } + /* Notify the VM that it's time to halt. */ + static native void beforeHalt(); + /* The halt method is synchronized on the halt lock * to avoid corruption of the delete-on-shutdown file list. * It invokes the true native halt method. @@ -209,6 +212,7 @@ class Shutdown { /* Synchronize on the class object, causing any other thread * that attempts to initiate shutdown to stall indefinitely */ + beforeHalt(); sequence(); halt(status); } diff --git a/src/share/javavm/export/jvm.h b/src/share/javavm/export/jvm.h index 2dc2e2021..f001e92d0 100644 --- a/src/share/javavm/export/jvm.h +++ b/src/share/javavm/export/jvm.h @@ -131,6 +131,9 @@ JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset, JNIEXPORT void JNICALL JVM_Exit(jint code); +JNIEXPORT void JNICALL +JVM_BeforeHalt(); + JNIEXPORT void JNICALL JVM_Halt(jint code); diff --git a/src/share/native/java/lang/Shutdown.c b/src/share/native/java/lang/Shutdown.c index f131a240f..b8f1bd2ea 100644 --- a/src/share/native/java/lang/Shutdown.c +++ b/src/share/native/java/lang/Shutdown.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, 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 @@ -29,6 +29,11 @@ #include "java_lang_Shutdown.h" +JNIEXPORT void JNICALL +Java_java_lang_Shutdown_beforeHalt(JNIEnv *env, jclass ignored) +{ + JVM_BeforeHalt(); +} JNIEXPORT void JNICALL Java_java_lang_Shutdown_halt0(JNIEnv *env, jclass ignored, jint code) -- GitLab