CMU-ISRI-05-102
Institute for Software Research International
School of Computer Science, Carnegie Mellon University



CMU-ISRI-05-102

Statically-Scoped Exceptions:
A Typed Foundation for Aspect-Oriented Error Handling

Neel Krishnaswami, Jonathan Aldrich

January 2005

This report was originally published on the web in January 2004.

CMU-ISRI-05-102.ps
CMU-ISRI-05-102.pdf


Keywords: Statically-scoped exceptions, aspect-oriented programming


Aspect-oriented programming systems such as AspectJ provide mechanisms for modularizing crosscutting error-handling concerns. However, AspectJ's advice does not integrate well with Java's checked exception mechanism. Furthermore, conventional exception-handling facilities such as AspectJ's share the problem of accidental exception capture due to the dynamic nature of exception-handling semantics.

We propose statically-scoped exceptions as an alternative mechanism for error-handling. In our system, a thrown exception is caught by the nearest lexically-enclosing exception handler, rather than the nearest handler on the call stack. Using static scoping allows us to achieve better modularization, as with AspectJ, and also precudes the problem of exception capture. We provide a static type system that tracks exceptions precisely and ensures that statically-scoped exceptions cannot be misused to cause continuation-like behavior. We hope that our system will serve as a foundation for error handling mechanisms that combine good modularization with strong static reasoning about errors.

10 pages


Return to: SCS Technical Report Collection
School of Computer Science homepage

This page maintained by reports@cs.cmu.edu