apache / apache/netbeans

NetBean java ide exception - fails to parse code

Open
#4,309 7 comments 0 reactions 0 assignees View on GitHub
Java kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 14

### What happened

this attached java code cannot be parsed by netbean and this error is reported

```
Annotation: An error occurred during parsing of 'C:\dev\projects\interviews\src\main\java\Test.java'. Please report a bug against java/source and attach dump file 'C:\Users\a184004\AppData\Roaming\NetBeans\14\var\log\Test_6.dump'.
An error occurred during parsing of 'C:\dev\projects\interviews\src\main\java\Test.java'. Please report a bug against java/source and attach dump file 'C:\Users\a184004\AppData\Roaming\NetBeans\14\var\log\Test_6.dump'.
Caused by: java.lang.IllegalStateException: java.lang.ClassCastException
at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383)
at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:770)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:540)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:141)
at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:608)
at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:239)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:775)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
Caused by: java.lang.ClassCastException
An error occurred during parsing of 'C:\dev\projects\interviews\src\main\java\Test.java'. Please report a bug against java/source and attach dump file 'C:\Users\a184004\AppData\Roaming\NetBeans\14\var\log\Test_6.dump'.
```
[Test.zip](https://github.com/apache/netbeans/files/9029449/Test.zip)

### How to reproduce

just open Test.java in Netbean to reproduce the issue

### Did this work correctly in an earlier version?

No

### Operating System

Windows 10

### JDK

jdk-17.0.3+7

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

_No response_

### Are you willing to submit a pull request?

No

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Start by opening the attached Test.java in Apache NetBeans 14 on Windows with JDK 17. Reproduce the failure and inspect the java/source parsing path, especially JavacParser.moveToPhase and the reported Java compiler stack trace; done means the file parses without the ClassCastException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.