JDK-6382750 : awt :TypeAhead Test is failing for all windows but passes in solaris and linux for all tiger JDKS.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2,5.0,5.0u7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_9,windows
  • CPU: x86,sparc
  • Submitted: 2006-02-08
  • Updated: 2011-01-19
  • Resolved: 2006-04-05
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.
JDK 6
6 b79Fixed
Related Reports
Duplicate :  
Relates :  
Description
Synopsis: TypeAhead Test is failing for all windows but passes in solaris and linux for all tiger JDKS(EVEN FCS).

Test Case from Regression workspce:
===================================
java/awt/KeyboardFocusmanager/TypeAhead/TestDialogTypeAhead.html

Java -version:
==============
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-ea-b01)
Java HotSpot(TM) Server VM (build 1.5.0_07-ea-b01, mixed mode)

To Reproduce:
=============
1) Inatll the test jdk in any windows machine.
2) Copy TestDialogTypeAhead.html, TestDialogTypeAhead.java and awtsqe.jar which are attached to the bugster.
3) Compile the java files as
<jdk-home>/bin/javac -classpath ./awtsqe.jar TestDialogTypeAhead.java
4) Run the applet as
<jdk-home>/bin/appletviewer -Xnosecurity -J-classpath -J./awtsqe.jar:. TestDialogTypeAhead.html

Out put Exception:
==================
b is shown
b is focused
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=Space,keyChar=' ',keyLocation=KEY_LOCATION_STANDARD] on button0
java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=' ',keyLocation=KEY_LOCATION_UNKNOWN] on but
ton0
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=32,keyText=Space,keyChar=' ',keyLocation=KEY_LOCATION_STANDARD] on button0
B pressed
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=Space,keyChar=' ',keyLocation=KEY_LOCATION_STANDARD] on button0
java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=' ',keyLocation=KEY_LOCATION_UNKNOWN] on but
ton0
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=32,keyText=Space,keyChar=' ',keyLocation=KEY_LOCATION_STANDARD] on button0
Ok got focus
java.lang.RuntimeException: Type-ahead doesn't work
        at TestDialogTypeAhead.start(TestDialogTypeAhead.java:152)
        at sun.applet.AppletPanel.run(AppletPanel.java:418)
        at java.lang.Thread.run(Thread.java:595)
Ok got focus
Ok got focus
Ok got focus
Ok got focus

Out put in Linux And Solaris:
==============================
b is shown
b is focused
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=Space,keyChar=' ',keyLocation=KEY_LOCATION_STANDARD] on button0
java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=' ',keyLocation=KEY_LOCATION_UNKNOWN] on button0
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=32,keyText=Space,keyChar=' ',keyLocation=KEY_LOCATION_STANDARD] on button0
B pressed
Ok got focus
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=Space,keyChar=' ',keyLocation=KEY_LOCATION_STANDARD] on button1
OK pressed

Comments
SUGGESTED FIX See the webrev here: http://javaweb.sfbay/jcg/1.6.0-mustang/awt/6382750
20-03-2006

EVALUATION Actually I found the test failing on Windows with all JDKs since 1.4.2 (probably since even older). And it looks like the problem is in AwtDialog::WmShowModal() method. Here: // normally done by DefWindowProc(WM_ACTIVATE), // but we override that message so we do it explicitly ::SetFocus(GetHWnd()); So, for some reason it sets native focus on dialog itself. The comments doesn't explain that reason. Indeed, we override DefWindowProc(WM_ACTIVATE) but then focus is requested on initial component (or most recent focus owner) in a window/frame/dialog. In fact, these strings fell into the code in JDK 1.1.7 and it looks like they don't make sense long ago. Now it results in that after a modal dialog is shown it receives FOCUS_GAINED on itself and then another FOCUS_GAINED on its initial component. KFM finds the first FOCUS_GAINED unexpected (indeed, it wasn't requested) and clears type-ahead markers queue as result (see retargetUnexpectedFocusEvent()). So, the markers queue is empty and newly appearing key events are dispatched direclty to the current focus owner that is the dialog (before focus comes to the initial component). Thus the initial component won't get that key events.
14-02-2006

EVALUATION Reproduced with JDK6.0b65 and local WS but we have similar CRs recently.
08-02-2006