Capítulo de livro Revisado por pares

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

2007; Springer Science+Business Media; Linguagem: Inglês

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

ISSN

1611-3349

Autores

Patrice Chalin, Perry R. James,

Tópico(s)

Software System Performance and Reliability

Resumo

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.

Referência(s)