JDK-8169355 : Diacritics input works incorrectly on Windows if Spanish (Latin American) keyboard layout is used
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2016-11-08
  • Updated: 2017-11-29
  • Resolved: 2016-11-09
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.
8u152Fixed 9 b147Fixed
The issue can be reproduced using a simple program (see below):

import javax.swing.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.concurrent.locks.LockSupport;

public class JTextFieldWithDelayTest {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame();
            JTextField textField = new JTextField(20);
            textField.addKeyListener(new KeyAdapter() {
                public void keyTyped(KeyEvent e) {

After launching the program, perform the following steps:
1) Switch to 'Spanish (United States)' input method (with 'Latin American' keyboard layout)
2) Type the following in a text field: ' ' o - i.e. single quote two times (using [ key on US keyboard) then o character.

Expected result is ''o.
Actual result is ''��.

Problem description: The new mechanism of dead keys detection and processing was introduced by JDK-8139189. It uses MapVirtualKey() function to detect dead key combination. Also an output of MapVirtualKey() invocation is used as a value which is send with Java's KEY_PRESSED/KEY_RELEASED events. However if the mechanism, (i.e. WindowsKeyToJavaChar() function inside awtComponent.cpp) is called from the Java layer via JNI right after a keyboard layout has been changed, MapVirtualKey() returns a character value related to the previous keyboard layout. Fix: The function WindowsKeyToJavaChar() has to take into account the current keyboard layout, (i.e. MapVirtualKey() should be replaced with MapVirtualKeyEx()).