Recommendation of Exception Handling Code in Mobile App Development

In modern programming languages, exception handling is an effective mechanism to avoid unexpected runtime errors. Thus, failing to catch and handle exceptions could lead to serious issues like system crashing, resource leaking, or negative end-user experiences. However, writing correct exception handling code is often challenging in mobile app development due to the fast-changing nature of API libraries for mobile apps and the insufficiency of their documentation and source code examples. Our prior study shows that in practice mobile app developers cause many exception-related bugs and still use bad exception handling practices (e.g. catch an exception and do nothing). To address such problems, in this paper, we introduce two novel techniques for recommending correct exception handling code. One technique, XRank, recommends code to catch an exception likely occurring in a code snippet. The other, XHand, recommends correction code for such an occurring exception. We have developed ExAssist, a code recommendation tool for exception handling using XRank and XHand. The empirical evaluation shows that our techniques are highly effective. For example, XRank has top-1 accuracy of 70% and top-3 accuracy of 87%. XHand's results are 89% and 96%, respectively.

[1]  George C. Necula,et al.  Finding and preventing run-time error handling mistakes , 2004, OOPSLA.

[2]  Martin P. Robillard,et al.  Enforcing Exception Handling Policies with a Domain-Specific Language , 2016, IEEE Transactions on Software Engineering.

[3]  Hung Viet Nguyen,et al.  Graph-based pattern-oriented, context-sensitive source code completion , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[4]  Arie van Deursen,et al.  Unveiling Exception Handling Bug Hazards in Android Based on GitHub and Google Code Issues , 2015, MSR.

[5]  Tung Thanh Nguyen,et al.  Recommending API Usages for Mobile Apps with Hidden Markov Model , 2015, 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[6]  Arie van Deursen,et al.  Discovering faults in idiom-based exception handling , 2006, ICSE '06.

[7]  Trevor Hastie,et al.  The Elements of Statistical Learning , 2001 .

[8]  Chanchal Kumar Roy,et al.  On the Use of Context in Recommending Exception Handling Code Examples , 2014, 2014 IEEE 14th International Working Conference on Source Code Analysis and Manipulation.

[9]  George C. Necula,et al.  Mining Temporal Specifications for Error Detection , 2005, TACAS.

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

[11]  Daniel Tarlow,et al.  Structured Generative Models of Natural Source Code , 2014, ICML.

[12]  Mira Mezini,et al.  Heuristic Strategies for Recommendation of Exception Handling Code , 2012, 2012 26th Brazilian Symposium on Software Engineering.

[13]  Ahmed Tamrawi,et al.  Fuzzy set approach for automatic tagging in evolving software , 2010, 2010 IEEE International Conference on Software Maintenance.

[14]  Anh Tuan Nguyen,et al.  A statistical semantic language model for source code , 2013, ESEC/FSE 2013.

[15]  Anh Tuan Nguyen,et al.  Graph-Based Statistical Language Model for Code , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[16]  Weiyi Shang,et al.  Studying the Relationship between Exception Handling Practices and Post-Release Defects , 2018, 2018 IEEE/ACM 15th International Conference on Mining Software Repositories (MSR).

[17]  Ferosh Jacob,et al.  Code template inference using language models , 2010, ACM SE '10.

[18]  Hong Mei,et al.  Mining repair model for exception-related bug , 2018, J. Syst. Softw..

[19]  Gabriele Bavota,et al.  API change and fault proneness: a threat to the success of Android apps , 2013, ESEC/FSE 2013.

[20]  Rossana M. de Castro Andrade,et al.  Preventing Erosion in Exception Handling Design Using Static-Architecture Conformance Checking , 2017, ECSA.

[21]  Diomidis Spinellis,et al.  The exception handling riddle: An empirical study on the Android API , 2018, J. Syst. Softw..

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

[23]  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).

[24]  Tao Xie,et al.  Mining exception-handling rules as sequence association rules , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[25]  Ahmed Tamrawi,et al.  Fuzzy set-based automatic bug triaging: NIER track , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[26]  Sandeep K. Singh,et al.  An Automated approach for Bug Categorization using Fuzzy Logic , 2015, ISEC.

[27]  Roberta Coelho,et al.  Improving developers awareness of the exception handling policy , 2018, 2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER).

[28]  Christoph Treude,et al.  Unveiling Exception Handling Guidelines Adopted by Java Developers , 2019, 2019 IEEE 26th International Conference on Software Analysis, Evolution and Reengineering (SANER).

[29]  Hoan Anh Nguyen,et al.  Graph-based mining of multiple object usage patterns , 2009, ESEC/FSE '09.

[30]  Jiangang Zhu,et al.  EXPSOL: Recommending Online Threads for Exception-Related Bug Reports , 2016, 2016 23rd Asia-Pacific Software Engineering Conference (APSEC).

[31]  Tung Thanh Nguyen,et al.  Learning API Usages from Bytecode: A Statistical Approach , 2015, 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).

[32]  Eran Yahav,et al.  Code completion with statistical language models , 2014, PLDI.

[33]  George J. Klir,et al.  Fuzzy sets and fuzzy logic - theory and applications , 1995 .

[34]  Zhendong Su,et al.  On the naturalness of software , 2012, ICSE 2012.

[35]  Premkumar T. Devanbu,et al.  On the localness of software , 2014, SIGSOFT FSE.

[36]  Ahmed Tamrawi,et al.  Fuzzy set and cache-based approach for bug triaging , 2011, ESEC/FSE '11.

[37]  Weiyi Shang,et al.  Revisiting Exception Handling Practices with Exception Flow Analysis , 2017, 2017 IEEE 17th International Working Conference on Source Code Analysis and Manipulation (SCAM).

[38]  Charles A. Sutton,et al.  Learning natural coding conventions , 2014, SIGSOFT FSE.

[39]  Charles A. Sutton,et al.  Mining source code repositories at massive scale using language modeling , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).