<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">I think I'm closer to Tagir on
this one. We have never tried to warn the user when they mangle
the "main" entry point before; we didn't warn on <br>
<br>
void main(String[] args) // no static<br>
<br>
or<br>
<br>
static void main() // no args<br>
<br>
or<br>
<br>
static void main(Sling[] args) // wrong args type<br>
<br>
<br>
These were all valid Java method declarations, but might not do
what the author expected, because the launch protocol has always
been nearly extralinguistic. This JEP doesn't really bring the
launch protocol that much more into the spotlight. <br>
<br>
I do think it is fair game for an IDE inspection, though (as if
Tagir doesn't already have one.)<br>
<br>
</font></font><br>
<div class="moz-cite-prefix">On 9/18/2023 12:47 PM, Alex Buckley
wrote:<br>
</div>
<blockquote type="cite" cite="mid:7a7d2695-3474-4ff3-8b88-80300553bea9@oracle.com">Traditionally,
`void main()` was not an entrypoint, but under JEP 445, it is.
This is a source compatible change, but not a behaviorally
compatible change. For example, consider a slightly modified
example:
<br>
<br>
class MissingWarningsSuper {
<br>
public static void main(String[] args) {}
<br>
}
<br>
<br>
class MissingWarnings extends MissingWarningsSuper {
<br>
void main() {}
<br>
}
<br>
<br>
Traditionally, `java MissingWarnings` would have run the inherited
static main. Under JEP 445, `java MissingWarnings` will run the
declared instance main. (JLS 12.1.4 has a nice discussion of this
policy.)
<br>
<br>
I think a preview warning is appropriate in order to highlight the
new role enjoyed by various methods called "main".
<br>
<br>
Alex
<br>
<br>
On 9/18/2023 7:17 AM, Tagir Valeev wrote:
<br>
<blockquote type="cite">But this code is a perfectly valid code in
non-preview Java version
<br>
(unless you try to launch this class, but you don't know this
during
<br>
the compilation). I don't think there should be a warning.
<br>
<br>
With best regards,
<br>
Tagir Valeev.
<br>
<br>
On Mon, Sep 18, 2023 at 9:37 AM Remi Forax
<a class="moz-txt-link-rfc2396E" href="mailto:forax@univ-mlv.fr"><forax@univ-mlv.fr></a> wrote:
<br>
<blockquote type="cite">
<br>
Hello,
<br>
I believe this code should emit a warning when compiled given
it uses an instance main method
<br>
<br>
class MissingWarnings {
<br>
void main() {
<br>
}
<br>
}
<br>
<br>
But the command
<br>
javac --enable-preview --source 21 MissingWarnings.java
<br>
does not print a warning.
<br>
<br>
regards,
<br>
Rémi
<br>
</blockquote>
</blockquote>
</blockquote>
<br>
</body>
</html>