@Nullable

What's the best way to use @Nullable and @NotNull annotations in a mixed project?

There has been org.jetbrains.annotations.NotNull for quite a while now. There's also JSR-305 out there (http://code.google.com/p/jsr-305/) and finally there are annotations from FindBugs as well. But what is the way to go in a mixed setup? The Jetbrains annotations won't have any benefit in a development team that is dominated by Eclipse users. The FindBugs annotations aren't recognized by IDEA (yes I know there's a FindBugs plugin but that's something else than the live IDEA inspections).

Is there any chance for the Inspections plugin to also support the FindBugs annotations?

What's the best way to go?

Thanks,
Dirk

11 comments

Dittert wrote:

The Jetbrains annotations won't have any benefit in a development team that is dominated by Eclipse users.

I would partially disagree with that statement. While an Eclipse user would not get the benefit of the IDE (i.e. Eclipse) highlighting potential errors, the @NotNull and @Nullable annotations do serve as a form of documentation in the code. So there is some benefit.

I don't know if there is an easy answer to the question of what's the best way to go. IMHO, you basically have to pick one. Some developers would get full IDE benefits. Others would not. It would be nice for these annotations to be added to the core JDK. But not sure when, if ever, that will happen.

0

Still, it would be nice if IDEA allowed configuration of additional Nullable/NotNull annotation variants..

0

First, speaking as the person who probably instigated JSR-305 something like 4 years ago, you should know that it is dead.  Deceased.  Extinct.  Failed.  It is, for all intents and purposes,  an ex-JSR.   It's failure is only slightly mitigated by the fact that there most likely won't be a Java 7 for it to have shipped with, thus hiding its failure behind a large, more comprehensive, and infinitely more expensive failure.

Second, I could have swore that the data flow inspections used to allow alternative @Nullable/@NotNull annotations to be specified, but that seems to have fallen by the wayside in 9.   Sadness.

--Dave Griffith

0
Still, it would be nice if IDEA allowed configuration of additional Nullable/NotNull annotation variants..


We will consider every request that improves IDEA for end-users. Feel free to summarize on what exactly is proposed to be done and submit it as a dedicate YouTrack ticket.

Denis.

0

Let's not be down-hearted. One total catastrophe like this is just          the beginning!

0

Dave,
I can feel the frustration from your words.

It's sad to hear that there still is no accepted common solution to this problem. I have been using the org.jetbrains.NotNull annotations for quite some time now with great success. Unfortunately, this is not a solution that is acceptable in the mainly Eclipse dominated projects of my customers. They would need to add an additional jar to the classpath without any additional benefit for them.

For me, it would be an acceptable solution if it was possible to configure which annotation class should be used. That way I could just use the corresponding FindBugs annoations in IDEA. Right now, there's no such setting in IDEA 9.

What do you think?
Dirk

0

There's already at least one request: http://youtrack.jetbrains.net/issue/IDEA-10924 This issue is marked as duplicate, though I couldn't find the original one. Can you reopen that issue?

Thanks,
Dirk

0

Hi Dirk,

Rechecked IDEA tracker issues - didn't find referenced duplicate.

Reopened the ticket, thanks.

Denis.

0

I think that's a good idea, and exactly what http://youtrack.jetbrains.net/issue/IDEA-10924 is requesting.

0

Feel free to vote that issue

0

It seems that the issue got updated, and now is marked as a duplicate of the following ticket from the IDEA backlog:
http://youtrack.jetbrains.net/issue/IDEABKL-4959

That particular RFE has 14 votes at the moment, including mine.

0

Please sign in to leave a comment.