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

Leuenberger, Manuel; Osman, Haidar; Ghafari, Mohammad; Nierstrasz, Oscar Marius (2017). Harvesting the Wisdom of the Crowd to Infer Method Nullness in Java. In: 17th International Working Conference on Source Code Analysis and Manipulation. SCAM 2017 (pp. 71-80). IEEE 10.1109/SCAM.2017.22

[img] Text
08090140.pdf - Published Version
Restricted to registered users only
Available under License Publisher holds Copyright.

Download (1MB) | Request a copy

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.

Item Type:

Conference or Workshop Item (Paper)


08 Faculty of Science > Institute of Computer Science (INF)
08 Faculty of Science > Institute of Computer Science (INF) > Software Composition Group (SCG) [discontinued]

UniBE Contributor:

Leuenberger, Manuel, Osman, Haidar, Ghafari, Mohammad, Nierstrasz, Oscar


000 Computer science, knowledge & systems
500 Science > 510 Mathematics






SCAM 2017






Oscar Nierstrasz

Date Deposited:

11 Apr 2018 12:09

Last Modified:

02 Mar 2023 23:30

Publisher DOI:






Actions (login required)

Edit item Edit item
Provide Feedback