Back to overview

Harvesting the Wisdom of the Crowd to Infer Method Nullness in {Java}

Type of publication Peer-reviewed
Publikationsform Proceedings (peer-reviewed)
Author Leuenberger Manuel, Osman Haidar, Ghafari Mohammad, Nierstrasz Oscar,
Project Agile Software Analysis
Show all

Proceedings (peer-reviewed)

Title of proceedings Proceedings of the 17th International Working Conference on Source Code Analysis and Manipulation
DOI 10.1109/scam.2017.22

Open Access


Null pointer exceptions are common bugs in Java projects. Previous research has shown that dereferencing the results of method calls is the main source of these bugs, as developers do not anticipate that some methods return null. To make matters worse, we find that whether a method returns null or not (nullness), is rarely documented. We argue that method nullness is a vital piece of information that can help developers avoid this category of bugs. This is especially important for external APIs where developers may not even have access to the code. In this paper, we study the method nullness of Apache Lucene, the de facto standard library for text processing in Java. Particularly, we investigate how often the result of each Lucene method is checked against null in Lucene clients. We call this measure method nullability, which can serve as a proxy for method nullness. Analyzing Lucene internal and external usage, we find that most methods are never checked for null. External clients check more methods than Lucene checks internally. Manually inspecting our dataset reveals that some null checks are unnecessary. We present an IDE plugin that complements existing documentation and makes up for missing documentation regard- ing method nullness and generates nullness annotations, so that static analysis can pinpoint potentially missing or unnecessary null checks.