On Tue, 8 Sep 2026 20:25:37 GMT, Andy Goryachev <[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).
>
> 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.

Yes, copied from `KeyInput` here in this repositoy. I don't know this can 
violate the copyright when it is just a regular file here in OpenJFX.

https://github.com/openjdk/jfx/blob/b8e3101220e564d3f9e2a72bb7eed929c2bc2e44/modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/KeyInput.java#L191

> 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

what is the exact failure?

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3962341397
PR Review Comment: https://git.openjdk.org/jfx/pull/2297#discussion_r3962342540

Reply via email to