RFR: JDK-8328339: Static import prevents source launcher from finding class with main method
Christian Stein
cstein at openjdk.org
Mon Mar 18 10:55:52 UTC 2024
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.
-------------
Commit messages:
- JDK-8328339: Static import prevents source launcher from finding class with main method
Changes: https://git.openjdk.org/jdk/pull/18345/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18345&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8328339
Stats: 27 lines in 2 files changed: 25 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/18345.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/18345/head:pull/18345
PR: https://git.openjdk.org/jdk/pull/18345
More information about the compiler-dev
mailing list