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 for public static void main(String[] args) methods at the moment
  • MainMethodRunner, as used by our launchers, only supports running a static main(String[]) method at the moment
  • DevTools ( see MainMethod), only supports static main(String[]) methods when finding the method to use for restart at the moment

Comment From: rafaelrc7

Hello, is this issue available for work?

Comment From: wilkinsona

Thanks for the offer, @rafaelrc7, but not yet. We haven't decided when to schedule this. As the support is only in preview at the moment, we may wait for it to be delivered in its final form before doing anything.