JDK-6978742 : RequestFocusInWindowTest test fails on WindowsXP
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0u17-crev
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2010-08-20
  • Updated: 2011-02-16
  • Resolved: 2010-11-25
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.
Other Other
5.0u17-crev b04Fixed 5.0u29Fixed
Related Reports
Relates :  
Relates :  
Description
RequestFocusInWindowTest test fails in windowsXP on Hitachi custom revision
See comments for full description

Comments
EVALUATION This issue was fixed together with CR 6928397 and CR 6938377. All three issues are linked to ::SetFocus(NULL) call in awt_Frame.cpp. The previous fix for CR 6928397 removed that call but it caused a regression CR 6978742. To fix both these issues, ::SetFocus(NULL) call was restored, and another fix was introduced in awt_Component.cpp. But, in turn, it caused the symptomes of CR 6938377. This problem was fixed by introducing a new condition around ::SetFocus(NULL) call which excluded a set of situations when the call is not desired.
09-11-2010

SUGGESTED FIX The code review request: http://jpsesvr.sfbay.sun.com:8080/ctetools/html/ViewDetail.jsp?index=3822
09-11-2010

EVALUATION Below is a step by step description of what's going on in the focus management (starting from switching to frame 1). 1. WM_ACTIVATE is received on frame1 Posting WINDOW_GAINED_FOCUS. 2. WM_SETFOCUS is received on frame1 This message is generated by the native platform. It restores the previous native focus owner (the frame itself in the test). ::SetFocus(NULL) call was just aimed at preventing this message from being sent. Posting FOCUS_GAINED. 3. WINDOW_GAINED_FOCUS is received on frame1 (the result of [1]) In the handler of the event (see DefaultKeyboardFocusManager.dispatchEvent): 3.1 requesting focus to "tempLost" component, that is LWList1 in the test: 3.1.1 adding HW request for frame1 to the queue (see KeyboardFocusManager.shouldNativelyFocusHeavyweight) 3.1.2 adding LW request for LWList1 to the HW request entry made at [3.1.1] 3.1.3 posting FOCUS_GAINED to LWList1 3.2 requesting focus to "mostRecentFocusOwner" component, that is LWList0 in the test: 3.2.1 adding LW request for LWList0 to the HW request entry made at [3.1.1] 4. FOCUS_GAINED is received on frame1 (the result of [2]) The event matches the HW request made at [3.1.1], this initiates processing of the LW requests. Processing LW requests: sending (synchronously) FOCUS_GAINED to LwList1 and LWList0 in a row 5. FOCUS_GAINED is received on LWList1 (the result of [3.1.3]) So, at the 5th step we get wrong focus set to LWList1. The cause is the unexpected focus event received at the 4th step (sent at the 2nd step) which trigerred out of order processing of the LW requests queue. The matching focus event that should have triggered the processing was posted at [3.1.3]. The problem in general is old: unmanaged native focus. It's resolved in jdk7 as 6806217. The fix is huge though, so backporting could be considered as the last possible solution, if nothing else suites.
16-09-2010

EVALUATION I prepared a minimal version of the test case that reproduces the failure - SimplifiedRequestFocusInWindowTest.zip (attached) - and found that there is a strong dependency between this failure and the types of "list1" and "list2" lists. The problem reproduces only if they are lightweight components (javasoft.awtsqe.lw.LWList) and doesn't happen if they are heavyweight components (java.awt.List). Also I verified that it is the removal of ::SetFocus() call in awt_Frame.cpp by the fix for CR 6928397 what is responsible for the observed regression. (This was the only change in awt_Frame.cpp) Restoring this call fixes the regression test case failure (but is a subject for discussion with PDE since it may break the original fix).
01-09-2010