Abstract
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 are proven to enhance the practice of software reliability, comprehension, and maintenance. Having acknowledged the advantages of exception handling features, the misuse of them can still cause catastrophic software failures, such as application crash. Prior studies suggested anti-patterns of exception handling; while little knowledge was shared about the prevalence of these anti-patterns. In this paper, we investigate the prevalence of exception-handling anti-patterns. We collected a thorough list of exception anti-patterns from 16 open-source Java and C# libraries and applications using an automated exception flow analysis tool. We found that although exception handling anti-patterns widely exist in all of our subjects, only a few anti-patterns (e.g. Unhandled Exceptions, Catch Generic, Unreachable Handler, Over-catch, and Destructive Wrapping) can be commonly identified. On the other hand, we find that the prevalence of anti- patterns illustrates differences between C# and Java. Our results call for further in-depth analyses on the exception handling practices across different languages.
Read more about our paper: Paper
If you use our data or code, please cite our paper. BibTex
Evaluated Subject Projects
The subject projects are 16 open-source softwares. To reproduce our study, the releases we analysed can be found in the links below.
C# Project | Release | Java Project | Release |
---|---|---|---|
Glimpse | 1.8.6 | Apache ANT | rel/1.9.7 |
Google API | v1.15.0 | Eclipse JDT Core | I20160803-2000 |
OpenRA | release-20160508 | Elasticsearch | v2.4.0 |
ShareX | v11.1.0 | Guava | v19.0 |
SharpDevelop | 5.0.0 | Hadoop Common | rel/release-2.6.4 |
SignalR | 2.2.1 | Hadoop HDFS | rel/release-2.6.4 |
Umbraco-CMS | release-7.5.0 | Hadoop MapReduce | rel/release-2.6.4 |
- | - | Hadoop YARN | rel/release-2.6.4 |
- | - | Spring Framework | v4.3.2.RELEASE |
Exception Flow Analyzer
Our analyzer parse try-catch blocks and traverse call graphs of the subject projects. We use .NET Compiler Platform (“Roslyn”) for C# and Eclipse Java development tools (JDT) for Java.
The source code and binary files of the two source-code analysis tools we developed are available below.
Java Binary and Source
C# Binary and Source
Data Output and Visualizations
The Summary data and Full data can be visible (and also downloaded as CSV file) using the following Tableau Public Visualizations. To Download, click the bottom right button (“Download”) in the Tableau frame. Choose Data option then you can choose Summary or Full Data in the pop-up window that will come up.
The full data sources can also be downloaded here: Exported Data sources
Catch Anti-Patterns
Throws Anti-Patterns
More on .NET and Java Exception Handling
To understand more about Exception Handling, check .Net and Java documentation.
Chapter 11. Exceptions - Java SE Specification
Handling and Throwing Exceptions - .NET Framework Documentation