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
Non-null type argument is expected #530
Comments
Oh I'm not sure (I use Eclipse). Maybe @vlsi can help explain what we should do. In v3, we tried to better conform to the Checker Framework annotations for inspections (#337). The recommended change was use the signature |
Thanks, I can suppress the warning but I usually prefer not to, unless it will really be something that can't be avoided otherwise. |
@amosss , do you have a reproducer? |
mmm... I opened the project in intellij and I see that warning there where I define the Cache variable. Nothing special. |
Ok, AFAIK, IDEA does not support nullability annotations for generic type parameters yet. I guess IntelliJ team would follow up with https://github.com/jspecify/jspecify and support jspecify annotations and behavior once it is ready.
For Checker Framework's default rules this declaration is the same as That is why for now I refrain from |
Oh, so the fix is to replace, Cache<K extends @NonNull Object, V extends @NonNull Object> with Cache<K extends Object, V extends Object> ? I hope jspecify makes progress because it seems kind of convoluted how analyzers interpret these annotations. |
It would probably do. You might want replacing all instances of |
Because it's a "living" project, I always work against releases. Is there a way I can try the snapshot by changing the maven dependency and then set it back after trying? |
Yes, I didn't mean to imply that you would switch your project over beyond a quick check. The CI will publish a snapshot build to Sonatype's repository under the version jitpack.io can build on-demand from a commit hash from a public repository. That remains stable as a decent means for hot patching if one has no other choice. We have it set up to skip tests when built that way to avoid timeouts. You should be able to use either locally, see if the warnings go away, and then revert back to a release version. |
So just to make sure, is it enough to add this jar: https://oss.sonatype.org/content/repositories/snapshots/com/github/ben-manes/caffeine/caffeine/3.0.2-SNAPSHOT/caffeine-3.0.2-20210410.225425-20.jar to my project to check the warnings disappear (and then revert back)? |
Yep. |
Works like a charm, I reverted to 3.0.1 until this is officially released, thanks! |
Maybe related? |
NPE is indeed possible if the key is not there. |
Obviously :) |
Please do not do that. The second read can indeed cause NPE. |
You got a point there... |
Released in 3.0.2 |
Thanks! |
Hi
Lately I started working with intellij and its inspections mechanism seems to be too sensitive but I want to make sure I'm not missing something. I set the following
private Cache<String, AnObject> objectsCache = null;
(Initialization comes later on)It marks both
String
andAnObject
with a warning:What am I missing?
Thanks
The text was updated successfully, but these errors were encountered: