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

Support @org.checkerframework.checker.nullness.compatqual.NullableDecl etc. #523

Closed
PhilippWendler opened this issue Jan 8, 2018 · 6 comments

Comments

@PhilippWendler
Copy link

Guava 23.6 has switched from using javax.annotation.Nonnull to org.checkerframework.checker.nullness.compatqual.NullableDecl for non-null parameters etc. Please support this annotation (and possibly the other annotations from the same package), because otherwise SpotBugs creates a lot of false alarms when calling Guava methods. I tested this with SpotBugs 3.1.1.

@iloveeclipse
Copy link
Member

iloveeclipse commented Jan 9, 2018

@PhilippWendler : it would be great if you could provide here a map which checker annotation corresponds to which "old" annotation.

The fix itself will be probably trivial (see for example #182).

@iloveeclipse iloveeclipse added this to the SpotBugs 3.1.2 milestone Jan 9, 2018
@PhilippWendler
Copy link
Author

Thanks.

It seems that org.checkerframework.checker.nullness.compatqual.NullableDecl for Nullable and org.checkerframework.checker.nullness.compatqual.NonNullDecl for NonNull would at least need to be supported.

There are more annotations in org.checkerframework.checker.nullness.qual for more complex nullness analysis (the above annotations are the compatibility annotations for Java 7 code), but I am not sure whether SpotBugs could support them, and it seems Guava does not use them. Maybe just org.checkerframework.checker.nullness.qual.Nullable and org.checkerframework.checker.nullness.qual.NonNull for now? This would allow Java 8 code to keep using annotations named Nullable instead of NullableDecl.
If SpotBugs supports it, the qual annotations can also be used on types, not only on declarations.

For reference: I have this from JetBrains/kotlin#1421, which is the PR that the Guava guys have submitted for the Kotlin nullness analyzer. It mentions these four annotations here.

@philipl
Copy link
Contributor

philipl commented Jan 29, 2018

This was fixed by #539, right?

@iloveeclipse
Copy link
Member

Yep.

dbeyer-bot pushed a commit to sosy-lab/cpachecker that referenced this issue Feb 6, 2018
@anatoliy-balakirev
Copy link

Hi. I'm trying to use guava 25.1-jre, namely MoreObjects.toStringHelper().add("name", value), where signature looks like this:
public ToStringHelper add(String name, @ org.checkerframework.checker.nullness.qual.Nullable Object value)

I'm passing in a value (name is just a string literal), which is marked with old @ javax.annotation.CheckForNull and getting some errors from spotbugs (version 3.1.3):

[INFO] Total bugs: 12
[INFO] Null passed for non-null parameter of com.google.common.base.MoreObjects$ToStringHelper.add(String, Object) in ...

Is that supposed to work?

@anatoliy-balakirev
Copy link

Actually, just tried to replace javax.annotation.CheckForNull with org.checkerframework.checker.nullness.qual.Nullable in our code and that helped. Not sure if this is an expected behavior though. I thought old annotations are still supported as well...

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

No branches or pull requests

4 participants