POLL: @Nullable etc. Follow
Recent discussion here convinced us to implement @nullable and @nonnull annotations
in 'constant conditions & runtime exceptions' aka 'data flow analysis' inspection.
The final question is quite simple: how those annotations should be named
and in what package they should reside?
The variants so far are as follows:
@nullable, @Nullable
@nonnull, @notnull, @NotNull, @NonNull
as to package, org.jetbrains comes to my mind.
Suggestions?
-
Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"
Please sign in to leave a comment.
Maarten
>>>@Optional (== @Nullable)
>>>@Mandatory (== @NotNull(able))
>>>
>>>
>>In what dimension are those words synonyms? Not in mine.
>>
>>
>Read them as 'value is optional' and 'value is mandatory'.
>
>
There is no such thing in Java, as a method that could optionally return
a value.
'null' is not the same as 'void'.
Alain
Alain Ravet wrote:
No, I feel the same. Optional is something that can be /physically/ omitted,
like an optional parameter. Mandatory is the opposite and doesn't relate to
being null or not null.
Sascha
Alain:
True, but null returns are as close as one can get in Java to an optional return value.
Sascha Weinreuter
Looking purely at computer programming and computer language grammars, that is quite true. Looking a bit further, and 'optional' field on a form (web or paper) is not physically omitted, but only logically by leaving the value empty (null or possibly an empty String).
Maarten
@BitchIfYouDontLikeIt
@CrapOnMyCode
@PissUserOff
R
@Freak!
@:-)
Vince.
vlad wrote:
That gets my vote:
@PossiblyNull
@NeverNull
With auto-completion, it's @P Ctrl-Space and @N Ctrl-Space.
--
Rob Harwood
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
In the JML community <http://www.jmlspecs.org/> (>20 Universities, >12 tools, support for program specification, runtime testing, unit test generation, extended static checking, and full program verification) we have, among many other keywords, specification expression to capture these notions.
We use the keywords "non_null" and "nullable". I humbly suggest you to use the same keywords.
The specification "non_null" used to be the default for reference types, but after recent analysis by Patrice Chalin's group at Concordia (http://www.cs.concordia.ca/~chalin/), we have decided to switch to a default annotation of "nullable". I suggest you choose the same default.
Joe Kiniry
UCD Dublin
Hmm, "non_null" looks a little bit odd for Java-accustomed eyes, but might
be fine for C hackers.
Tom
Rob wrote:
If it's a free-for-all, I'd prefer:
@CanBeNull
@NeverNull
@CanBeNull sounds a little more sure of itself than @PossiblyNull or @MayBeNull, and complements the certainty of @NeverNull.
It also seems to me that length (within reason) isn't such an issue: for on-the-fly coders, typing @NeverNull or @CanBeNull gives a chance for the subconscious to flag up any doubts or issues, and for those of us who prefer to design in detail before ever touching the keyboard, IDEA will provide a key combination to save us the effort ;)