JDK-8248122 : java.base should not handle JavaFX application in a specific way
  • Type: Bug
  • Component: javafx
  • Sub-Component: application-lifecycle
  • Affected Version: openjfx11
  • Priority: P5
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2020-06-19
  • Updated: 2020-11-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Can be reproduced with any Java version 11+ and JavaFX 11+ on any OS

A DESCRIPTION OF THE PROBLEM :
When using Java 11+ with JavaFX dependencies on the classpath an JavaFX application can not be started. With Java 11+ JavaFX is only useable when it is on the module-path. This is not an issue regarding JavaFX but Java / OpenJDK. JavaFX would work from the classpath. The cause of the problems is in the sun.launcher.LauncherHelper class that is part of the java.base module. This class checks ff the main class of a started application extends the ������������javafx.application.Application������������ class. If this is the case the application will only start if the ������������javafx.graphics������������ is in the module-path (see sun.launcher.LauncherHelper.FXHelper.setFXLaunchParameters). If the module can not be found the application ends with System.exit(1) and an error message.

Some information about the ������������javafx.application.Application������������ class: This class defines the default lifecycle of a JavaFX application. Therefore a lot of applications directly extend this class for the main class of the application.

From my point of view such behaviour must not be part of the java.base module. Once JavaFX was removed from the JDK all references should have gone. If JavaFX would only be useable if it is on the moduelpath this must be check by JavaFX and not by OpenJDK. To be true  it is not possible to have JavaFX on the module-path. You can easily create a basic main class that does not extend ������������javafx.application.Application������������ and call the main of a class that extend ������������javafx.application.Application������������ internally. By doing so an application would work. But this is really an ugly workarounds (see https://github.com/karakun/OpenWebStart/blob/master/documentation/faq/FAQ.adoc#how-to-run-openjfx-based-javafx-applications-with-openwebstart for a sample).


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an Java application and add JavaFX (javafx.graphics-win for example) to the class path

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Application starts normally
ACTUAL -
application ends (System.exit(1))

---------- BEGIN SOURCE ----------
see https://github.com/karakun/OpenWebStart/blob/master/documentation/faq/FAQ.adoc#how-to-run-openjfx-based-javafx-applications-with-openwebstart
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
see https://github.com/karakun/OpenWebStart/blob/master/documentation/faq/FAQ.adoc#how-to-run-openjfx-based-javafx-applications-with-openwebstart

FREQUENCY : always



Comments
There is (or was) more than this in terms of non-java base behaviour in the launcher. It was resposible for setting up a whole slew of things for the desktop module (which IS delivered) with OpenJDK. But rather than just ripping out support and breaking apps the answer was to find another way to make it work first. The same should be applied here. And FWIW nothing precludes some one bundling OpenJFX with OpenJDK if they want to. So maybe the answer needs to be to make it conditionally compiled so someone producing an OpenJDK with OpenJFX can enable it as part of their build.
31-10-2020

Further information from the submitter: From my point of view this issue is not related to JavaFX but to Java core. The sun.launcher.LauncherHelper class should not contain any specific code for JavaFX. That would be the same as adding Spring specific code to the OpenJDK. The sun.launcher.LauncherHelper class needs to be refactored and references to JavaFX needs to be removed.
24-07-2020

JavaFX 11 is intentionally delivered as modules. If it accidentally happens to work on the classpath, then it isn't by design nor it is supported. We are unlikely to address any bugs that might result from this use case.
26-06-2020