JEL 477 Issue

Jan Lahoda jan.lahoda at oracle.com
Tue Aug 13 11:56:38 UTC 2024


On 13. 08. 24 13:22, Olexandr Rotan wrote:

> I actually had a similar issue quite a while ago, when I wrote tests 
> for https://bugs.openjdk.org/browse/JDK-8332497. 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.


Could you please be more specific about the relevant parts in the PR? I 
went through it twice, but sadly don't see much that would be relevant. 
(I believe this report is specifically about sub-optimal error recovery 
and reporting for implicitly declared classes.)


Thanks,

     Jan


>
> On Tue, Aug 13, 2024 at 2:06 PM Magnus Ihse Bursie 
> <magnus.ihse.bursie at oracle.com> wrote:
>
>     If this is something that should be fixed, do we have a JBS issue
>     tracking it?
>
>     /Magnus
>
>     On 2024-07-30 19:43, Jonathan Gibbons wrote:
>>
>>     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.
>>
>>     -- Jon
>>
>>
>>     On 7/30/24 9:57 AM, Remi Forax wrote:
>>>
>>>
>>>     ------------------------------------------------------------------------
>>>
>>>         *From: *"Jaikiran Pai" <jai.forums2013 at gmail.com>
>>>         <mailto:jai.forums2013 at gmail.com>
>>>         *To: *"jdk-dev" <jdk-dev at openjdk.org>
>>>         <mailto:jdk-dev at openjdk.org>
>>>         *Sent: *Tuesday, July 30, 2024 5:43:34 PM
>>>         *Subject: *Re: JEL 477 Issue
>>>
>>>         > import module java.base;
>>>         >
>>>         > main() {
>>>         >
>>>         >    println("Moose");
>>>         >
>>>         >}
>>>
>>>         It appears that you are missing a "void" return type before
>>>         the main() method name. As noted in the JEP-477, it should be:
>>>
>>>         import module java.base;
>>>         void main() {
>>>             println("Moose");
>>>         }
>>>
>>>
>>>     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).
>>>
>>>     @Ken, you do not need to import module java.base, it's done by
>>>     default and --source 23 is not needed anymore since 23.
>>>
>>>
>>>         -Jaikiran
>>>
>>>
>>>     regards,
>>>     Rémi
>>>
>>>
>>>         On 30/07/24 9:05 pm, omniprof at gmail.com wrote:
>>>
>>>             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.
>>>
>>>             *>> Here is the program*
>>>
>>>             import module java.base;
>>>
>>>             main() {
>>>
>>>                 println("Moose");
>>>
>>>             }
>>>
>>>             *>> Here is the version of Java I am running*
>>>
>>>             C:\dev\Onramptesting\OnRamptest\src>java --version
>>>
>>>             openjdk 23-ea 2024-09-17
>>>
>>>             OpenJDK Runtime Environment (build 23-ea+34-2361)
>>>
>>>             OpenJDK 64-Bit Server VM (build 23-ea+34-2361, mixed
>>>             mode, sharing)
>>>
>>>             *>> Here I run the code with all the required switches.
>>>             The errors are the same with or without Xlint*
>>>
>>>             C:\dev\Onramptesting\OnRamptest\src>javac
>>>             --enable-preview --source 23 -Xlint:preview Main.java
>>>
>>>             Main.java:1: warning: [preview] module imports are a
>>>             preview feature and may be removed in a future release.
>>>
>>>             import module java.base;
>>>
>>>                    ^
>>>
>>>             Main.java:3: error: class, interface, enum, or record
>>>             expected
>>>
>>>             main() {
>>>
>>>             ^
>>>
>>>             Main.java:5: error: class, interface, enum, or record
>>>             expected
>>>
>>>             }
>>>
>>>             ^
>>>
>>>             2 errors
>>>
>>>             1 warning
>>>
>>>             Note that I get the same results for –source 23 and
>>>             –release 23
>>>
>>>             Trying single file:
>>>
>>>             java –enable-preview Main.java
>>>
>>>             does not work as well.
>>>
>>>             Same result using Console or PowerShell in Windows.
>>>
>>>             What am I doing wrong?
>>>
>>>             Ken Fogel
>>>
>>>             omniprof at gmail.com
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20240813/29b4d19b/attachment.htm>


More information about the jdk-dev mailing list