POLL: @Nullable etc.

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!"


69 comments
Comment actions Permalink

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

0
Comment actions Permalink

Alain Ravet wrote:

Did I miss something?


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

0
Comment actions Permalink

Alain:

There is no such thing in Java, as a method that
could optionally return
a value.
'null' is not the same as 'void'.


True, but null returns are as close as one can get in Java to an optional return value.


Sascha Weinreuter

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.


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

0
Comment actions Permalink

@AlwaysTrue


@BitchIfYouDontLikeIt
@CrapOnMyCode
@PissUserOff

R

0
Comment actions Permalink

@Freak!
@:-)

Vince.


0
Comment actions Permalink

vlad wrote:

Yes, I like that too! (But I still find @PossiblyNull more in line with @NeverNull)


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!"

0
Comment actions Permalink

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

0
Comment actions Permalink

Hmm, "non_null" looks a little bit odd for Java-accustomed eyes, but might
be fine for C hackers.

Tom

0
Comment actions Permalink

Rob wrote:

That gets my vote:
@PossiblyNull
@NeverNull


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 ;)

0

Please sign in to leave a comment.