<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Hello Tagir,</div><div>for me, you need another template, let's call it "main", which is a little smarter than psvm.</div><div><br data-mce-bogus="1"></div><div>First, i would keep "psvm" as is, because psvm literally means "public static void main" so the intent of the user is clear.</div><div>Then for the new template "main", i would take a look if main is invoked inside a class or not, if it's inside a class, I think "static void main" is a good default with public being added if the class itself is public.</div><div>If there is no enclosing class, "void main" is a good default.</div><div><br data-mce-bogus="1"></div><div>Now, about adding the String parameter, i would if calling main should not result with the method main be generated (using the rule above) and the caret is in between the two parenthesis of the main,</div><div>if a character is typed, then String[] is added and the character is the first character of the parameter, if the compeltion is used, the name "args" can be added, otherwise, the caret if moved inside the method.</div><div><br data-mce-bogus="1"></div><div>It's perhaps a little too smart for beginners, so perhaps the "smart insert" of the argument should only occur when there is a class ?</div><div><br data-mce-bogus="1"></div><div>regards,</div><div>RĂ©mi</div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Tagir Valeev" <amaembo@gmail.com><br><b>To: </b>"amber-spec-experts" <amber-spec-experts@openjdk.org><br><b>Sent: </b>Thursday, May 8, 2025 10:32:24 AM<br><b>Subject: </b>Simplified main methods -- what IDE users should expect?<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr">Hello, dear experts!<br><br><div>This discussion is not exactly about Java specification, but I think we have the right people here for this topic.</div><br><div>The Java IDEs usually provide a way to automatically generate a main method using some kind of template named 'main' or 'psvm' (which is short for 'public static void main'). Historically, invoking such a template generated a code like this:</div><br><div>public static void main(String[] args) {</div><div>  <caret is here></div><div>}</div><br><div>However, when 'Compact Source Files and Instance Main Methods' feature (JEP 512) is available, this doesn't look like a good default anymore. Some of our colleagues advocate that keeping the old signature is good because this is what people get used to, but I think we should reconsider this.</div><br><div>Now we have multiple ways to generate a main method:</div><div>- 'public' may be present or not</div><div>- 'static' may be present or not</div><div>- 'String[] args' may be present or not</div><br><div>So technically we have eight different variants. What would the user expect by default?</div><br><div>In my opinion, 'public' is simple: we should just drop it, as it doesn't add any value. This reduces the number of options to four.</div><br><div>The 'static' modifier is more difficult. 'static void main()' and 'void main()' have different semantics: the latter involves automatic class instantiation, it makes the main() method inheritable (so inheritors if any may become launchable), and it requires a no-arg constructor. We cannot generate `void main(){}` inside the class that contains no default constructor, as this method will be non-functional and users might be surprised and confused. We might consider adding the `static` modifier only in classes without no-arg constructor, but this might be inconsistent, as users might not understand why sometimes `static` is generated and sometimes is not. Another case is implicit classes where `static` looks really alien, and we never have problems like no-arg constructors or inheritors. So I lean toward generating 'static' by default for explicit classes (regardless of its constructors) and no 'static' for implicit classes. However, I'm not sure that it's the best solution.</div><br><div>Skipping 'String[] args' by default seems nice, but it will worsen the experience of people who actually need the args, as they will probably need to type more. We can assume that the variable named 'args' is implicitly available inside the method body, so the user may use it via autocompletion, and upon the first use, it will be automatically added to the method signature. This is possible but somewhat weird: users should know in advance that something named 'args' can be used, even if it's not explicitly available in the code.</div><br><div>We can also create several templates (something like 'maina' for main with arguments and 'mains' for static main), but this also complicates things and increases the cognitive load to the users. Also, different IDEs may solve this differently, and this may add confusion for people who change IDE sometimes.</div><br><div>I would be glad to hear your opinions. What would you expect from your IDE when generating a main method in Java 25?</div><br><div>With best regards,</div><div>Tagir Valeev</div></div><br></blockquote></div></div></body></html>