8248122: java launcher should launch normally if JavaFX modules not found

Reviewed-by: kcr, prr, aivanov
This commit is contained in:
Christopher Schnick 2026-05-13 17:42:54 +00:00 committed by Alexey Ivanov
parent 9be6e77d73
commit f59ee5acfc

View File

@ -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";