-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntactic error missing when inserting a switch in enum body #7437
Comments
Well, NetBeans uses javac for parsing, and the same |
fixed the formatting a bit so that the log doesn't break the markup. thanks for providing the reproducer! |
Thanks 😉
Com os melhores cumprimentos,
***@***.***
From: Michael Bien ***@***.***>
Sent: Thursday, June 6, 2024 1:23 PM
To: apache/netbeans ***@***.***>
Cc: José Braz ***@***.***>; Author ***@***.***>
Subject: Re: [apache/netbeans] Syntactic error missing when inserting a switch in enum body (Issue #7437)
ATENÇÃO: Este email foi originado fora do IPS. Por favor, não clique em links nem abra anexos, a não ser que conheça o remetente e saiba que o seu conteúdo é seguro.
fixed the formatting a bit so that the log doesn't break the markup.
thanks for providing the reproducer!
—
Reply to this email directly, view it on GitHub<#7437 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BI6V33KGCMRQSS43WHP7CVLZGBIDNAVCNFSM6AAAAABI3KHIZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJSGI3TIOBZGU>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
@neilcsmith-net this doesn't seem to make a (big) difference unfortunately since IOEs are caught and rethrown as netbeans/java/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java Lines 535 to 539 in f6e7673
I quickly tested this using the reproducer and it would still end up in the notifications instead of the editor error annotations.
javac output for public enum EPOCH {
CLASSIC, CONTEMPORARY, NONE;
switch (this){ // (no sintactic error message on the left):
case CLASSIC : return "Classic";
case CONTEMPORARY : return "Contemporary";
default : return "None";
}
} is
btw |
Any progress? netbeans 23 with same problem |
Yes, there's progress. I believe this should be fixed in javac by: |
I quickly checked and this should be fixed by the next regular javac update #8037 (targets NB25) link to a dev build in case someone wants to test it https://github.com/apache/netbeans/actions/runs/12447221005/artifacts/2352100555 (link expires in ~7 days) |
Apache NetBeans version
Apache NetBeans 22
What happened
A student (students are great bug hunters) when asked to create a toString for an enum inserted a switch/case instruction directly in the enum body and it did not show any syntactic error ... instead, when compiling, it just throws an exception:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
It was great if netBeans could detect and show the syntactic error. I think the switch (){ } looks a lot like a method and something goes wrong when parsing.
Moreover, when trying to refactor/rename the file with the main class the following exception was thrown:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Below the messages.log file content (is there a way to submit a few files here, namely the project?)
Language / Project Type / NetBeans Component
Java with Ant
How to reproduce
1, create a project java with ant -> java application
2. create a class named ClassHasEnum
3. create an enum named EPOCH with values CLASSIC, CONTEMPORARY, NONE;
4. insert a switch in the enum body
5.
Add an attribute private EPOCH epoch to class ClassHasEnum
On main method create an ClassHasEnum object:
ClassHasEnum oa = new ClassHasEnum();
Menu Debug -> Debug Project (or Ctrl+F5) and the appError class appears missing
if you try shift+F11, yes it detects the syntactic error
Hope it helps improving "our" great IDE ;-)
All the best,
José
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows 10 and 11
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
Yes, everytime because is a syntactic error ;-)
Are you willing to submit a pull request?
No
The text was updated successfully, but these errors were encountered: