Integrated: JDK-8328339: Static import prevents source launcher from finding class with main method

Christian Stein cstein at openjdk.org
Fri Mar 22 05:32:27 UTC 2024


On Mon, 18 Mar 2024 09:49:19 GMT, Christian Stein <cstein at openjdk.org> wrote:

> Please review this fix for finding the program class in case the first top-level type has no main method and the order of type compilation does not match the order in the source file - for example by a static import statement being present.
> 
> Here's an excerpt from [JEP 458](https://openjdk.org/jeps/458#Launch-time-semantics-and-operation)'s "Launch-time semantics and operation" section describing the process:
>> 5. Determine the launch class of the initial .java file. If the first top level class in the initial file declares a standard main method (`public static void main(String[])` or other standard main entry points as defined in [JEP 463](https://openjdk.org/jeps/463#A-flexible-launch-protocol)), then that class is the launch class. Otherwise, if another top level class in the initial file declares a standard main method and has same name as the file, that class is the launch class. Otherwise, there is no launch class, and the launcher reports an error and stops.
> 
> Tested tier1-tier3: ✅

This pull request has now been integrated.

Changeset: 9bc741d0
Author:    Christian Stein <cstein at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/9bc741d04f0c2e731f67ac21144812a55d0ea03d
Stats:     97 lines in 4 files changed: 44 ins; 30 del; 23 mod

8328339: Static import prevents source launcher from finding class with main method

Reviewed-by: jlahoda

-------------

PR: https://git.openjdk.org/jdk/pull/18345


More information about the compiler-dev mailing list