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

Introduce Nullability API #3115

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Introduce Nullability API #3115

wants to merge 9 commits into from

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Jun 26, 2024

We now provide a dedicated API to introspect nullability rules. The new API supports Spring, JSR-305, and JSpecify.

Nullability nullability = Nullability.forMethodReturnType(method);
nullability.isDeclared();
nullability.isNullable();
nullability.isNonNull();

// introspect multiple elements for their nullability in the scope of a class/package.
Nullability.Introspector introspector = Nullability.introspect(NonNullOnPackage.class);
Nullability nullability = introspector.forReturnType(method);

The previous NullableUtils API is now deprecated as its implementation would not support a pluggable model of NullabilityProvider.

Related to #3100

@mp911de mp911de added the type: enhancement A general enhancement label Jun 26, 2024
@mp911de
Copy link
Member Author

mp911de commented Jun 26, 2024

Paging @sdeleuze

@odrotbohm
Copy link
Member

Should this rather live in Spring Framework?

@sdeleuze
Copy link
Contributor

If we added more nullabilty runtime API, it would indeed be worth to considering it for inclusion in Spring Framework, but in terms of timeframe it would be more towards next year. As shared with @mp911de, nullabilty is a complex and nuanced topic with a lot of implications, and there are some ongoing discussions with JSpecify working group on potential evolution that could impact how Spring supports it, as well as some future implication on JDK side. With @jhoeller, in terms of timeline we suggest to wait for related portfolio-wide discussions to evaluate what could go on Framework side before merging this PR.

@mp911de mp911de added the status: on-hold We cannot start working on this issue yet label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: on-hold We cannot start working on this issue yet type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants