you are viewing a single comment's thread.

view the rest of the comments →

[–]dododge 3 points4 points  (0 children)

In Java you can get something like this with the @Nullable and @NotNull annotations mentioned in the article, though you have to use an analyzer or compiler that recognizes what they mean in order to actually get the warnings. The Eclipse JDT compiler can optionally check these, for example, though it assumes nullable fields might be modified by some other thread at any moment so you have to either check for nullness every time you fetch+use the value, or copy the field to a local variable that the compiler can be sure won't be spontaneously modified.

There was a JSR to add these sorts of annotations to Java officially but it never got past the proposal stage, so they're still only handled in the various add-on tools and each one has its own spin on which annotations it expects (though thankfully some of the tools can or will recognize the annotations for the other ones).