<AWT Dev> [8] Request for review: java/awt/Focus/TypeAhead/TestFocusFreeze.java hangs with jdk8 since b56

Anton V. Tarasov anton.tarasov at oracle.com
Thu May 30 06:48:39 PDT 2013


Hello,

Please, review the fix:

jira: https://jbs.oracle.com/bugs/browse/JDK-8015454
webrev: http://cr.openjdk.java.net/~ant/JDK-8015454/webrev.0

It's a regression of 6981400 "Tabbing between textfield do not work 
properly when ALT+TAB".

That fix resolved the following case: in a frame with several 
components, one pressed TAB multiple times.
This should have transferred focus to the N'th component. But, to make 
things complicated, one switched
back and forth active windows with ALT-TAB in the middle. Namely, when 
the first TAB gets dispatched
(this is possible when if the app performs lengthy tasks on EDT). As a 
result, the appropriate focus window
events were dispatched before the key events and the key events were 
dispatched improperly.

In order to solve it, there were created a timed window event. When a 
timed focus window event is dispatched
by DKFM, it inspects the type-ahead queue and if it contains a key event 
with a time stamp less than the window
event's time, the window event gets reposted to the end of the queue. 
For more details, please refer to the CR.

One aspect wasn't taken into account. A key event, waiting in the 
type-ahead queue, may depend on the
delivery of the focus window event which gets reposted. So, quite the 
contrary, it should be dispatched after
the focus window event is delivered to its target. This may happen when 
a key event is generated after a type-ahead
marker is added (as a result of, say, a window switch), but before the 
targeted component (which may reside in another
window) gets focused. In such situation, the window focus events may get 
reposted infinitely waiting for the key
events, because the latter will wait for the delivery of the focus 
window event. So, a kind of a deadlock...

How to solve it? Somehow we could analyze that the waiting key events 
depend on the delivery of the focus
window event. However, originally it wasn't assumed that key events are 
left in the queue more than a single repost
cycle. If they do, it just means the dependency. So, I suggest simply 
bound the number of reposts by one.

Additionally, I've fixed the test. The key event time stamp should not 
be equal to the type-ahead marker time stamp.
Sometimes they appear to match on Windows. I've put a 1ms delay.

The fix also fixes the following CRs: JDK-8015584 
<https://jbs.oracle.com/bugs/browse/JDK-8015584>, JDK-8015450 
<https://jbs.oracle.com/bugs/browse/JDK-8015450>, JDK-8015446 
<https://jbs.oracle.com/bugs/browse/JDK-8015446>.

Thanks,
Anton.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20130530/4355b268/attachment.html 


More information about the awt-dev mailing list