United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7145768 [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
7145768 : [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest

Details
Type:
Bug
Submit Date:
2012-02-15
Status:
Closed
Updated Date:
2012-04-04
Project Name:
JDK
Resolved Date:
2012-04-04
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7u4

Related Reports
Backport:

Sub Tasks

Description
Mac OS X 10.7.3 macmini4,1, also iMac
Regression test closed/java/awt/Focus/ModalDialogInFocusEventTest consistently fails with b11 on stage 3 or sometimes 4. 
Test does display 2 Frames, and on focus events of a first one it fires a modal Dialog. Failure occurs in b11 if that Frame is activated first of two.

                                    

Comments
SUGGESTED FIX

http://cr.openjdk.java.net/~ant/7145768/
                                     
2012-03-20
EVALUATION

When the first frame is shown and focused, WINDOW_GAINED_FOCUS is posted to it. When the evene is dispatched by DKFM, focus is requested on the most-recent-focus-owner in the frame via calling requestFocusInWindow(). The method (the call stack it produces) looks for the "native focused window" which is returned by KeyboardFocusManagerPeer implementation as a reference to the java peer window object. The latter is set up when corresponding native window gains focus, on toolkit thread. So there may be a time slot when native focused window changes, but KFMPeer still keeps reference to the previous focused window object, on EDT.

Back to requestFocusInWindow(). If allows requests "in window" and denies requests which require focused window change. In case of the test, the request is allowed when real native focused window changes to the second frame, when it's just shown. The latter causes the first frame to regain native focus.

A possible solution is to additionally check if current focused window retained by KFMPeer is natively focused at the moment of decision whether to allow focus request or don't.
                                     
2012-03-12
EVALUATION

The test shows two frames, then it shows a modal dialog from a focus listener (the type of event depends on a test stage), then closes the dialog and hides the frames. The process repeats on the next stage. This way the test checks that showing a dialog doesn't hang the app.

Sometimes, when two frames are shown in a raw, I see window focus events generated for the first frame, then for the second frame and then again for the first frame. At the same time, the second frame remains visually active. Thus, we face java & native focus unsynchronized. After all, the test clicks the second frame & waits for appropriate focus events but nothing is generated as the frame is natively active.
                                     
2012-03-06



Hardware and Software, Engineered to Work Together