JDK-8169289 : JavaFX application in named module fails to launch if no main method
  • Type: Bug
  • Component: javafx
  • Sub-Component: application-lifecycle
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-11-05
  • Updated: 2016-12-01
  • Resolved: 2016-11-21
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.
JDK 9
9 b147Fixed
Related Reports
Blocks :  
Relates :  
Description
The attached test program launches and runs fine in the unnamed module. If it is packaged and run as a modular application, then it fails to launch.

Steps to reproduce:

1. Compile the attached test program as a module:

javac --module-source-path src -d build/classes src/mymod/module-info.java src/mymod/simple/Simple.java

2. Run the test program as a modular application:

java --module-path build/classes -m mymod/simple.Simple

It will fail with the following exception:

Error: Main method not found in class simple.Simple, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

Comments
Changeset: f58c774610ac Author: ddehaven Date: 2016-11-10 09:10 -0800 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/f58c774610ac
21-11-2016

Looks good.
21-11-2016

The .1 version of the FX webrev looks good to me. +1
17-11-2016

noreg-external as the unit tests will be added to openjfx
10-11-2016

Webrevs (both openjfx and openjdk): http://cr.openjdk.java.net/~ddehaven/8169289
10-11-2016

JavaFX needs java.lang.reflect.Module to do this work, which doesn't exist in JDK 9+b109
08-11-2016

The error message reported is java.launcher.cls.error4 in LauncherHelper.java, this is only reported in validateMainMethod All FX apps are routed through LauncherHelper$FXHelper class to trampoline to LauncherImpl in javafx.graphics, whether there's a main method or not. Doing this allows LauncherImpl to do any setup necessary before the main class is handed control. So the path that's failing is LauncherHelper->FXHelper->LauncherImpl.
07-11-2016

A new launch method (LM_MODULE) was added for jigsaw, it appears neither FXHelper nor LauncherImpl were updated to handle this case, which could explain this. In the case of LM_MODULE (triggered by -m <module>/*) the setFXLaunchParameters method will throw an exception, which I believe is causing the validateMainMethod check to fail. So, this needs to be fixed in both JDK and FX
07-11-2016

Note that if you uncomment the main(String[]) method then it works as a modular application with no problems. This is likely a bug in the JavaFX application launch code but could be a bug in the Java launcher.
05-11-2016