www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Non-null analysis in Java

reply Somedude <lovelydear mailmetrash.com> writes:
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

* javax.validation.constraints.NotNull
Created for runtime validation, not static analysis.

* edu.umd.cs.findbugs.annotations.NonNull
Static analysis

* com.intellij.annotations.NotNull
Used by IntelliJ IDEA IDE for static analysis.

* lombok.NonNull
Annotation used to control code generation in Project Lombok.
Dec 11 2011
next sibling parent reply deadalnix <deadalnix gmail.com> writes:
Le 11/12/2011 11:29, Somedude a écrit :
 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

 * javax.validation.constraints.NotNull
 Created for runtime validation, not static analysis.

 * edu.umd.cs.findbugs.annotations.NonNull
 Static analysis

 * com.intellij.annotations.NotNull
 Used by IntelliJ IDEA IDE for static analysis.

 * lombok.NonNull
 Annotation used to control code generation in Project Lombok.
We definitively should have a non nullable type in D. Null check are: - Easy to forget, leading to catastrophic results when forgotten. - Crippling the codebase at an alarming speed if you want reliable code. Plus, when an error occurs with null, it is usually hard to track and solve, because you have to understand how that b****y variable ends up being null. Arguably, things should be non nullable by default. Tony Hoare (inventor of null ?) recently gave this conference : http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare
Dec 11 2011
parent reply =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
On 11-12-2011 14:18, deadalnix wrote:
 Le 11/12/2011 11:29, Somedude a écrit :
 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

 * javax.validation.constraints.NotNull
 Created for runtime validation, not static analysis.

 * edu.umd.cs.findbugs.annotations.NonNull
 Static analysis

 * com.intellij.annotations.NotNull
 Used by IntelliJ IDEA IDE for static analysis.

 * lombok.NonNull
 Annotation used to control code generation in Project Lombok.
We definitively should have a non nullable type in D. Null check are: - Easy to forget, leading to catastrophic results when forgotten. - Crippling the codebase at an alarming speed if you want reliable code. Plus, when an error occurs with null, it is usually hard to track and solve, because you have to understand how that b****y variable ends up being null. Arguably, things should be non nullable by default. Tony Hoare (inventor of null ?) recently gave this conference : http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare
I think the idea with D's disable attribute on default struct contructors is to allow implementing a NoNull type. Still, I'd prefer having it in the language. - Alex
Dec 11 2011
next sibling parent deadalnix <deadalnix gmail.com> writes:
Le 11/12/2011 14:19, Alex Rønne Petersen a écrit :
 On 11-12-2011 14:18, deadalnix wrote:
 Le 11/12/2011 11:29, Somedude a écrit :
 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

 * javax.validation.constraints.NotNull
 Created for runtime validation, not static analysis.

 * edu.umd.cs.findbugs.annotations.NonNull
 Static analysis

 * com.intellij.annotations.NotNull
 Used by IntelliJ IDEA IDE for static analysis.

 * lombok.NonNull
 Annotation used to control code generation in Project Lombok.
We definitively should have a non nullable type in D. Null check are: - Easy to forget, leading to catastrophic results when forgotten. - Crippling the codebase at an alarming speed if you want reliable code. Plus, when an error occurs with null, it is usually hard to track and solve, because you have to understand how that b****y variable ends up being null. Arguably, things should be non nullable by default. Tony Hoare (inventor of null ?) recently gave this conference : http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare
I think the idea with D's disable attribute on default struct contructors is to allow implementing a NoNull type. Still, I'd prefer having it in the language. - Alex
Definitively, it should be done the other way around : Non null by default, and Nullable!(T) in the standard lib. Most of the time, you don't want null, and have to check them.
Dec 11 2011
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 12/11/2011 02:19 PM, Alex Rønne Petersen wrote:
 On 11-12-2011 14:18, deadalnix wrote:
 Le 11/12/2011 11:29, Somedude a écrit :
 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

 * javax.validation.constraints.NotNull
 Created for runtime validation, not static analysis.

 * edu.umd.cs.findbugs.annotations.NonNull
 Static analysis

 * com.intellij.annotations.NotNull
 Used by IntelliJ IDEA IDE for static analysis.

 * lombok.NonNull
 Annotation used to control code generation in Project Lombok.
We definitively should have a non nullable type in D. Null check are: - Easy to forget, leading to catastrophic results when forgotten. - Crippling the codebase at an alarming speed if you want reliable code. Plus, when an error occurs with null, it is usually hard to track and solve, because you have to understand how that b****y variable ends up being null. Arguably, things should be non nullable by default. Tony Hoare (inventor of null ?) recently gave this conference : http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare
I think the idea with D's disable attribute on default struct contructors is to allow implementing a NoNull type. Still, I'd prefer having it in the language. - Alex
D cannot support library NonNull types because there is no way to get initialization right.
Dec 11 2011
prev sibling parent bearophile <bearophileHUGS lycos.com> writes:
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
Dec 12 2011