From f59ee5acfca6c0ac2cb60b892c4503bd0d18bd1a Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Wed, 13 May 2026 17:42:54 +0000 Subject: [PATCH] 8248122: java launcher should launch normally if JavaFX modules not found Reviewed-by: kcr, prr, aivanov --- .../share/classes/sun/launcher/LauncherHelper.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/sun/launcher/LauncherHelper.java b/src/java.base/share/classes/sun/launcher/LauncherHelper.java index 9badf2beaeb..04adf0549b4 100644 --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java @@ -98,6 +98,8 @@ public final class LauncherHelper { "javafx.application.Application"; private static final String JAVAFX_FXHELPER_CLASS_NAME_SUFFIX = "sun.launcher.LauncherHelper$FXHelper"; + private static final String JAVAFX_GRAPHICS_MODULE_NAME = + "javafx.graphics"; private static final String LAUNCHER_AGENT_CLASS = "Launcher-Agent-Class"; private static final String MAIN_CLASS = "Main-Class"; private static final String ADD_EXPORTS = "Add-Exports"; @@ -768,8 +770,9 @@ public final class LauncherHelper { * the main class may or may not have a main method, so do this before * validating the main class. */ - if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) || - doesExtendFXApplication(mainClass)) { + if ((JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) || + doesExtendFXApplication(mainClass)) && + ModuleLayer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME).isPresent()) { // Will abort() if there are problems with FX runtime FXHelper.setFXLaunchParameters(what, mode); mainClass = FXHelper.class; @@ -1082,9 +1085,6 @@ public final class LauncherHelper { static final class FXHelper { - private static final String JAVAFX_GRAPHICS_MODULE_NAME = - "javafx.graphics"; - private static final String JAVAFX_LAUNCHER_CLASS_NAME = "com.sun.javafx.application.LauncherImpl";