-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The type javax.annotation.Nonnull cannot be resolved #2712
Comments
Do you have a sample project available to share that was causing this issue. Looks like the annotations are used in some library/class files but aren't on the classpath ? CC @CsCherrYY |
If anyone is able to point to a sample project (or upload one) that causes this problem, it would be very helpful. Looking at some past issues in JDT, I noticed this would happen when null analysis was enabled, but no implementation on the classpath. Since we currently enable the analysis automatically, it's obviously being enabled in circumstances where it shouldn't be. |
This is also occurring on a project I'm a part of. It's preventing the project from building within the IDE. Unfortunately, I'm not able to share any source code. Is there a way to turn off/disable null analysis in configuration for the time being? |
I'm having the same problem using VSCode + SSH into a remote Linux machine I'm not using Mac Version 12.5 Unfortunately, I'm not able to share the code |
You should be able to disable this feature with the following settings (on the individual workspace, or globally). .vscode/settings.json
|
A related issue - #2721 |
I have setup my settings.json file as instructed (I chose the workspace root .vscode directory) {
"java.compile.nullAnalysis.nonnull": [],
"java.compile.nullAnalysis.nullable": []
} However, I'm still seeing the same error after running
Does this have anything to do with the issue mentioned above? |
@rgrunber here is a sample project that causes the problem for me - https://github.com/yotov/vscode-nullable Hope that this can help you :) |
@chowethan @yotov Could you try to remove .project, .classpath, .settings from your project? |
@yotov thank-you. Am able to reproduce. Looking at the classpath of the project, I see both 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 {
"java.compile.nullAnalysis.nullable": [
"org.springframework.lang.Nullable",
"javax.annotation.Nullable",
"org.eclipse.jdt.annotation.Nullable"
],
"java.compile.nullAnalysis.nonnull": [
"org.springframework.lang.NonNull",
"javax.annotation.Nonnull",
"org.eclipse.jdt.annotation.NonNull"
]
} |
@rgrunber yes, reordering the classes fixes the problem and I'm able to compile the project from IDE |
There may be a few things at play here as pointed out to me by @snjeza . Apparently At https://github.com/eclipse/eclipse.jdt.ls/blob/f8452b422add64f9bbc80d0e22b48ed71797e563/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java#L2055 , could we just set the classpath options scope to be "compile" ? |
We can't because the scope is set in upstream project (spring-core). m2e adds the classpath test attribute for the maven runtime and test scope. |
It took adding to my user and workspace settings.json. No change in the project .project, .classpath, .settings necessary. |
@jvansant The fix eclipse-jdtls/eclipse.jdt.ls#2264 is available in the newest pre-release verison |
In one of my projects, I'm getting an error after upgrading to the latest version:
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
The text was updated successfully, but these errors were encountered: