mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8329581: Java launcher no longer prints a stack trace
8329420: Java 22 (and 23) launcher calls default constructor although main() is static 8330864: No error message when ExceptionInInitializerError thrown in static initializer Reviewed-by: stuefe
This commit is contained in:
parent
789f704d9a
commit
cbb6747e6b
4 changed files with 341 additions and 42 deletions
|
@ -904,6 +904,9 @@ public final class LauncherHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static boolean isStaticMain = false;
|
||||
private static boolean noArgMain = false;
|
||||
|
||||
// Check the existence and signature of main and abort if incorrect.
|
||||
private static void validateMainMethod(Class<?> mainClass) {
|
||||
Method mainMethod = null;
|
||||
|
@ -927,19 +930,19 @@ public final class LauncherHelper {
|
|||
}
|
||||
|
||||
int mods = mainMethod.getModifiers();
|
||||
boolean isStatic = Modifier.isStatic(mods);
|
||||
isStaticMain = Modifier.isStatic(mods);
|
||||
boolean isPublic = Modifier.isPublic(mods);
|
||||
boolean noArgs = mainMethod.getParameterCount() == 0;
|
||||
noArgMain = mainMethod.getParameterCount() == 0;
|
||||
|
||||
if (!PreviewFeatures.isEnabled()) {
|
||||
if (!isStatic || !isPublic || noArgs) {
|
||||
if (!isStaticMain || !isPublic || noArgMain) {
|
||||
abort(null, "java.launcher.cls.error2", mainClass.getName(),
|
||||
JAVAFX_APPLICATION_CLASS_NAME);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isStatic) {
|
||||
if (!isStaticMain) {
|
||||
String className = mainMethod.getDeclaringClass().getName();
|
||||
if (mainClass.isMemberClass() && !Modifier.isStatic(mainClass.getModifiers())) {
|
||||
abort(null, "java.launcher.cls.error7", className);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue