United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6534883 keyReleased keychars are inconsistent in JDK6 on both Linux and Solaris and different from JDK5
JDK-6534883 : keyReleased keychars are inconsistent in JDK6 on both Linux and Solaris and different from JDK5

Details
Type:
Bug
Submit Date:
2007-03-15
Status:
Closed
Updated Date:
2011-05-18
Project Name:
JDK
Resolved Date:
2011-05-18
Component:
client-libs
OS:
linux
Sub-Component:
java.awt
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
keyReleased keychars are inconsistent in JDK6 (on both Solaris and Linux). It seems to be a kind of an initialization problem of the JVM, because the keychars return different values depending on when you have pressed particular characters the first time.

The problem has been detected with JDK6 on both Solaris and Linux (but not Windows). This problem isn't reproducible with JDK5 (neither with Solaris nor Linux nor Windows).

If you perform the test, make sure you have a keyboard which allows you to press a dead acute sign. If you perform the test on Linux, make sure that have not configured nodeadkeys for the keyboard properties. Quick test: if you type the keys <dead acute> followed by an <e> in a terminal, you should see: ??

A small testcase (c_framekeylook) ist attached to this CR. Compile and run it with
$ javac c_framekeylook.java
$ java -cp . c_framekeylook

An AWT frame opens and you can press keys on the keyboard now. Keys which has been used for this testcase are e, a and the dead acute. The keychars are printed to the standard output. Compare the 1.5 output with the output of 1.6 to understand the problem.

Output on Linux (1_5_acc_e.txt, 1_5_e_acc_e.txt, 1_6_acc_e.txt, 1_6_e_acc_e.txt) have been attached to the report as well.

The following output has been gathered on Solaris 10:

Solaris 10
==========
1.6
---
<dead acute> <e>
----------------
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Dead Acute,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='??',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

<e> <dead acute> <e>
--------------------
keyPressed: kev=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='e',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0x65(101)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)

keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Dead Acute,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='??',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)

<a> <dead acute> <e>
--------------------
keyPressed: kev=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyText=A,keyChar='a',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x61(97)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='a',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0x61(97)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=65,keyText=A,keyChar='a',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x61(97)

keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Dead Acute,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='??',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)


1.5.0_11
--------
<dead acute> <e>
---------------
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Dead Acute,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='??',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)

<e> <dead acute> <e>
--------------------
keyPressed: kev=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='e',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0x65(101)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)

keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Dead Acute,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='??',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)


<a> <dead acute> <e>
--------------------
keyPressed: kev=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyText=A,keyChar='a',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x61(97)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='a',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0x61(97)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=65,keyText=A,keyChar='a',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x61(97)

keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Dead Acute,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='??',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyChar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)


The following output has been gathered on Suse Linux:

Linux
=====
1_5_acc_e.txt
-------------
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Akut (
Dead),keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCod
e: 0x0,keyChar='????',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyCh
ar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)


1_5_e_acc_e.txt
---------------
keyPressed: kev=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=69,keyText=E,keyChar
='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCod
e: 0x0,keyChar='e',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0x65(101)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyCh
ar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Akut (
Dead),keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCod
e: 0x0,keyChar='????',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyCh
ar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)


1_6_acc_e.txt
-------------
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Akut (
Dead),keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCod
e: 0x0,keyChar='????',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyCh
ar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

1_6_e_acc_e.txt
---------------
keyPressed: kev=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=69,keyText=E,keyChar
='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCod
e: 0x0,keyChar='e',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0x65(101)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyCh
ar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Akut (
Dead),keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)
keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCod
e: 0x0,keyChar='????',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyCh
ar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)

                                    

Comments
WORK AROUND

On JDK6, use the MToolkit rather than the XToolkit. See also
http://java.sun.com/javase/6/docs/technotes/guides/awt/1.5/xawt.html

$ java -Dawt.toolkit=sun.awt.X11.XToolkit -cp . c_framekeylook
[--snip--]
CHAR-ENCODING: UTF8

keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=129,keyText=Akut (
Dead),keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0xffff(65535)

keyTyped: kev=java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCod
e: 0x0,keyChar='????',keyLocation=KEY_LOCATION_UNKNOWN] on frame0
   char=0xe9(233)
keyReleased: kev=java.awt.event.KeyEvent[KEY_RELEASED,keyCode=69,keyText=E,keyCh
ar='e',keyLocation=KEY_LOCATION_STANDARD] on frame0
   char=0x65(101)

*** (#1 of 1): [ UNSAVED ] ###@###.###
                                     
2007-03-15
EVALUATION

In current implementation, it's hard to tell keychar by keycode of KeyRelease. Basically, it is cached from a correspondent KeyPress and later retrieved on KeyRelease by keycode. So if there was KeyPress processed for this keycode, keychar will be taken from cache, otherwise it will be CHAR_UNDEFINED. 

Now, for certain reason, we have no KeyPress to process in java for a vowel if a dead key has changed state in IM. It is just filtered out, consumed by IM. Therefore, if your input consist no 'e' before 'e acute', you'll have CHAR_UNDEFINED on 'e' KeyRelease.

We are working together with IM team to fix that. In the meantime, I'd note that, even comparing with related bugs, the impact of this one is not very significant, and also, specification explicitly warns user not to depend on KeyChar value in non-KEY_TYPED events. So I'm going to decrease priority of this bug.
                                     
2007-03-26



Hardware and Software, Engineered to Work Together