JDK-8130772 : Util.hitMnemonics does not work: getSystemMnemonicKeyCodes() returns ALT_MASK rather than VK_ALT
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-07-08
  • Updated: 2022-07-27
  • Resolved: 2015-07-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.
JDK 8 JDK 9 Other
8u351Fixed 9 b76Fixed openjdk8u282Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
New implementation of test/swing/regtesthelpers/Util.getSystemMnemonicKeyCodes is not correct.

It combines key codes and key masks:

    public static ArrayList<Integer> getSystemMnemonicKeyCodes() {
        String osName = System.getProperty("os.name");
        ArrayList<Integer> result = new ArrayList<>();
        if (osName.contains("OS X")) {
            result.add(KeyEvent.VK_CONTROL);
        }
        result.add(KeyEvent.ALT_MASK);
        return result;
    }

KeyEvent.VK_CONTROL and KeyEvent.ALT_MASK are combined, and then interpreted as key codes by hitMnemonics but KeyEvent.ALT_MASK is not a key code. Therefore tests which use Util.hitMnemonics fail now, for example test javax/swing/JFileChooser/8002077/bug8002077.java.
Comments
Fix Request (8u). Applies cleanly. Minimal risk, adds a method to a swing test suite utility. Required for JDK-8067441 on 8u: javax/swing/JMenu/4515762 passes with this patch.
24-11-2020

URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/1873d761658e User: lana Date: 2015-08-05 21:01:38 +0000
05-08-2015

URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/1873d761658e User: aivanov Date: 2015-07-09 12:27:47 +0000
09-07-2015

Before Util.getSystemMnemonicKeyCodes() was removed from test/swing/regtesthelpers/Util.java, the method was implemented this way: public static ArrayList<Integer> getSystemMnemonicKeyCodes() { return Util.getKeyCodesFromKeyMask(SwingUtilities2.getSystemMnemonicKeyMask()); } It contained two steps: SwingUtilities2.getSystemMnemonicKeyMask() returned the key mask which was converted to key codes using Util.getKeyCodesFromKeyMask. KeyEvent.ALT_MASK has to be changed to KeyEvent.VK_ALT.
08-07-2015