Non-null analysis in Java
bearophile
bearophileHUGS at lycos.com
Mon Dec 12 05:27:21 PST 2011
Somedude:
> Just for the record, non-null static and runtime analysis is implemented
> in a number of Java projects.
>
> http://eclipseandjazz.blogspot.com/2011/12/inter-procedural-null-analysis-using.html
> Anotation based Static analysis for eclipse
It looks very nice.
Instead of that Java syntax:
@NonNull Object foo(@NonNull Object x) {...
For D2 I have suggested a more handy and short syntax, a trailing @ means non-null:
object@ foo(object@ x) {...
A leading (usually optional, because it's the default, but in some situations you need to use it) ? means nullable:
object? foo(object? x) {...
The question mark is useful in some situations:
Foo@ foo = new Foo(); // foo is non-null
auto f = cast(?)foo; // cast to nullable
Some notes here:
http://d.puremagic.com/issues/show_bug.cgi?id=4571
Bye,
bearophile
More information about the Digitalmars-d
mailing list