Abstract
Unhandled exceptions crash programs, so a compile-time check that exceptions are handled should in principle make software more reliable. But designers of some recent languages have argued that the benefits of statically checked exceptions are not worth the costs. We introduce a new statically checked exception mechanism that addresses the problems with existing checked-exception mechanisms. In particular, it interacts well with higher-order functions and other design patterns. The key insight is that whether an exception should be treated as a "checked" exception is not a property of its type but rather of the context in which the exception propagates. Statically checked exceptions can "tunnel" through code that is oblivious to their presence, but the type system nevertheless checks that these exceptions are handled. Further, exceptions can be tunneled without being accidentally caught, by expanding the space of exception identifiers to identify the exception-handling context. The resulting mechanism is expressive and syntactically light, and can be implemented efficiently. We demonstrate the expressiveness of the mechanism using significant codebases and evaluate its performance. We have implemented this new exception mechanism as part of the new Genus programming language, but the mechanism could equally well be applied to other programming languages.
- Ada 95. Ada 95 reference manual: language and standard libraries, 1997.Google Scholar
- Apache Commons. The Apache Commons project. https: //commons.apache.org/.Google Scholar
- A. P. Black. Exception handling: The case against. PhD thesis, University of Oxford, 1982.Google Scholar
- S. M. Blackburn, R. Garner, C. Hoffmann, A. M. Khang, K. S. McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. E. B. Moss, A. Phansalkar, D. Stefanovi´c, T. VanDrunen, D. von Dincklage, and B. Wiedermann. The DaCapo benchmarks: Java benchmarking development and analysis. In 21st ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 169–190, 2006. Google Scholar
Digital Library
- M. Bravenboer and Y. Smaragdakis. Exception analysis and points-to analysis: Better together. In Proceedings of the Eighteenth International Symposium on Software Testing and Analysis, ISSTA ’09, 2009. Google Scholar
Digital Library
- P. A. Buhr and W. Y. R. Mok. Advanced exception handling mechanisms. IEEE Trans. Softw. Eng., 26(9), Sept. 2000. Google Scholar
Digital Library
- B. Cabral and P. Marques. Exception handling: A field study in Java and .NET. In 21st European Conf. on Object-Oriented Programming, pages 151–175, 2007. Google Scholar
Digital Library
- B. Cabral and P. Marques. Hidden truth behind .NET’s exception handling today. IET Software, 1(6), 2007.Google Scholar
- B. Cahoon and K. S. McKinley. Data flow analysis for software prefetching linked data structures in Java. In International Conference on Parallel Architectures and Compilation Techniques (PACT), Sept. 2001. Google Scholar
Digital Library
- CWE. Common weakness enumeration list. http://cwe. mitre.org/data/.Google Scholar
- B. Eckel. Does Java need checked exceptions? http://www. mindview.net/Etc/Discussions/CheckedExceptions, 2003.Google Scholar
- M. Fähndrich, J. S. Foster, A. Aiken, and J. Cu. Tracking down exceptions in standard ML programs. Technical report, EECS Department, UC Berkeley, 1998. Google Scholar
Digital Library
- FindBugs bug descriptions. Findbugs bug descriptions. http: //findbugs.sourceforge.net/bugDescriptions.html/.Google Scholar
- R. B. Findler and M. Felleisen. Contracts for higher-order functions. In 7th ACM SIGPLAN Int’l Conf. on Functional Programming, 2002. Google Scholar
Digital Library
- R. B. Findler, M. Latendresse, and M. Felleisen. Behavioral contracts and behavioral subtyping. In ESEC/FSE-9, 2001. Google Scholar
Digital Library
- A. F. Garcia, C. M. Rubira, A. Romanovsky, and J. Xu. A comparative study of exception handling mechanisms for building dependable object-oriented software. Journal of Systems and Software, 2001. Google Scholar
Digital Library
- B. Goetz. Java theory and practice: The exceptions debate. http://www.ibm.com/developerworks/library/ j-jtp05254, 2004.Google Scholar
- B. Goetz. Exception transparency in Java. http: //blogs.oracle.com/briangoetz/entry/exception_ transparency_in_java, 2010.Google Scholar
- J. B. Goodenough. Exception handling: Issues and a proposed notation. Comm. of the ACM, 18:683–696, Dec. 1975. Google Scholar
Digital Library
- J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification. Addison Wesley, 3rd edition, 2005. ISBN 0321246780.Google Scholar
- D. Grossman, G. Morrisett, T. Jim, M. Hicks, Y. Wang, and J. Cheney. Region-based memory management in Cyclone. In ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI), pages 282–293, 2002. Google Scholar
Digital Library
- A. Hejlsberg, B. Venners, and B. Eckel. Remaining neutral on checked exceptions. http://www.artima.com/intv/ handcuffs.html, 2003.Google Scholar
- A. Hejlsberg, S. Wiltamuth, and P. Golde. The C# Programming Language. Addison-Wesley, 1st edition, Oct. 2003. ISBN 0321154916.Google Scholar
- D. Leijen. Koka: Programming with row polymorphic effect types. In 5th Workshop on Mathematically Structured Functional Programming, 2014.Google Scholar
Cross Ref
- X. Leroy and F. Pessaux. Type-based analysis of uncaught exceptions. ACM Trans. on Programming Languages and Systems, 22(2), Mar. 2000. Google Scholar
Digital Library
- B. Liskov and A. Snyder. Exception handling in CLU. IEEE Transactions on Software Engineering, SE-5(6):546–558, Nov. 1979. Google Scholar
Digital Library
- B. H. Liskov and J. M. Wing. A behavioral notion of subtyping. ACM Trans. on Programming Languages and Systems, 16(6), Nov. 1994. Google Scholar
Digital Library
- M. D. MacLaren. Exception handling in PL/I. In Proceedings of an ACM Conference on Language Design for Reliable Software, 1977. Google Scholar
Digital Library
- L. Mastrangelo, L. Ponzanelli, A. Mocci, M. Lanza, M. Hauswirth, and N. Nystrom. Use at your own risk: The Java Unsafe API in the wild. In 2015 ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), 2015. Google Scholar
Digital Library
- B. Meyer. Eiffel: The Language. 1992. Google Scholar
Digital Library
- Microsoft Corporation. Microsoft C# Language Specifications. Microsoft Press, 2001. ISBN 0-7356-1448-2. Google Scholar
Digital Library
- R. Milner, M. Tofte, and R. Harper. The Definition of Standard ML. MIT Press, Cambridge, MA, 1990. Google Scholar
Digital Library
- J. G. Mitchell, W. Maybury, and R. Sweet. Mesa language manual. Technical Report CSL-78-1, Xerox Research Center, Palo Alto, CA, Feb. 1978.Google Scholar
- G. Nelson, editor. Systems Programming with Modula-3. Prentice-Hall, 1991. Google Scholar
Digital Library
- N. Nystrom, M. R. Clarkson, and A. C. Myers. Polyglot: An extensible compiler framework for Java. In 12th Int’l Conf. on Compiler Construction (CC’03), pages 138–152, Apr. 2003. Google Scholar
Digital Library
- M. Odersky. The Scala Language Specification. EPFL, 2014. Version 2.9.Google Scholar
- OpenJDK javac. The javac compiler. http://hg.openjdk. java.net/.Google Scholar
- S. Peyton Jones. Haskell 98 language and libraries: the revised report. Cambridge University Press, 2003.Google Scholar
- A. Rastogi, A. Chaudhuri, and B. Hosmer. The ins and outs of gradual type inference. In 39th ACM Symp. on Principles of Programming Languages (POPL), 2012. Google Scholar
Digital Library
- M. P. Robillard and G. C. Murphy. Designing robust Java programs with exceptions. In Proceedings of the 8th ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE-8), 2000. Google Scholar
Digital Library
- L. Rytz, M. Odersky, and P. Haller. Lightweight polymorphic effects. In 26th European Conf. on Object-Oriented Programming, 2012. Google Scholar
Digital Library
- S. Sinha and M. J. Harrold. Analysis and testing of programs with exception handling constructs. IEEE Transactions on Software Engineering, 26(9), Sept. 2000. Google Scholar
Digital Library
- G. L. Steele, Jr. Common LISP: the Language. Digital Press, second edition, 1990. ISBN 1-55558-041-6. Google Scholar
Digital Library
- B. Stroustrup. The C++ Programming Language. Addison-Wesley, 1987. Google Scholar
Digital Library
- SunFlow. SunFlow: the open-source rendering engine. Opensource software, 2007.Google Scholar
- Swift 2014. Swift programming language. https:// developer.apple.com/swift/resources, 2014.Google Scholar
- M. van Dooren and E. Steegmans. Combining the robustness of checked exceptions with the flexibility of unchecked exceptions using anchored exception declarations. In 20th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), 2005. Google Scholar
Digital Library
- B. Venners. Failure and exceptions: A conversation with James Gosling, Part II. http://www.artima.com/intv/solid.html, 2003.Google Scholar
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In 16th ACM Symp. on Principles of Programming Languages (POPL), 1989. Google Scholar
Digital Library
- P. Wadler and R. B. Findler. Well-typed programs can’t be blamed. In European Symposium on Programming, 2009. Google Scholar
Digital Library
- R. Waldhoff. Java’s checked exceptions were a mistake. http://radio-weblogs.com/0122027/stories/2003/ 04/01/JavasCheckedExceptionsWereAMistake.html, 2003.Google Scholar
- W. Weimer and G. C. Necula. Exceptional situations and program reliability. ACM Trans. on Programming Languages and Systems, 30(2), Mar. 2008. Google Scholar
Digital Library
- Y. Zhang, M. C. Loring, G. Salvaneschi, B. Liskov, and A. C. Myers. Lightweight, flexible object-oriented generics. In 36th ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI), pages 436–445, June 2015. Google Scholar
Digital Library
- Y. Zhang, G. Salvaneschi, Q. Beightol, B. Liskov, and A. C. Myers. Accepting blame: Expressive checked exceptions. Technical Report http://hdl.handle.net/1813/43784, Cornell University Computing and Information Science, Apr. 2016.Google Scholar
Index Terms
Accepting blame for safe tunneled exceptions
Recommendations
Accepting blame for safe tunneled exceptions
PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and ImplementationUnhandled exceptions crash programs, so a compile-time check that exceptions are handled should in principle make software more reliable. But designers of some recent languages have argued that the benefits of statically checked exceptions are not ...
Efficient Java exception handling in just-in-time compilation
Research ArticlesJava uses exceptions to provide elegant error handling capabilities during program execution. However, the presence of exception handlers complicates the job of the just-in-time (JIT) compiler, while exceptions are rarely used in most programs. This ...
Combining the robustness of checked exceptions with the flexibility of unchecked exceptions using anchored exception declarations
OOPSLA '05: Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applicationsEver since their invention 30 years ago, checked exceptions have been a point of much discussion. On the one hand, they increase the robustness of software by preventing the manifestation of unanticipated checked exceptions at run-time. On the other ...







Comments