<div dir="ltr">I actually had a similar issue quite a while ago, when I wrote tests for <a href="https://bugs.openjdk.org/browse/JDK-8332497">https://bugs.openjdk.org/browse/JDK-8332497</a>. but thought it was an issue with jtreg. If you go to related PR, you could see long rants about test failing with similar error. Not sure if it would be helpful, but whoever will take on this issue could also look into this PR for extra test case and anything else one might find useful.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 13, 2024 at 2:06 PM Magnus Ihse Bursie <<a href="mailto:magnus.ihse.bursie@oracle.com">magnus.ihse.bursie@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<p>If this is something that should be fixed, do we have a JBS issue
tracking it?</p>
<p>/Magnus<br>
</p>
<div>On 2024-07-30 19:43, Jonathan Gibbons
wrote:<br>
</div>
<blockquote type="cite">
<p>Even without special-casing `main`, the error message is
misleading because it says `class, interface, enum, or record
expected` and does not admit the possibility of `void` in this
particular circumstance.</p>
<p>-- Jon</p>
<p><br>
</p>
<div>On 7/30/24 9:57 AM, Remi Forax wrote:<br>
</div>
<blockquote type="cite">
<div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div><br>
</div>
<div><br>
</div>
<hr id="m_6296078229940487285zwchr">
<div>
<blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From:
</b>"Jaikiran Pai" <a href="mailto:jai.forums2013@gmail.com" target="_blank"><jai.forums2013@gmail.com></a><br>
<b>To: </b>"jdk-dev" <a href="mailto:jdk-dev@openjdk.org" target="_blank"><jdk-dev@openjdk.org></a><br>
<b>Sent: </b>Tuesday, July 30, 2024 5:43:34 PM<br>
<b>Subject: </b>Re: JEL 477 Issue<br>
</blockquote>
</div>
<div>
</div>
<div>
<blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt">
<p>> import module java.base;<br>
><br>
> main() {<br>
><br>
> println("Moose");<br>
><br>
>}</p>
<p>It appears that you are missing a "void" return type
before the main() method name. As noted in the JEP-477,
it should be:</p>
<p>import module java.base;<br>
void main() {<br>
println("Moose");<br>
}</p>
</blockquote>
<div><br>
</div>
<div>that said, if we want beginners to be able to use that
syntax, the error message should be changed because the
current message is misleading and not very helpfull (javac
should recognize "main" and have a tailored error
message).<br>
</div>
<div><br>
</div>
<div>@Ken, you do not need to import module java.base, it's
done by default and --source 23 is not needed anymore
since 23.<br>
</div>
<div><br>
</div>
<blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt">
<p><br>
</p>
<p>-Jaikiran</p>
</blockquote>
<div><br>
</div>
<div>regards,<br>
</div>
<div>Rémi<br>
</div>
<div><br>
</div>
<blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt">
<p><br>
</p>
<div>On 30/07/24 9:05 pm, <a href="mailto:omniprof@gmail.com" target="_blank">omniprof@gmail.com</a> wrote:<br>
</div>
<blockquote>
<div>
<p class="MsoNormal">I apologize for posting what is
likely a trivial question that may be inappropriate
for this list but I cannot find anywhere in my
searches to explain what is going wrong. Simply put
JEP 477 does not work in the pre-release version of
Java 23 on a Windows 11 PC. There is a lot written
that all show a similar example.</p>
<p class="MsoNormal"><b>>> Here is the program</b></p>
<p class="MsoNormal">import module java.base;</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">main() {</p>
<p class="MsoNormal"> println("Moose");</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b>>> Here is the version
of Java I am running</b></p>
<p class="MsoNormal">C:\dev\Onramptesting\OnRamptest\src>java
--version</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">openjdk 23-ea 2024-09-17</p>
<p class="MsoNormal">OpenJDK Runtime Environment
(build 23-ea+34-2361)</p>
<p class="MsoNormal">OpenJDK 64-Bit Server VM (build
23-ea+34-2361, mixed mode, sharing)</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b>>> Here I run the code
with all the required switches. The errors are the
same with or without Xlint</b></p>
<p class="MsoNormal">C:\dev\Onramptesting\OnRamptest\src>javac
--enable-preview --source 23 -Xlint:preview
Main.java</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Main.java:1: warning: [preview]
module imports are a preview feature and may be
removed in a future release.</p>
<p class="MsoNormal">import module java.base;</p>
<p class="MsoNormal"> ^</p>
<p class="MsoNormal">Main.java:3: error: class,
interface, enum, or record expected</p>
<p class="MsoNormal">main() {</p>
<p class="MsoNormal">^</p>
<p class="MsoNormal">Main.java:5: error: class,
interface, enum, or record expected</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal">^</p>
<p class="MsoNormal">2 errors</p>
<p class="MsoNormal">1 warning</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Note that I get the same results
for –source 23 and –release 23</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Trying single file:</p>
<p class="MsoNormal">java –enable-preview Main.java</p>
<p class="MsoNormal">does not work as well.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Same result using Console or
PowerShell in Windows.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">What am I doing wrong? </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Ken Fogel</p>
<p class="MsoNormal"><a href="mailto:omniprof@gmail.com" target="_blank">omniprof@gmail.com</a><br>
</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
</div>
</blockquote>
<br>
</blockquote>
</div>
</div>
</blockquote>
</blockquote>
</div>
</blockquote></div>