Non-null references by default in java: alleviating the nullity annotation burden

  • Authors:
  • Patrice Chalin;Perry R. James

  • Affiliations:
  • Dept. of Computer Science and Software Engineering, Concordia University Montréal, Québec, Canada;Dept. of Computer Science and Software Engineering, Concordia University Montréal, Québec, Canada

  • Venue:
  • ECOOP'07 Proceedings of the 21st European conference on Object-Oriented Programming
  • Year:
  • 2007

Quantified Score

Hi-index 0.00

Visualization

Abstract

With Java 5 annotations, we note a marked increase in tools that statically detect potential null dereferences. To be effective such tools require that developers annotate declarations with nullity modifiers and have annotated API libraries. Unfortunately, in our experience specifying moderately large code bases, the use of non-null annotations is more labor intensive than it should be. Motivated by this experience, we conducted an empirical study of 5 open source projects totaling 700 KLOC which confirms that on average, 3/4 of declarations are meant to be non-null, by design. Guided by these results, we propose adopting a non-null-by-default semantics. This new default has advantages of better matching general practice, lightening developer annotation burden and being safer. We adapted the Eclipse JDT Core to support the new semantics, including the ability to read the extensive API library specifications written in the Java Modeling Language (JML). Issues of backwards compatibility are addressed.