Exception handling facilities are useful but dangerous. Many modern programming languages such as C++, Java, Ada, Modula-3, and ML provide the programmer with exception mechanisms. However, the exception facilities can provide a hole for program safety. Even for type-safe programming languages like ML, exceptions provide a hole for program safety. ML programs can abruptly halt when an exception is raised and never handled. This is the only one "safety hole" in well-typed ML programs.
Multithreaded exception handling is not well supported. Even though many languages offer both exception handling and multithreading mechanisms, they do not provide a good method to use these two features together. Although Java provides a simple and tightly integrated language support for multithreaded programs, throwing exceptions across threads is deprecated because of the safety problem.
In this thesis, we present two static analyses that detect potential runtime exceptions that are raised and never handled. We first design such an analysis for single-threaded ML programs and then for multithtreaded Java programs. We found that even though the exception flow and control flow are in general intertwined in ML programs, the two analyses could be safely and cost-effectively decoupled. For cases where exceptions carry functions(i.e., where control flow analysis needs exception analysis) our control flow analysis uses a crude approximation to assure its safety against the decoupling. In Java, throwing exceptions across threads is deprecated because of the safety problem. Instead of restricting programmers` freedom, we extend the Java language to support multithreaded exception handling and propose a tool to detect uncaught exceptions. Our analysis firstly estimates concurrently evaluated expressions among threads, and then predicts uncaught exceptions by using the pre-analyzed concurrency information.
Our method can be applied to other languages with exception handling facilities....