Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Confused about discrepancy with null annotation classes
Confused about discrepancy with null annotation classes [message #1760975] Thu, 04 May 2017 19:56 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 813
Registered: July 2009
Senior Member
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.
Re: Confused about discrepancy with null annotation classes [message #1760985 is a reply to message #1760975] Thu, 04 May 2017 22:37 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Two problems identified (in https://bugs.eclipse.org/516202):
- those findbugs annotations are not well-defined, they lack a @Target meta annotation, which makes it almost impossible to correctly interpret them (it's both a declaration annotation and a type annotation, yikes)
- JDT is successful when reading Bar from .class (incremental compile), but get's it wrong when reading Bar from source (full build).

Previous Topic:Building Eclipse JDT From Source
Next Topic:How to show svg type images from java code?
Goto Forum:
  


Current Time: Sat Oct 12 15:06:49 GMT 2024

Powered by FUDForum. Page generated in 0.03305 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top