netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

NetBean java ide exception - fails to parse code

Open shoblingr opened this issue 3 years ago • 7 comments

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

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

shoblingr avatar Jul 01 '22 14:07 shoblingr

In case it is needed, here is the Test_6.dump file Test_6.zip

shoblingr avatar Jul 01 '22 14:07 shoblingr

Any news ?

shoblingr avatar Jul 12 '22 08:07 shoblingr

I got the following issue do you have the project instead of only the java class ? windows 11, maven project with Test.java in default package, maven compiler set up for jdk 17. I have no parsing error. Test.java:[31,9] method get in class Test cannot be applied to given types; required: java.util.function.Function<java.lang.String,Test.MyClass>,boolean found: (str)->foo(str) reason: actual and formal argument lists differ in length 1 error

ebarboni avatar Jul 12 '22 09:07 ebarboni

Thanks for the answer! Please find attached the full project folder interviews.zip .

shoblingr avatar Jul 12 '22 14:07 shoblingr

@ebarboni, maybe I was not clear, if i compile I have the same error. The issue is the live code analysis, it should produce a red marker on saving the file indicating the project will not compile, instead because of the bug nothing is shown.

shoblingr avatar Jul 13 '22 12:07 shoblingr

Are you able to reproduce the issue ?

shoblingr avatar Jul 19 '22 07:07 shoblingr

sorry for the delay maybe @jlahoda can help on this. Seems also related to #4341 or #4344

ebarboni avatar Jul 26 '22 15:07 ebarboni