netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

NullPointerException in compiler, Java files with red error badges can't be run

Open bernard01 opened this issue 3 years ago • 0 comments

Apache NetBeans version

Apache NetBeans 15

What happened

At NetBeans startup with a project group containing a single project, after the cache was deleted. The problem occurred before. That is why I deleted the cache.

The project where the exception occurs worked before for a long time just a few weeks ago. Now it is broken and I cannot work with it.

The project compiles without errors when compiled from the Projects window context menu.

The "broken" java files are in the unit test hierarchy of a Maven project.

I cannot navigate to the "broken" java files highlighted in red. But when I copy the name of such a file and use "Go to Type" to navigate to it then that works, and the file it navigates to is good.

I may be able to provide more info, but this will require some work. So I wait and see whether something obvious can be discovered from the log.

Product Version: Apache NetBeans IDE 15 Java: 14; Java HotSpot(TM) 64-Bit Server VM 14+36-1461 Runtime: Java(TM) SE Runtime Environment 14+36-1461 System: Windows 7 version 6.1 running on amd64; Cp1252; en_NZ (nb) User directory: C:\Users\user\AppData\Roaming\NetBeans\15 Cache directory: C:\Users\user\AppData\Local\NetBeans\Cache\15

java.lang.NullPointerException
	at com.sun.tools.javac.tree.TreeInfo.declarationFor(TreeInfo.java:792)
	at com.sun.tools.javac.model.JavacElements.getTreeAndTopLevel(JavacElements.java:769)
	at com.sun.tools.javac.model.JavacElements.getTreeAndTopLevel(JavacElements.java:789)
	at com.sun.tools.javac.api.JavacTrees.getPath(JavacTrees.java:337)
	at com.sun.tools.javac.api.JavacTrees.getPath(JavacTrees.java:327)
	at org.netbeans.lib.nbjavac.services.NBJavacTrees.getPath(NBJavacTrees.java:56)
	at org.netbeans.modules.java.source.indexing.VanillaCompileWorker$2.run(VanillaCompileWorker.java:352)
	at org.netbeans.modules.java.source.parsing.FileManagerTransaction.runConcurrent(FileManagerTransaction.java:180)
[catch] at org.netbeans.modules.java.source.indexing.VanillaCompileWorker.compile(VanillaCompileWorker.java:342)
	at org.netbeans.modules.java.source.indexing.JavaCustomIndexer.index(JavaCustomIndexer.java:360)
	at org.netbeans.modules.parsing.spi.indexing.Indexable$MyAccessor$2.run(Indexable.java:138)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runIndexer(RepositoryUpdater.java:274)
	at org.netbeans.modules.parsing.spi.indexing.Indexable$MyAccessor.index(Indexable.java:136)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.doIndex(RepositoryUpdater.java:2749)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.lambda$index$0(RepositoryUpdater.java:2626)
	at org.netbeans.modules.parsing.impl.indexing.errors.TaskCache.refreshTransaction(TaskCache.java:540)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.index(RepositoryUpdater.java:2625)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$AbstractRootsWork.lambda$scanSource$3(RepositoryUpdater.java:5735)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.lambda$runInContext$4(RepositoryUpdater.java:2119)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runInContext(RepositoryUpdater.java:2117)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runInContext(RepositoryUpdater.java:2098)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.access$1400(RepositoryUpdater.java:135)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$AbstractRootsWork.scanSource(RepositoryUpdater.java:5770)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$AbstractRootsWork.scanSources(RepositoryUpdater.java:5443)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$RootsWork.getDone(RepositoryUpdater.java:5075)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$InitialRootsWork.getDone(RepositoryUpdater.java:5842)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.doTheWork(RepositoryUpdater.java:3452)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task._run(RepositoryUpdater.java:6197)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task.access$3400(RepositoryUpdater.java:5855)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.lambda$call$0(RepositoryUpdater.java:6116)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279)
	at org.netbeans.modules.parsing.impl.RunWhenScanFinishedSupport.performScan(RunWhenScanFinishedSupport.java:83)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.call(RepositoryUpdater.java:6116)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.call(RepositoryUpdater.java:6112)
	at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
	at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335)
	at org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118)
	at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task.run(RepositoryUpdater.java:6112)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	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)

How to reproduce

I may be able to provide a reproducible test case. But perhaps I may not be able to because from experience, after simplifying projects to a test case, the problem often disappears. messages.log

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 7

JDK

Java 14

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Code of Conduct

Yes

bernard01 avatar Oct 11 '22 01:10 bernard01