8162840: Desktop. enableSuddenTermination() has no effect
Reviewed-by: serb
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java Tue Aug 23 14:47:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java Tue Aug 23 18:15:27 2016 +0300
@@ -171,7 +171,8 @@
currentQuitResponse = null;
try {
- if (defaultQuitAction == QuitStrategy.NORMAL_EXIT) System.exit(0);
+ if (defaultQuitAction == QuitStrategy.NORMAL_EXIT
+ || _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0);
if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
throw new RuntimeException("Unknown quit action");
@@ -422,6 +423,10 @@
}
void performUsing(final QuitHandler handler, final _NativeEvent event) {
+ if (_AppMiscHandlers.isSuddenTerminationEnbaled()) {
+ performDefaultAction(event);
+ return;
+ }
final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
handler.handleQuitRequestWith(new QuitEvent(), response);
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java Tue Aug 23 14:47:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java Tue Aug 23 18:15:27 2016 +0300
@@ -26,6 +26,8 @@
package com.apple.eawt;
class _AppMiscHandlers {
+ private static boolean isSuddenTerminationEnabled;
+
private static native void nativeOpenHelpViewer();
private static native void nativeRequestActivation(final boolean allWindows);
@@ -47,10 +49,16 @@
}
static void enableSuddenTermination() {
+ isSuddenTerminationEnabled = true;
nativeEnableSuddenTermination();
}
static void disableSuddenTermination() {
+ isSuddenTerminationEnabled = false;
nativeDisableSuddenTermination();
}
+
+ public static boolean isSuddenTerminationEnbaled() {
+ return isSuddenTerminationEnabled;
+ }
}