Revisiting Exception Handling Practices with Exception Flow Analysis

Modern programming languages, such as Java and C#, typically provide features that handle exceptions. These features separate error-handling code from regular source code and aim to assist in the practice of software comprehension and maintenance. Having acknowledged the advantages of exception handling features, their misuse can still cause reliability degradation or even catastrophic software failures. Prior studies on exception handling aim to understand the practices of exception handling in its different components, such as the origin of the exceptions and the handling code of the exceptions. Yet, the observed findings were scattered and diverse. In this paper, to complement prior research findings on exception handling, we study its features by enriching the knowledge of handling code with a flow analysis of exceptions. Our case study is conducted with over 10K exception handling blocks, and over 77K related exception flows from 16 open-source Java and C# (.NET) libraries and applications. Our case study results show that each try block has up to 12 possible potentially recoverable yet propagated exceptions. More importantly, 22% of the distinct possible exceptions can be traced back to multiple methods (average of 1.39 and max of 34). Such results highlight the additional challenge of composing quality exception handling code. To make it worse, we confirm that there is a lack of documentation of the possible exceptions and their sources. However, such critical information can be identified by exception flow analysis on well-documented API calls (e.g., JRE and.NET documentation). Finally, we observe different strategies in exception handling code between Java and C#. Our findings highlight the opportunities of leveraging automated software analysis to assist in exception handling practices and signify the need of more further in-depth studies on exception handling practice.

[1]  Alessandro F. Garcia,et al.  Trading robustness for maintainability: an empirical study of evolving c# programs , 2014, ICSE.

[2]  F. Wilcoxon SOME RAPID APPROXIMATE STATISTICAL PROCEDURES , 1950 .

[3]  Aaas News,et al.  Book Reviews , 1893, Buffalo Medical and Surgical Journal.

[4]  Chanchal Kumar Roy,et al.  How Developers Use Exception Handling in Java? , 2016, 2016 IEEE/ACM 13th Working Conference on Mining Software Repositories (MSR).

[5]  Uirá Kulesza,et al.  Understanding the Exception Handling Strategies of Java Libraries: An Empirical Study , 2016, 2016 IEEE/ACM 13th Working Conference on Mining Software Repositories (MSR).

[6]  Meiyappan Nagappan,et al.  Curating GitHub for engineered software projects , 2017, Empirical Software Engineering.

[7]  Martin P. Robillard,et al.  Analyzing exception flow in Java programs , 1999, ESEC/FSE-7.

[8]  Alessandro F. Garcia,et al.  Categorizing Faults in Exception Handling: A Study of Open Source Projects , 2014, 2014 Brazilian Symposium on Software Engineering.

[9]  Chandra Krintz,et al.  As-if-serial exception handling semantics for Java futures , 2009, Sci. Comput. Program..

[10]  Martin P. Robillard,et al.  Static analysis to support the evolution of exception structure in object-oriented systems , 2003, TSEM.

[11]  Weiyi Shang,et al.  Studying the Prevalence of Exception Handling Anti-Patterns , 2017, 2017 IEEE/ACM 25th International Conference on Program Comprehension (ICPC).

[12]  Uirá Kulesza,et al.  The use of C++ exception handling constructs: A comprehensive study , 2015, 2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation (SCAM).

[13]  James Clause,et al.  Lightweight automated detection of unsafe information leakage via exceptions , 2014, ISSTA 2014.

[14]  Paulo Marques,et al.  Hidden truth behind .NETs exception handling today , 2007, IET Softw..

[15]  Nélio Cacho,et al.  eFlowMining: An Exception-Flow Analysis Tool for .NET Applications , 2011, 2011 Fifth Latin-American Symposium on Dependable Computing Workshops.

[16]  Flaviu Cristian,et al.  Exception Handling and Software Fault Tolerance , 1982, IEEE Transactions on Computers.

[17]  Paulo Marques,et al.  A transactional model for automatic exception handling , 2011, Comput. Lang. Syst. Struct..

[18]  Qiang Fu,et al.  Learning to Log: Helping Developers Make Informed Logging Decisions , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[19]  Alessandro F. Garcia,et al.  How Does Exception Handling Behavior Evolve? An Exploratory Study in Java and C# Applications , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

[20]  Yu Chin Cheng,et al.  Elsevier Editorial System(tm) for Journal of Systems and Software Manuscript Draft Exception Handling Refactorings: Directed by Goals and Driven by Bug Fixing , 2022 .

[21]  Paulo Marques,et al.  Exception Handling: A Field Study in Java and .NET , 2007, ECOOP.

[22]  Brad A. Myers,et al.  Examining Programmer Practices for Locally Handling Exceptions , 2016, 2016 IEEE/ACM 13th Working Conference on Mining Software Repositories (MSR).

[23]  Stanley B. Lippman C++ gems , 1996 .

[24]  Alessandro Orso,et al.  Automated support for development, maintenance, and testing in the presence of implicit flow control , 2004, Proceedings. 26th International Conference on Software Engineering.

[25]  Carlos José Pereira de Lucena,et al.  Assessing the Impact of Aspects on Exception Flows: An Exploratory Study , 2008, ECOOP.

[26]  Felipe Ebert,et al.  A Reflection on “An Exploratory Study on Exception Handling Bugs in Java Programs” , 2015, 2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER).

[27]  Diomidis Spinellis,et al.  Undocumented and unchecked: exceptions that spell trouble , 2014, MSR 2014.

[28]  P. M. Melliar-Smith,et al.  Software reliability: The role of programmed exception handling , 1977, Language Design for Reliable Software.

[29]  Kwangkeun Yi,et al.  An uncaught exception analysis for Java , 2004, J. Syst. Softw..

[30]  Sahithi Thandra,et al.  Analysis of Exception Handling Patterns in Java Projects: An Empirical Study , 2016, 2016 IEEE/ACM 13th Working Conference on Mining Software Repositories (MSR).

[31]  Diomidis Spinellis,et al.  Towards a Context Dependent Java Exceptions Hierarchy , 2017, 2017 IEEE/ACM 39th International Conference on Software Engineering Companion (ICSE-C).