The type javax.annotation.Nonnull cannot be resolved
See original GitHub issueIn one of my projects, I’m getting an error after upgrading to the latest version:
The type javax.annotation.Nonnull cannot be resolved. It is indirectly referenced from required .class filesJava(16777540)
Annotation type 'javax.annotation.Nonnull' cannot be found on the build path, which is implicitly needed for null analysisJava(536871894)
I saw the changelog and found that the issue relates to enhancement - Enable annotation-based null analysis. See #1693.
Removing “javax.annotation.Nonnull” from “java.compile.nullAnalysis.nonnull” config fixes the problem for me.
Environment
- Operating System: MacOS 12.6
- JDK version: openjdk 17 2021-09-14
- Visual Studio Code version: 1.71.2
- Java extension version: 1.11.0
Issue Analytics
- State:
- Created a year ago
- Reactions:8
- Comments:16 (9 by maintainers)
Top Results From Across the Web
Can't find @Nullable inside javax.annotation.* - Stack Overflow
Unable to import javax.annotation.Nullable; I have jsr250-api-1.0.jar in my classpath. I even tried updating maven pom <dependency> ...
Read more >The annotation Nonull cannot be resolved to a type - SpigotMC
Tried to import javax.annotation.Nonnull, but it tells me that javax.anotation doesn't contain Nonull, tried to add the dependency to ...
Read more >javax.annotation.Nullable cannot be found by IDEA - YouTrack
The only one known workaround is to type imports manually (after adding 'import javax.annotation.Nullable' everything is fine for current class).
Read more >Full Text Bug Listing - Bugs - Eclipse
annotation.Nullable Object) Now we have an URB(javax.annotation.Nullable) Later when trying to resolve the import javax.annotation.Nullable, we find the URB, ...
Read more >how to fix Cannot resolve symbol 'Nullable' - YouTube
Java annotations are pieces of metadata that provide information about the code they are used with, and can instruct the IDE how to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You should be able to disable this feature with the following settings (on the individual workspace, or globally).
.vscode/settings.json
@yotov thank-you. Am able to reproduce.
Looking at the classpath of the project, I see both
com.google.code.findbugs:jsr305:jar:3.0.2:runtime
&org.springframework:spring-core:jar:5.3.22:compile
. So basically we have 2 annotation providers on the classpath. It looks like the defaults prefer thejsr305
provides (eg. javax.annotation…) over the spring framework provider (eg. org.springframework.lang…). However clearly in this case it should be reversed.Can you try, the following setting ? It’s basically just the default settings, but the spring framework annotations are moved to the top.
.vscode/settings.json