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

Request: add nullable annotations, to know what can return null #87

Open
AndroidDeveloperLB opened this issue Sep 24, 2023 · 3 comments

Comments

@AndroidDeveloperLB
Copy link

For example, I've noticed there is some case that "findMatch" can return null:

private ContentInfo findMatch(byte[] bytes, List<MagicEntry> entryList) {
    ....
    if (partialMatchInfo == null) {
        logger.trace("returning no match");
            return null;z
@j256
Copy link
Owner

j256 commented Oct 4, 2023

I'm not sure I understand your question. It is returning null because it found no match to the bytes. Are you asking for partial match information or something? Can you provide an example and what output you would like?

@vinceh121
Copy link
Contributor

vinceh121 commented Oct 4, 2023

If I understand the title correctly, it is a request to annotate public methods with JSR 305 @Nullable and @Nonnull

@AndroidDeveloperLB
Copy link
Author

@j256 Nullability annotations help both the IDE and us to understand which functions can return null and which function should never return null.
This helps with prevention of NPE, helps the IDE to offer various optimizations, helps to remove useless nullability checks, and also provides better support for Kotlin which forces developers to declare what can have a null value and what cannot.

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