JDK-7134826 : [macosx] KeyEvent difference between Apple 1.6 and openjdk
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7u4
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic
  • Submitted: 2012-01-27
  • Updated: 2012-09-25
  • Resolved: 2012-03-23
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.
7u4 b11Fixed

Basically the code involved is a KeyListener on a JTextArea
setup like...
From the CmdJConsole class...
TextInterface theText = null, entry = null;

entry = new SwingTextArea("area","",2,80);

[The entry component that the KeyListener ends up bolted to...
public class SwingTextAreaImpl extends JTextArea implements SwingTextImpl {

From the CmdJConsole KeyListener (keyTyped method) when CTRL-D is entered
With 1.7 I see this here...
CmdJConsole: byte 100 code 0
CmdJConsole: modifiers 128

With 1.6
CmdJConsole: byte 4 code 0
CmdJConsole: modifiers 128

The current workaround is...

byte keychar = (byte)kevt.getKeyChar();
if (keychar == (byte)4)
else if (kevt.isControlDown() && kevt.getKeyChar() == 'd') { ((CmdIn)imp.getIn()).eod(); }

The first 'if' works SE 6, the second works on SE 7.
I haven't come up with one that seems to cover both.

This is an old app I am getting up and running again. I plan on probably uploading shortly if a test case is wanted.
Or I can try to get a more isolated test case.

EVALUATION The current fix doesn't work for layouts other then English (no matter what the current layout is, ctrl+D should always generate 0x04 character). Better fix is to rely on OS X to do the translation instead of doing it ourself in Java.