EVALUATION
I have emailed submitter as I was not able to reproduce this on 2000/nt/98.
###@###.### 2002-01-25
Submitter indicates this only heppens when running Reflection X on his 2000 machine, which would seem to apply this isn't a swing problem but most likely either a reflection x problem or awt problem.
From submitter:
I don't think they're running Reflection X, they probably have their own set of application windows that causes the same problem. So, this bug might be appearing rather frequently under different circumstances. I'll ask them about their configuration.
###@###.### 2002-01-28
Because it is too late to fix this in Merlin, I am dropping the priority to 4.
Since it is an escalation, I will commit it to Hopper. I assume CTE plans to
fix this in 1.4.0_001. We should make sure it is also fixed in Hopper.
I will assign it to our focus engineers for tracking purposes only. We'll
let CTE finish their investigation.
###@###.### 2002-01-28
Name: ssR10077 Date: 02/07/2002
This is thread race in awt_Component.cpp between sending a
WM_AWT_COMPONENT_SETFOCUS from
Java_sun_awt_windows_WComponentPeer_requestFocus called from
EventDispatchThread and Asyncronous Focus events from operating system
posted on Mouse press. The Reflection sets global Hook on system events and
so changes the event timings.
Tread race:
Send WM_AWT_COMPONENT_SETFOCUS, HWND=2000e0
HWND=2000e0 WM_AWT_COMPONENT_SETFOCUS
::SetFocus(GetHWnd()), GetHWnd()=2000e0
HWND=2000e0 WM_SETFOCUS lParam=0, wParam=0
Send WM_AWT_COMPONENT_SETFOCUS, HWND=2000e0
HWND=2000e0 WM_AWT_COMPONENT_SETFOCUS
**HWND=2000e0 WM_KILLFOCUS lParam=0, wParam=0
Send WM_AWT_COMPONENT_SETFOCUS, HWND=2000e0
HWND=2000e0 WM_AWT_COMPONENT_SETFOCUS
::SetFocus(GetHWnd()), GetHWnd()=2000e0
**HWND=2000e0 WM_SETFOCUS lParam=0, wParam=0
HWND=2000e0 WM_KILLFOCUS lParam=0, wParam=1a00fe
HWND=2000e0 WM_SETFOCUS lParam=0, wParam=2000e0
Send WM_AWT_COMPONENT_SETFOCUS, HWND=2000e0
HWND=2000e0 WM_AWT_COMPONENT_SETFOCUS
Normal Run:
Send WM_AWT_COMPONENT_SETFOCUS, HWND=230274
HWND=230274 WM_AWT_COMPONENT_SETFOCUS
::SetFocus(GetHWnd()), GetHWnd()=230274
HWND=230274 WM_SETFOCUS lParam=0, wParam=0
Send WM_AWT_COMPONENT_SETFOCUS, HWND=230274
HWND=230274 WM_AWT_COMPONENT_SETFOCUS
**HWND=230274 WM_KILLFOCUS lParam=0, wParam=0
**HWND=230274 WM_SETFOCUS lParam=0, wParam=0
Send WM_AWT_COMPONENT_SETFOCUS, HWND=230274
HWND=230274 WM_AWT_COMPONENT_SETFOCUS
::SetFocus(GetHWnd()), GetHWnd()=230274
HWND=230274 WM_KILLFOCUS lParam=0, wParam=230274
HWND=230274 WM_SETFOCUS lParam=0, wParam=18021a
Send WM_AWT_COMPONENT_SETFOCUS, HWND=230274
HWND=230274 WM_AWT_COMPONENT_SETFOCUS
======================================================================
Name: osR10079 Date: 02/17/2002
In the test, when a customer clicks on an item in JComboBox popup, the
window (heavyweight AWT window which is used to implement this popup)
receives WM_ACTIVATE. As a result of this, AWT code that handles
window activation starts working. It calls
AwtToolkit::InvokeFunctionLater() with AwtWindow::BounceActivation()
as its parameter. Within BounceActivation, we make the nearest Frame
or Dialog (in this case Frame) active, and set the focus on window
focus proxy related to this Frame. To prevent native events caused by
calls to SetActiveWindow and SetFocus from being passed to Java level,
we use Component's static field sm_suppressFocusAndActivation, which
we set before those calls and clear after them (here we use the fact
that SetActiveWindow and SetFocus only generate synchronous events,
i.e. the events that will be processed before those two functions
return). We also assume that within this handler no other Win32
message will be dispatched.
However, our last assumption appears to be wrong (most likely it is a
bug in Win32 API though). So, if we are especially lucky with thread
timings (Spy++ or ReflectionX enhance our luck by installing global
hooks), another meassge WM_AWT_COMPONENT_SETFOCUS is dispatched while
sm_suppressFocusAndActivation is set. This WM_AWT_COMPONENT_SETFOCUS
message is generated on Java level (by requestFocus(), called by
Swing). And the handler of this message actually sets focus to the
correct component (in our case, Frame). Since it happens when
activation and focus are suppressed, this is not passed back to Java
and Java thinks that focus is not set.
We can suggest an easy solution for patch release. Please see
Suggested fix section.
###@###.###
======================================================================
|