Open
Description
Java 21 introduces (as a preview) support for instance main methods and for main methods (static or instance) that have no parameters:
Selecting a main method
When launching a class, the launch protocol chooses the first of the following methods to invoke:
- A
static void main(String[] args)
method of non-private access (i.e., public, protected or package) declared in the launched class,- A
static void main()
method of non-private access declared in the launched class,- A
void main(String[] args)
instance method of non-private access declared in the launched class or inherited from a superclass, or, finally,- A
void main()
instance method of non-private access declared in the launched class or inherited from a superclass.
To support these new main methods, some changes will be required in Boot:
MainClassFinder
, as used by our Maven and Gradle plugins (and Antlib), only looks forpublic static void main(String[] args)
methods at the momentMainMethodRunner
, as used by our launchers, only supports running astatic main(String[])
method at the moment- DevTools ( see
MainMethod
), only supportsstatic main(String[])
methods when finding the method to use for restart at the moment