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

Anthony Petrov anthony.petrov at oracle.com
Fri May 31 06:41:31 PDT 2013

Hi Anton,

My knowledge of the focus machinery is limited, but according to your 
description of the problem, the main issue here is that we re-post 
window events to the end of the queue as opposed to re-posting them to a 
specific position in the queue.

In other words my question is: can we move the timed window events to a 
specific position in the event queue according to their timestamp, so 
that both the key and window events get processed in the same order as 
they have actually been generated by the native system?

best regards,

On 05/30/2013 05:48 PM, Anton V. Tarasov wrote:
> 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.

More information about the awt-dev mailing list