JDK-8032078 : [macosx] CPlatformWindow.setWindowState throws RuntimeException, if windowState=ICONIFIED:MAXIMIZED_BOTH
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7-pool
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2014-01-17
  • Updated: 2014-10-15
  • Resolved: 2014-02-24
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.
JDK 7 JDK 8 JDK 9
7u66Fixed 8u20Fixed 9Fixed
Description
FULL PRODUCT VERSION :
JDK 7u45 b18

ADDITIONAL OS VERSION INFORMATION : 
OS X 

A DESCRIPTION OF THE PROBLEM :
The method "sun.lwawt.macosx.CPlatformWindow.setWindowState" throws "java.lang.RuntimeException", if the provided "windowState" parameter is the bitwise mask "Frame.ICONIFIED | Frame.MAXIMIZED_BOTH" on OS X platform. Since the exception is undocumented, a third party application passing such a state value is not ready to handle the exception.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached test case "RuntimeExceptionOnSetExtendedState.java.zip".

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.RuntimeException: Unknown window state: 7
        at sun.lwawt.macosx.CPlatformWindow.setWindowState(CPlatformWindow.java:830)
        at sun.lwawt.LWWindowPeer.setState(LWWindowPeer.java:589)
        at java.awt.Frame.setExtendedState(Frame.java:753)
        at RuntimeExceptionOnSetExtendedState.main(RuntimeExceptionOnSetExtendedState.java:14)
Comments
During the code review of the fix it was decided not to create an additional case in "switch" block of the method "sun.lwawt.macosx.CPlatformWindow.setWindowState", but to treat all state bit masks containing "Frame.ICONIFIED" bit as "Frame.ICONIFIED" state. Also it was found out that it is necessary to add an analogous change into "sun.lwawt.macosx.CPlatformWindow.setVisible" method.
24-02-2014

A possible solution for this bug could be addition of handling of the compound mask "Frame.ICONIFIED | Frame.MAXIMIZED_BOTH" to "switch" block in the method "sun.lwawt.macosx.CPlatformWindow.setWindowState" which would duplicate currently existing handling of the mask "Frame.ICONIFIED" but not throw RuntimeException. Current behavior of throwing of RuntimeException for this particular bitwise mask does not correspond to the value "true" returned by a call to "java.awt.Frame.isFrameStateSupported" method for this mask.
21-01-2014