Pluggable checking and inferencing of nonnull types for Java

We have implemented a non-null type checker for Java and a new non-null inferencing algorithm for analyzing legacy code. The tools are modular extensions to the JastAdd extensible Java compiler, illustrating how pluggable type systems can be achieved. The resulting implementation is compact, less than 230 lines of code for the non-null checker and 460 for the inferencer. Non-null checking is a local analysis with little effect on compilation time. The inferencing algorithm is a whole-program analysis, yet it runs sufficiently fast for practical use, less than 10 seconds for 100.000 lines of code. We ran our inferencer on a large part of the JDK library, and could detect that around 70% of the dereferences, and around 24% of the method return values, were guaranteed to be non-null.

[1]  J. L Bank,et al.  Parameterized Types and Java , 1996 .

[2]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[3]  Shane Markstrum,et al.  A framework for implementing pluggable type systems , 2006, OOPSLA '06.

[4]  Torbjörn Ekman,et al.  Rewritable Reference Attributed Grammars , 2004, ECOOP.

[5]  K. Rustan M. Leino,et al.  Declaring and checking non-null types in an object-oriented language , 2003, OOPSLA.

[6]  Todd D. Millstein,et al.  Practical predicate dispatch , 2004, OOPSLA.

[7]  Greg Nelson,et al.  Extended static checking for Java , 2002, PLDI '02.

[8]  Alexander Aiken,et al.  A theory of type qualifiers , 1999, PLDI '99.

[9]  Daniel H. H. Ingalls A Simple Technique for Handling Multiple Polymorphism , 1986, OOPSLA.

[10]  Donald E. Knuth,et al.  Semantics of context-free languages , 1968, Mathematical systems theory.

[11]  Görel Hedin,et al.  JastAdd--an aspect-oriented compiler construction system , 2003, Sci. Comput. Program..

[12]  Shane Markstrum,et al.  Semantic type qualifiers , 2005, PLDI '05.

[13]  PughWilliam,et al.  Evaluating and tuning a static analysis to find null pointer bugs , 2005 .

[14]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[15]  David Hovemeyer,et al.  Evaluating and tuning a static analysis to find null pointer bugs , 2005, PASTE '05.

[16]  Gilad Bracha Pluggable Type Systems , 2004 .

[17]  Michael D. Ernst,et al.  An overview of JML tools and applications , 2003, International Journal on Software Tools for Technology Transfer.

[18]  K. Rustan M. Leino,et al.  The Spec# Programming System: An Overview , 2004, CASSIS.

[19]  Görel Hedin,et al.  Circular reference attributed grammars - their evaluation and applications , 2003, Sci. Comput. Program..

[20]  Torbjörn Ekman,et al.  The jastadd extensible java compiler , 2007, OOPSLA.

[21]  Bertrand Meyer Attached Types and Their Application to Three Open Problems of Object-Oriented Programming , 2005, ECOOP.

[22]  Michael R. Clarkson,et al.  Polyglot: An Extensible Compiler Framework for Java , 2003, CC.

[23]  Patrice Chalin,et al.  Non-null References by Default in Java: Alleviating the Nullity Annotation Burden , 2007, ECOOP.

[24]  Mark Lillibridge,et al.  Extended static checking for Java , 2002, PLDI '02.