Skip to content

Commit e384c76

Browse files
committed
Improve JavaFX toolkit initialization in tests - Added error handling for glass platform initialization failures and ensured headless properties are set correctly.
1 parent 86aab6e commit e384c76

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

fx-onscreen-keyboard/src/test/java/org/comtel2000/keyboard/control/KeyButtonTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ static void initToolkit() throws Exception {
2323
// Ensure headless property is set early in CI via JAVA_TOOL_OPTIONS; this is
2424
// just in case.
2525
System.setProperty("java.awt.headless", System.getProperty("java.awt.headless", "true"));
26+
System.setProperty("prism.order", "sw");
27+
System.setProperty("prism.forceGPU", "false");
28+
System.setProperty("glass.platform", "Monocle");
29+
System.setProperty("monocle.platform", "Headless");
2630

2731
// Initialize JavaFX toolkit (safe if already started)
2832
try {
@@ -32,6 +36,11 @@ static void initToolkit() throws Exception {
3236
});
3337
} catch (IllegalStateException ex) {
3438
// toolkit already started
39+
} catch (NullPointerException | RuntimeException ex) {
40+
// Handle glass platform initialization failures in JDK 25+
41+
// This can occur when the glass platform factory is not properly initialized
42+
System.err.println("Warning: Failed to initialize JavaFX toolkit: " + ex.getMessage());
43+
ex.printStackTrace();
3544
}
3645
}
3746

0 commit comments

Comments
 (0)