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

Provide two annotations, NonnullField and NonnullApi #124

Open
Silentdoer opened this issue Nov 21, 2023 · 2 comments
Open

Provide two annotations, NonnullField and NonnullApi #124

Silentdoer opened this issue Nov 21, 2023 · 2 comments

Comments

@Silentdoer
Copy link

Like in Spring, non null annotations can be added to all fields in the class and method parameter return values, And it should be able to support annotation of the entire project/module

@Silentdoer Silentdoer changed the title Provide two annotations, NonnulllFields and NonnullApi Provide two annotations, NonnullFields and NonnullApi Nov 21, 2023
@Silentdoer Silentdoer changed the title Provide two annotations, NonnullFields and NonnullApi Provide two annotations, NonnullFields and NonnullApis Nov 21, 2023
@Silentdoer Silentdoer changed the title Provide two annotations, NonnullFields and NonnullApis Provide two annotations, NonnullField and NonnullApi Nov 21, 2023
@xenoterracide
Copy link

I'd like to see the converse also added NullField and NullApi, this way you could enforce being explicit.

Honestly this is low hanging fruit, I have time on my plate and would be willing to contribute these, as well as any underlying needed duplication of JSR-305 to support them (I notice spring's annotations compose JSR-305 code)

@sdeleuze
Copy link

sdeleuze commented Feb 14, 2024

Hey, Spring Framework committer here. I am not sure that would be as simple as adding those 2 additional annotations since:

  • Spring use case is leveraging meta annotations
  • The scope where null-safety applies needs to be specified, in JSR 305, we use @TypeQualifierDefault
  • Annotation attributes like When.MAYBE need to be expressed in another way in order to avoid warnings from javac
  • Need to have specifications and tooling support

In a nutshell, going beyond simple @Nonnull and @Nullable annotations is a huge task that is much more involved that it seems, as proven in https://github.com/jspecify/jspecify related work.

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

No branches or pull requests

3 participants