JDK-7149085 : [macosx] Quit with QuitStrategy CLOSE_ALL_WINDOWS does terminate application
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2012-02-27
  • Updated: 2012-04-04
  • Resolved: 2012-04-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u4 b18Fixed 8Fixed
Related Reports
Duplicate :  
Mac OS X 10.7.3 macmini4,1
Run the attached application. Here, QuitStrategy.CLOSE_ALL_WINDOWS is set. Mac OS sends to all windows in back-to-front order a closing event. On Java level, it is windowClosing(), and if on windowClosing nothing is explicitly closed, it is equivalent to no action. So it works on Apple Java 6: you will see printout from windowClosing() listener's method, and that's it.

However in jdk7 the application frames receive windowClosing, do not receive windowClosed, and application terminates.

EVALUATION Now in b18 we behave just like Apple Java 6 in u31. (And unlike Apple Java 6 u24/26 which did as we did in b17).

SUGGESTED FIX --- old/src/macosx/classes/com/apple/eawt/_AppEventHandler.java 2012-03-20 18:28:42.000000000 +0400 +++ new/src/macosx/classes/com/apple/eawt/_AppEventHandler.java 2012-03-20 18:28:41.000000000 +0400 @@ -157,7 +157,10 @@ } }); } finally { - nativeReplyToAppShouldTerminate(true); + // Either we've just called System.exit(), or the app will call + // it when processing a WINDOW_CLOSING event. Either way, we reply + // to Cocoa that we don't want to exit the event loop yet. + nativeReplyToAppShouldTerminate(false); } }

EVALUATION We should never return YES from applicationShouldTerminate:. Either we call System.exit() ourselves, or the app will call it when processing WINDOW_CLOSING events.