-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
Affects Version/s: 25
-
Component/s: specification
-
Fix Understood
JEP 512 reads:
"If the chosen method is static then the launcher invokes it.
Otherwise, the chosen method is an instance main method. The class must have a non-private constructor with no parameters. The launcher invokes that constructor and then invokes the chosen main method of the resulting object. If there is no such constructor then the launcher reports an error and terminates."
However:
{noformat}
samael:nutshell-examples ben$ java -version
openjdk version "25" 2025-09-16 LTS
OpenJDK Runtime Environment Temurin-25+36 (build 25+36-LTS)
OpenJDK 64-Bit Server VM Temurin-25+36 (build 25+36-LTS, mixed mode, sharing)
samael:nutshell-examples ben$ cat HelloWorld.java class HelloWorld {
private HelloWorld() {}
void main() {
System.out.println("Hello, World!");
}
}
samael:nutshell-examples ben$ java HelloWorld.java
Hello, World!
{noformat}
"If the chosen method is static then the launcher invokes it.
Otherwise, the chosen method is an instance main method. The class must have a non-private constructor with no parameters. The launcher invokes that constructor and then invokes the chosen main method of the resulting object. If there is no such constructor then the launcher reports an error and terminates."
However:
{noformat}
samael:nutshell-examples ben$ java -version
openjdk version "25" 2025-09-16 LTS
OpenJDK Runtime Environment Temurin-25+36 (build 25+36-LTS)
OpenJDK 64-Bit Server VM Temurin-25+36 (build 25+36-LTS, mixed mode, sharing)
samael:nutshell-examples ben$ cat HelloWorld.java class HelloWorld {
private HelloWorld() {}
void main() {
System.out.println("Hello, World!");
}
}
samael:nutshell-examples ben$ java HelloWorld.java
Hello, World!
{noformat}