Exception-Handling bugs in java and a language extension to avoid them

  • Authors:
  • Westley Weimer

  • Affiliations:
  • University of Virginia, Charlottesville, Virginia

  • Venue:
  • Advanced Topics in Exception Handling Techniques
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

It is difficult to write programs that behave correctly in the presence of exceptions. We describe a dataflow analysis for finding a certain class of mistakes made while programs handle exceptions. These mistakes involve resource leaks and failures to restore program-specific invariants. Using this analysis we have found over 1,200 bugs in 4 million lines of Java. We give some evidence of the importance of the bugs we found and use them to highlight some limitations of destructors and finalizers. We propose and evaluate a new language feature, the compensation stack, to make it easier to write solid code in the presence of exceptions. These compensation stacks track obligations and invariants at run-time. Two case studies demonstrate that they can yield more natural source code and more consistent behavior in long-running programs.