Problem using JavaFX Application class

Alan Bateman Alan.Bateman at oracle.com
Wed Feb 24 08:46:01 UTC 2016


On 23/02/2016 23:21, Sander Mak wrote:
> :
>
> However, is such an application class really something I want to export to other modules? Of course using a qualified export the scope can be restricted to the javafx.graphics module, and that's what I ended up doing.
In the early exploration phase of Project Jigsaw then modules could 
declare entry points. It worked okay for the `public static void main` 
cases but it wasn't really general purpose enough. There were 
suggestions to use services for entry points at the time too. Things 
have been significantly simplified since then and there aren't entry 
points in the current proposal.


> In general, I think it's interesting  that many frameworks want reflective access to what are essentially internal implementation classes. Spring comes to mind, you'd want to export interfaces but not Spring bean implementation classes, even though the framework needs access to instantiate them.
Indeed and I'm sure Mark will bring proposals around this to the JSR soon.


> As has been discussed before on this list, ServiceLoader has a special super-power in this regard, and I sort of expected JavaFX Application handling to have that same superpower for instantiating the Application class.
There isn't any notion of "superpower" as such. Instead, think of it as 
a special type of access check where access is checked to the service 
type (the super type) rather than the implementation type.

>
> One more follow-up question: when I remove the main() method that invokes launch (see here: https://bitbucket.org/sandermak/javafx-application/diff/src/applicationmodule/application/Main.java?diff2=fca74ffbc28d&at=without-main), the following error comes up (build 9-ea+106-jigsaw-nightly-h4498-20160221):
>
> Error: Main method not found in class application.Main, please define the main method as:
>     public static void main(String[] args)
> or a JavaFX application class must extend javafx.application.Application
>
I hope Kevin or David can answer this but assuming this is output from 
`java -m` then it will be because that doesn't locate FX entry point 
(unlike `java -jar`). This may be something that needs to be fixed.

-Alan



More information about the jigsaw-dev mailing list