rut-galera opened a new issue, #9832:
URL: https://github.com/apache/netbeans/issues/9832
### Apache NetBeans version
Apache NetBeans 32
### What happened
I am a computer science and Java programming teacher in Spain.
During a Java programming exam, one of my students experienced an unexpected
problem with the NetBeans editor.
After introducing an invalid method parameter declaration involving an enum,
NetBeans stopped highlighting certain syntax errors in the source file.
For example, a missing semicolon was no longer reported. Neither the red
underline nor the error indicator in the editor's left margin appeared.
The issue has been successfully reproduced in a new project using the
minimal example below.
Expected behaviour
NetBeans should report both syntax errors:
• The missing semicolon after the variable declaration.
• The invalid method parameter declaration involving the enum keyword.
Invalid Java source code should not cause an internal parser failure or
prevent unrelated syntax errors from being displayed.
Actual behaviour
The Java source parser fails with an internal AssertionError, preventing
certain syntax errors from being displayed.
The following exception was recorded in the dump file generated during the
original incident:
java.lang.AssertionError
at com.sun.tools.javac.util.Assert.error(Assert.java:155)
at com.sun.tools.javac.util.Assert.check(Assert.java:46)
at com.sun.tools.javac.comp.Attr.attribIdentAsEnumType(Attr.java:948)
at com.sun.tools.javac.comp.MemberEnter.visitVarDef(MemberEnter.java:261)
The stack trace also includes:
org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase
org.netbeans.modules.java.source.parsing.JavacParser.getResult
Reproducibility
Confirmed in both:
• The original student's Maven project.
• A newly created Maven project containing the minimal reproduction
example provided above.
Confirmed workaround
Correcting the invalid enum parameter declaration immediately restores
normal syntax error detection.
### Language / Project Type / NetBeans Component
Java Maven Web application project
### How to reproduce
1. Create a new Java Maven project in NetBeans 31.
2. Introduce the following code:
public class TestEnum {
enum Circuito {
BASICO, INTERMEDIO, AVANZADO
}
public static void main(String[] args) {
int peso = 0
}
public static String pedirCircuito(enum Circuito) {
return "";
}
}
3. Observe that the missing semicolon is not reported by the editor.
4. Replace the invalid method declaration with:
public static String pedirCircuito(Circuito circuito) {
return "";
}
5. Observe that NetBeans resumes normal error detection and highlights the
missing semicolon.
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Windows 11
### JDK
Eclipse Adoptium OpenJDK 25.0.5
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
**Impact**
[Java editor stops reporting syntax errors after an invalid enum parameter
declaration.docx](https://github.com/user-attachments/files/35509964/Java.editor.stops.reporting.syntax.errors.after.an.invalid.enum.parameter.declaration.docx)
This issue is particularly relevant in educational environments, where
students frequently introduce invalid Java syntax while learning the language.
An internal parser failure prevents students from identifying unrelated
errors in their programs and may lead them to believe that their code is
syntactically correct.
Possibly related issue
NETBEANS-4296 – Assertion error in javac when enum definition follows
incomplete method.
https://issues.apache.org/jira/browse/NETBEANS-4296
The historical issue contains a similar stack trace involving
Attr.attribIdentAsEnumType. Whether both issues share the same root cause
remains to be determined.
Thank you for your work on Apache NetBeans.
### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists