Tracking Null Checks in Open-Source Java']Java Systems

被引:1
|
作者
Osman, Haidar [1 ]
Leuenberger, Manuel [2 ]
Lungu, Mircea [3 ]
Nierstrasz, Oscar [1 ]
机构
[1] Univ Bern, SCG, CH-3012 Bern, Switzerland
[2] Univ Bern, CH-3012 Bern, Switzerland
[3] Univ Groningen, NL-9700 AB Groningen, Netherlands
关键词
Null Checks; Null Usage; Static Analysis;
D O I
10.1109/SANER.2016.57
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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.
引用
收藏
页码:304 / 313
页数:10
相关论文
共 50 条
  • [1] An Empirical Study of "Removed" Classes in Java']Java Open-Source Systems
    Mubarak, Asma
    Counsell, Steve
    Hierons, Robert M.
    [J]. ADVANCES TECHNIQUES IN COMPUTING SCIENCES AND SOFTWARE ENGINEERING, 2010, : 99 - 104
  • [2] Classifying code comments in Java']Java open-source software systems
    Pascarella, Luca
    Bacchelli, Alberto
    [J]. 2017 IEEE/ACM 14TH INTERNATIONAL CONFERENCE ON MINING SOFTWARE REPOSITORIES (MSR 2017), 2017, : 227 - 237
  • [3] Analyzing Conflict Predictors in Open-Source Java']Java Projects
    Accioly, Paola
    Borba, Paulo
    Silva, Leuson
    Cavalcanti, Guilherme
    [J]. 2018 IEEE/ACM 15TH INTERNATIONAL CONFERENCE ON MINING SOFTWARE REPOSITORIES (MSR), 2018, : 576 - 586
  • [4] An Open-Source Java']Java Platform for Automated Reaction Mapping
    Crabtree, John D.
    Mehta, Dinesh P.
    Kouri, Tina M.
    [J]. JOURNAL OF CHEMICAL INFORMATION AND MODELING, 2010, 50 (09) : 1751 - 1756
  • [5] On the Nature of Code Cloning in Open-Source Java']Java Projects
    Golubev, Yaroslav
    Bryksin, Timofey
    [J]. 2021 IEEE 15TH INTERNATIONAL WORKSHOP ON SOFTWARE CLONES, IWSC 2021, 2021, : 22 - 28
  • [6] SPMF: A Java']Java Open-Source Pattern Mining Library
    Fournier-Viger, Philippe
    Gomariz, Antonio
    Gueniche, Ted
    Soltani, Azadeh
    Wu, Cheng-Wei
    Tseng, Vincent S.
    [J]. JOURNAL OF MACHINE LEARNING RESEARCH, 2014, 15 : 3389 - 3393
  • [7] WEKA-Experiences with a Java']Java Open-Source Project
    Bouckaert, Remco R.
    Frank, Eibe
    Hall, Mark A.
    Holmes, Geoffrey
    Pfahringer, Bernhard
    Reutemann, Peter
    Witten, Ian H.
    [J]. JOURNAL OF MACHINE LEARNING RESEARCH, 2010, 11 : 2533 - 2541
  • [8] Source Code Features and their Dependencies: An Aggregative Statistical Analysis on Open-Source Java']Java Software Systems
    Toosi, Farshad Ghassemi
    [J]. APPLIED COMPUTER SYSTEMS, 2023, 28 (02) : 221 - 231
  • [9] JBioWH: an open-source Java']Java framework for bioinformatics data integration
    Vera, Roberto
    Perez-Riverol, Yasset
    Perez, Sonia
    Ligeti, Balazs
    Kertesz-Farkas, Attila
    Pongor, Sandor
    [J]. DATABASE-THE JOURNAL OF BIOLOGICAL DATABASES AND CURATION, 2013,
  • [10] BioJava']Java:: an open-source framework for bioinformatics
    Holland, R. C. G.
    Down, T. A.
    Pocock, M.
    Prlic, A.
    Huen, D.
    James, K.
    Foisy, S.
    Draeger, A.
    Yates, A.
    Heuer, M.
    Schreiber, M. J.
    [J]. BIOINFORMATICS, 2008, 24 (18) : 2096 - 2097