|Confused about discrepancy with null annotation classes [message #1760975]
||Thu, 04 May 2017 19:56
| David M. Karr
Registered: July 2009
I'm attempting to start using null annotations.|
It appears there are two "common" null annotations artifacts, one at "org.eclipse.jdt:org.eclipse.jdt.annotation" and the other at ""com.google.code.findbugs:jsr305". There are likely others, as they're just marker interfaces. It shouldn't matter which one I use, as supposedly tooling can use whichever you specify.
If I add the first artifact to my project and put a "@NonNull" annotation on a method, then I can verify that Eclipse knows that some code calling this method cannot result in a null value in that variable, so it won't emit "potential null pointer access" on derefs of the variable later.
However, if I also have the findbugs artifact, and I change the annotation to "@Nonnull" (annoying that they spelled it differently), then Eclipse gives me the "pnpa" warning on the code calling this.
I believe I'm supposed to rectify this by going to "Preferences"->"Java"->"Compiler"->"Errors/Warnings", and then on the checked setting for "Use default annotations for null specifications", to click the "Configure" link to get a "Annotations for Null Specifications" subdialog. I would assume that I would then add "javax.annotation.Nonnull" in the "Secondary annotations" list for "NonNull annotations".
I did this, but it appeared to have no effect.
Powered by FUDForum
. Page generated in 0.01382 seconds