On Sun, 6 Sep 2026 15:22:36 GMT, Marius Hanl <[email protected]> wrote:
> Issue only exists in the Headless platform. Consider this test code:
>
>
> KeyCombination combination = KeyCombination.valueOf("shortcut+,");
>
> KeyEvent event = new KeyEvent(KeyEvent.KEY_PRESSED, "s", "S", KeyCode.S,
> false, true, false, false);
> boolean match = combination.match(event);
>
>
> What happens is that the KeyCombination is an instance of
> `KeyCharacterCombination`.
>
> `KeyCharacterCombination` is special, because in its `match` function, it
> will call:
> `Toolkit.getToolkit().getKeyCodeForChar(getCharacter(), code));`
> which will be delegated to the `HeadlessApplication`, which will throw an
> `UnsupportedOperationException`.
>
> Most of the time, the `KeyCombination` is not an instance of
> `KeyCharacterCombination`, so this exception can only be reproduced with more
> special combinations like in the example with the comma.
>
> I used the implementation we also use in `Monocle`. Rechecked with the US
> keyboard layout.
>
> ---
>
> Trivia: JabRef found this issue when changing their tests from Monocle to
> Headless: [GHA
> run](https://github.com/JabRef/jabref/actions/runs/34032443925/job/101484543433?pr=16850)
>
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK
> Interim AI Policy](https://openjdk.org/legal/ai).
Changes requested by angorya (Reviewer).
Also, this might be related: #2257
modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessApplication.java
line 2:
> 1: /*
> 2: * Copyright (c) 2025, 2026, Gluon. All rights reserved.
you mentioned that it is the same code used in Monocle - was it copied from
there or just the logic was adopted? My question is whether this change is
compatible with the openjdk/jfx license.
modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessApplication.java
line 255:
> 253: case '=' -> KeyEvent.VK_EQUALS;
> 254: case '[' -> KeyEvent.VK_BRACELEFT;
> 255: case ']' -> KeyEvent.VK_BRACERIGHT;
are the codes for `[` and `]` correct? shouldn't they be mapped to
`VK_OPEN_BRACKET` / `VK_CLOSE_BRACKET`
modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessApplication.java
line 262:
> 260: case '.' -> KeyEvent.VK_PERIOD;
> 261: case '/' -> KeyEvent.VK_SLASH;
> 262: default -> KeyEvent.VK_UNDEFINED;
what about " " -> `VK_SPACE`?
modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessApplication.java
line 281:
> 279: case '^' -> '6';
> 280: case '&' -> '7';
> 281: case '*' -> '8';
looks like it will break if numpad is used.
example: (Numpad-*) is converted to 8 instead of `KeyCode.MULTIPLY`, right?
tests/system/src/test/java/test/com/sun/glass/ui/headless/HeadlessApplicationKeyCombinationTest.java
line 74:
> 72: match = combination.match(event);
> 73:
> 74: assertTrue(match);
this test fails on macOS
tests/system/src/test/java/test/com/sun/glass/ui/headless/HeadlessApplicationKeyCombinationTest.java
line 76:
> 74: assertTrue(match);
> 75: }
> 76:
extra newline
-------------
PR Review: https://git.openjdk.org/jfx/pull/2297#pullrequestreview-5146546404
PR Comment: https://git.openjdk.org/jfx/pull/2297#issuecomment-5591740167
PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3961950261
PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3961880827
PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3961887471
PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3961846794
PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3962159346
PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3961984443