editor does not find library containing @NotNull annotation

I created a simple test project that uses @NotNull. I added a dependency on a library that defines it (a copy of the IDEA annotations.jar but with a different name). I added an import statement:

import org.jetbrains.annotations.NotNull;


The program builds without error. However, the editor fails to find the library. It highlights "jetbrains" in red and says it can't resolve the symbol. Same for @NotNull.

I have observed this problem in IDEA CE 13.1.1, 13.0.2, and 12.1.

Oddly, the problem does not occur in 11.1.2.

Am I missing something, or is this a regression that has not been observed?
1
18 comments

Hello.

Your scenario looks Ok, it should work. Can you attach a sample project that does not?

Regards,
Alexander.

0

I have some additional information. The problem does not happen when I define the annotations library in the project. It happens when the library is referenced as a global library, like this:

    <library name="IdeaAnnotations">
      <CLASSES>
        <root url="file://$USER_HOME$/javalib/share/IdeaAnnotations.jar" />
      </CLASSES>
      <JAVADOC />
      <SOURCES />
    </library>



Attachment(s):
TestNotNullProblem.zip
0

Thank you. It works for me. Please try main menu / File / Invalidate Caches and Restart.

Alexander.

0

That did not fix the problem.

0

Can you attach a screenshot of Project Structure dialog / Global Libraries section / annotation library selected?

Thanks,
Alexander.

0

Thank you. Can't reproduce the problem.

Please attach idea.logs (see main menu / Help / Show Log in Finder).

Alexander.

0

Hmm... There are many exceptions here. The last thing I did was invalidate caches and restart. Not sure that invalidate caches works, it throws an exception.



Attachment(s):
idea.log.zip
0

Thank you.

As a quick fix attempt: please exit IDEA, erase /Users/alan/Library/Caches/IdeaIC13 at all, and restart. Just for a case some file is not updated during "fine" re-indexing for some reason.

Regards,
Alexander.

0

Tried that... no improvement.

0

Please take a look at the files on disk. E.g. if idea.log reports the file: /Users/alan/Library/Caches/IdeaIC13/index/stubs/java.class.shortname/java.class.shortname.project.176214839.1887115.true

Then what's going on with this file: are all directories created? And the file is created too?

If some part of the file tree does not exist then please check a) files and directories permissions up to Caches/IdeaIC13, b) free disk space.

Thank you,
Alexander.

0

I do not see any message about cache files in the latest log. 14GB free disk space.



Attachment(s):
CacheList.zip
idea.log.zip
0

And the problem is still the same with clean log?

Thank you,
Alexander.

0

Sorry, I've run out of ideas. You can create an issue in our bug tracker: http://youtrack.jetbrains.com/issues/IDEA
Maybe assigned developer will have more luck in catching this.

Regards,
Alexander.

0

I found the problem.

The reference to the library in applicationLibraries.xml was a file: URL. If I change it to a jar: URL, the library is found and the test program display is correct.

So, which is the bug - (1) that IDEA created a file URL for a JAR file, or (2) that the file URL was not effective?

My applicationLibraries.xml mostly contains jar URLs for JAR files, but not exclusively.

  Alan

The version that worked:

    <library name="IdeaAnnotations">
      <CLASSES>
        <root url="jar://$USER_HOME$/javalib/share/IdeaAnnotations.jar!/" />
      </CLASSES>
      <JAVADOC />
      <SOURCES />
    </library>

0

Thank you, great that you've found it.

The problem is (1), but another problem is that I have not reproduced it on my side, so I have no scenario to make it happen. Do you remember how did you act when the wrong reference was created? Anyway, I'll make several more attempts.

Alexander.

0

I faced the same issue in Android studio. But, It resolved on it's own in a minute or so. While I was googling it, I guess the Android Studio corrected the reference to library.

0

Please sign in to leave a comment.