Osman, Haidar; Leuenberger, Manuel; Lungu, Mircea; Nierstrasz, Oscar Marius (March 2016). Tracking Null Checks in Open-Source Java Systems. In: 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER) (pp. 304-313). IEEE 10.1109/SANER.2016.57
Text
07476652.pdf - Published Version Restricted to registered users only Available under License Publisher holds Copyright. Download (263kB) |
It is widely acknowledged that null values should be avoided if possible or carefully used when necessary in Java code. The careless use of null has negative effects on maintainability, code readability, and software performance. However, a study on understanding null usage is still missing. In this paper we analyze null checks in 810 open-source Java systems and manually inspect 100 code samples to understand when and why developers use null. We find that 35 of all conditional statements contain null checks. A deeper investigation reveals many questionable practices with respect to using null. Uninitialized member variables, returning null in methods, and passing null as a method parameter are among the most recurrent reasons for introducing null checks. Developers often return null in methods to signal errors instead of throwing a proper exception. As a result, 71 of the values checked for null are returned from method calls. Our study provides a novel evidence of an overuse of null checks and of the null value itself in Java, and at the same time, reveals actionable recommendations to reduce this null usage.
Item Type: |
Conference or Workshop Item (Paper) |
---|---|
Division/Institute: |
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: |
Osman, Haidar, Lungu, Mircea, Nierstrasz, Oscar |
Subjects: |
000 Computer science, knowledge & systems 500 Science > 510 Mathematics |
ISBN: |
978-1-5090-1855-0 |
Publisher: |
IEEE |
Language: |
English |
Submitter: |
Oscar Nierstrasz |
Date Deposited: |
01 Feb 2017 10:56 |
Last Modified: |
02 Mar 2023 23:28 |
Publisher DOI: |
10.1109/SANER.2016.57 |
Uncontrolled Keywords: |
scg-pub snf-asa2 jb16 scg16 |
BORIS DOI: |
10.7892/boris.94647 |
URI: |
https://boris.unibe.ch/id/eprint/94647 |