Skip to content
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

org.springframework.lang.NonNullApi not supported #3431

Closed
exprassL opened this issue Dec 15, 2023 · 8 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#3003 or #3436
Closed

org.springframework.lang.NonNullApi not supported #3431

exprassL opened this issue Dec 15, 2023 · 8 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#3003 or #3436
Assignees

Comments

@exprassL
Copy link

exprassL commented Dec 15, 2023

Annotation org.springframework.lang.NonNullApi is not supported for null analysis.

os: win 10 pro
vscode: 1.84.2 (system setup)
redhat.java: v1.25.2023112903
jdk: jdk-17.0.6
springboot: 3.1.2

With the method parameter annotated by org.springframework.lang.NonNull directly, I got a warning said tha Null type mismatch: required .... but the provided is null. It's cool.

But with

"java.compile.nullAnalysis.nonnull": [
    "javax.annotation.Nonnull",
    "org.eclipse.jdt.annotaion.NonNull",
    "org.springframework.lang.NonNull",
    "org.springframework.lang.NonNullApi"
]

in the user's settings.json, and a package-info.java annotated by org.springframework.lang.NonNullApi, I got nothing.

When I placed "org.springframework.lang.NonNullApi" at the first line in the configuration json like this

"java.compile.nullAnalysis.nonnull": [
    "org.springframework.lang.NonNullApi",
    "javax.annotation.Nonnull",
    "org.eclipse.jdt.annotaion.NonNull",
    "org.springframework.lang.NonNull"
]

, I also got nothing about null analysis, but an error from package-info.java file saying The nullness annotation 'NonNullApi' is not applicable at this location instead.

@fbricon
Copy link
Collaborator

fbricon commented Dec 15, 2023

Can you please provide a sample project? Without knowing anything about the NonNullApi, I'd infer from the name it has a specific behaviour, different from NonNull, and JDT doesn't know anything about that specific behaviour.

@fbricon
Copy link
Collaborator

fbricon commented Dec 15, 2023

@martinlippert is this something STS should take care of?

@exprassL
Copy link
Author

Can you please provide a sample project? Without knowing anything about the NonNullApi, I'd infer from the name it has a specific behaviour, different from NonNull, and JDT doesn't know anything about that specific behaviour.

@fbricon the project is accessible only on company's intranet. After posting this issue, I tried IDEA and found it worked well.

@exprassL
Copy link
Author

Can you please provide a sample project? Without knowing anything about the NonNullApi, I'd infer from the name it has a specific behaviour, different from NonNull, and JDT doesn't know anything about that specific behaviour.

Sorry to forget telling that I had JDK17 installed and used.

@snjeza
Copy link
Contributor

snjeza commented Dec 15, 2023

@exprassL Could you try to add

org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.springframework.lang.NonNullApi

to <your_project>/.settings/org.eclipse.jdt.core.prefs

@fbricon @rgrunber We need to add the java.compile.nullAnalysis.nonnullbydefault property.

nullannot

@exprassL
Copy link
Author

@snjeza It's working. Thanks.

@martinlippert
Copy link

@martinlippert is this something STS should take care of?

Hey @fbricon, not sure what exactly the Spring Tools could/should do here. Do you have anything concrete in mind?

@fbricon
Copy link
Collaborator

fbricon commented Dec 18, 2023

@martinlippert nothing, now that @snjeza found this can be covered by java.compile.nullAnalysis.nonnullbydefault ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants