From bc7eb9f89f50447c2f5a7c51e0a3d9ba793353d7 Mon Sep 17 00:00:00 2001 From: Mikhail Pyltsin Date: Fri, 27 Jun 2025 16:16:17 +0200 Subject: [PATCH] [java] IDEA-375134 Can't run non-static main method for Java 21 Preview (cherry picked from commit f9d8a7a3b8b6f24ae8014ffb05b9b5b28ba9d3c0) (cherry picked from commit f0966f81713bd81f4128c2a1c1fbd717dc394682) IJ-MR-169535 GitOrigin-RevId: f9bfafb5e635f684d124d8fd4a7a5a996c6971e7 --- .../com/intellij/rt/execution/application/AppMainV2.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/java/java-runtime/src/com/intellij/rt/execution/application/AppMainV2.java b/java/java-runtime/src/com/intellij/rt/execution/application/AppMainV2.java index 22ec2bed388e..72c104a2c753 100644 --- a/java/java-runtime/src/com/intellij/rt/execution/application/AppMainV2.java +++ b/java/java-runtime/src/com/intellij/rt/execution/application/AppMainV2.java @@ -120,10 +120,12 @@ public final class AppMainV2 { * - MainMethodStatus.WithoutArgs: the method is the main method and does not accept any parameters */ private static MainMethodStatus getMainMethodStatus(Method method, MainMethodSearchMode mode) { - if ("main".equals(method.getName()) ) { + if ("main".equals(method.getName())) { if (!Modifier.isPrivate(method.getModifiers())) { if (mode == MainMethodSearchMode.ALL_METHOD || - (mode == MainMethodSearchMode.STATIC_METHOD && Modifier.isStatic(method.getModifiers()))) { + (mode == MainMethodSearchMode.STATIC_METHOD && Modifier.isStatic(method.getModifiers())) || + (mode == MainMethodSearchMode.NON_STATIC_METHOD && !Modifier.isStatic(method.getModifiers())) + ) { Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0] == String[].class) { return MainMethodStatus.WithArgs;