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
[null] Consider javax.annotation.Nullable/NonNull by default #379
[null] Consider javax.annotation.Nullable/NonNull by default #379
Conversation
cc @rgrunber |
You might be aware that I have quite strong reservations against what you call JSR 305:
For decades it was furthermore the position of JDT not to endorse/favor/advertise any specific 3rd party library (with maybe the singular exception of junit, which is above any doubt, though :) ). This is likely a wont fix, because it would likely create quite some confusion for those not aware of the issues I mentioned. |
To be honest I'm not familiar with the technical limitation of those particular null annotations. I'm just aware that they are relatively popular (much more than JDT ones if we look at all Maven consumers of this jsr-305 artifact), and that they do not work by default in Eclipse IDE while users would expect those to work. |
It was brought to my attention that javax.annotation.Nullable and javax.annotation.NonNull are actually shipped by the Eclipse Platform and used by e4. So IMO, it would be consistent to better support them by default. |
Not that I know, not in the SDK itself. It is only in spotbugs and only in old versions of it.
git grep shows zero matches in platform UI. Where exactly it is used? |
OK, I verified and am actually wrong, the javax.annotations that are used are not the null-analysis ones, only some Inject and PostConstruct and so on. |
The motivation for this is redhat-developer/vscode-java#1693 . It looks like it's something that a sizable amount of users are interested in. If this is a no-go because it creates more problems / is legacy / no agreed upon standard, then we may end up just carrying it in JDT-LS since the options are simple enough to override. |
795,000 hits for |
@mickaelistria : please consider to recommend everyone stop using JSR-305 annotations. If sou want to do something in NP area, consider add support to https://github.com/jspecify/jspecify in JDT, because that is supposed to be next "common" NP annotations standard. Note: I'm not sure if JDT implementation is compatible with jspecify, it just happened to me to know about that initiative. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment regarding this dead JSR.
So they are getting closer to a first release? That's probably a sound option moving forward (although I would add "quasi-" or similar in front of "standard", right? :) )
Please let me know if you see some kind of test suite that we could use to test compatibility. At a quick glance the annotations could be made to match with a little tweaking behind the scenes:
This should go a long way for a quick integration, but still there will be fine points in the semantics. That's why I asked for tests. |
Closing as two project committer have consensus that this PR is "no go" and there were no other committer votes for a merge. |
OK. Do you have some more insights about it (articles, former discussions...)? I'm curious as many projects happen to happily use those javax.annotation.NonNull, what can be not working in JDT? |
I don't know how official a definition jsr305 produced, but my understanding is that jsr305's |
Ok thanks. And what about @nonnull? If semantics for this one match, JDT
could support it by default even if @nullable is not.
…--
Mickael Istria
Eclipse IDE <https://www.eclipse.org/eclipseide> developer, for Red Hat
Developers <https://developers.redhat.com/>
|
I don't believe you'd gain much with supporting only one of the pair. If you want to omit one use The next issue is
As an exercise for the reader: is the following assignment safe?
Is it readable? |
Please reconsider this. Promoting these annotations in any way is doing more harm than good to the Java ecosystem for all of the aforementioned reasons. |
What it does
This adds support for
javax.annotation.Nonnull
andjavax.annotation.Nullable
, which are popular becaues of JSR-305 by default in JDT null analysis. So users of JSR-305 do not require specific configuration to leverage JDT null analysisHow to test
Enable null annotation and try
Author checklist