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

Closed
wants to merge 9 commits into from
Closed

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
@mp911de mp911de force-pushed the issue/nullability-revision branch from 654c59e to ec06257 Compare November 4, 2024 13:35
@mp911de mp911de added status: superseded An issue that has been superseded by another and removed status: on-hold We cannot start working on this issue yet type: enhancement A general enhancement labels Jan 23, 2025
@mp911de
Copy link
Member Author

mp911de commented Jan 23, 2025

Spring Framework introduced a Nullness utility (see also #3100) so we can leverage that one to detect null markers instead of having an own utility.

@mp911de mp911de closed this Jan 23, 2025
@mp911de mp911de deleted the issue/nullability-revision branch January 23, 2025 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants