European Conference on Object-Oriented Programming

ECOOP 2007: ECOOP 2007 – Object-Oriented Programming pp 227-247

Non-null References by Default in Java: Alleviating the Nullity Annotation Burden

  • Patrice Chalin
  • Perry R. James
Conference paper

DOI: 10.1007/978-3-540-73589-2_12

Volume 4609 of the book series Lecture Notes in Computer Science (LNCS)
Cite this paper as:
Chalin P., James P.R. (2007) Non-null References by Default in Java: Alleviating the Nullity Annotation Burden. In: Ernst E. (eds) ECOOP 2007 – Object-Oriented Programming. ECOOP 2007. Lecture Notes in Computer Science, vol 4609. Springer, Berlin, Heidelberg

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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Patrice Chalin
    • 1
  • Perry R. James
    • 1
  1. 1.Dependable Software Research Group, Dept. of Computer Science and Software Engineering, Concordia University Montréal, QuébecCanada