12

I'm using Intellij IDEA for work on a Java project.

I'm finding I get a lot of false positives when I build in Intellij, but only when there are other compilation errors - e.g. I've made a change and expect a number of compile errors, so I build to find all the errors. (In this instance, I changed a widely used interface, and want the compiler to catch the errors so that I know which implementations to fix.) In addition to some of these expected errors, Intellij reports hundreds of false positives (which makes it difficult to find the real errors - at present the compiler is showing only one genuine compile error each time, so I have to rebuild to find the next error...). These false compile errors are not highlighted - indeed, they are not real compile errors. (Nor do they appear if I compile via Maven.)

The most common error is 'cannot find symbol class [X]', despite that class often being in the same project.

I've tried: - upgrading Intellij (from 10.5.1 to 10.5.2 to 11.0.1) - invalidating and rebuilding caches - restarting Intellij ...but all to no effect.

I've searched the Intellij Bug Tracking board, but haven't found any reference to this there, so wondered whether this is user error (if so, what settings do I need to change)?

Has anyone else experienced anything like this? If so, how did you fix it?

amaidment
  • 6,942
  • 5
  • 52
  • 88
  • I would call a false error message a *false negative*. A *false positive* would be code which apparently compiles in IntelliJ but doesn't. I have seen this from time to time and reported the bug to Jetbrains, but never enough to cause a problem. – Peter Lawrey Jan 12 '12 at 11:21
  • @amaidment: I'm rarely leaving lots of classes in a state that do not compile but, indeed, I do see something similar (although maybe not identical) since, well, literally years. For example on desktop apps, where I'm using IntelliJ's GUI builder, if I have only *one* class that doesn't compile and try to recompile everything, I'll get a **lot** of the following errors: *"... Form. Class to bind does not exist: ...View"*. I think that basically I get this message for every single GUI built using IntelliJ's GUI builder. Once again, as my projects typically compile, it's not an issue :-/ – TacticalCoder Jan 12 '12 at 11:56
  • @user988052, congratulations. My projects are also normally compiling. Indeed, I don't want to be in a state where the code doesn't compile... but occassionally one has to make a change that could cause lots compile errors (as per my edit, in this case, by changing a widely used interface) - it's those real compile errors that I want to fix, but Intellij's spurious error reporting means it is only reporting one real error per build... – amaidment Jan 12 '12 at 18:45
  • why are you changing interfaces manually and not using the automatic refactoring tools which would completely eliminate the human error –  Jan 12 '12 at 18:47
  • @Jarrod what are the automatic refactoring tools for interfaces/implementations in Intellij? – amaidment Feb 10 '12 at 10:15

2 Answers2

8

This is probably too late to help you, but maybe it will help somebody else. I had a similar problem. IntelliJ complained that it couldn't find a symbol class, and the class it couldn't find had an icon with a little x in the upper left hand corner. The x indicates that the class was excluded from compilation. (I have no idea how that happened.)

To include the excluded file, access project settings, e.g., by clicking Ctrl+Alt+S. Then you can modify the list found under Project Settings -> Compiler -> Excludes, to re-include the excluded file.

kc2001
  • 5,008
  • 4
  • 51
  • 92
3

Such issue can be caused by incorrect project configuration, like when some module source directories are added to the dependencies as library roots. If you can't find a problem yourself, either contact support or file a bug to YouTrack with a sample project attached and the steps to reproduce the problem.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904