Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Exception handling implemented by programming languages?

I wanted to gain in-depth understanding of how programming languages implements exception handling and how exactly it works inside the hood. I have try to phrase this in many sub-questions as below.

  1. What is the mechanism used by programing languages to implement try { } catch { } blocks (under the hood)?
  2. How exactly stack unwinding works inside?
  3. What are the key differences between try { } / catch {} implementations between different languages like C++ and Java? Do they offer differ significantly or are they same?
  4. Is setjump/longjump method of stack rewinding in C is similar to try/throw/catch block?
  5. Why do people say that "stack unwinding" is costly?
  6. What exactly is SEH (Structured Exception Handling?)
like image 341
Dipan Mehta Avatar asked Nov 04 '11 04:11

Dipan Mehta


People also ask

How do you implement exception handling?

The try-catch is the simplest method of handling exceptions. Put the code you want to run in the try block, and any Java exceptions that the code throws are caught by one or more catch blocks. This method will catch any type of Java exceptions that get thrown. This is the simplest mechanism for handling exceptions.

What is exception handling in programming language?

Exception handling is the process of responding to unwanted or unexpected events when a computer program runs. Exception handling deals with these events to avoid the program or system crashing, and without this process, exceptions would disrupt the normal operation of a program.

What is exception handling how it is implemented in Java?

Java Exception Handling is a mechanism to handle runtime errors such as ClassNotFoundException, IOException, SQLException, RemoteException, etc. Exception is an unwanted or unexpected event, which occurs during the execution of a program, i.e. at run time, that disrupts the normal flow of the program's instructions.

How exception handling is implemented in Python?

In Python, exceptions can be handled using a try statement. The critical operation which can raise an exception is placed inside the try clause. The code that handles the exceptions is written in the except clause. We can thus choose what operations to perform once we have caught the exception.


1 Answers

This is a nice description of how exception handling works, https://gforge.inria.fr/frs/download.php/26600/PBE2-Exceptions-2010-03-02.pdf

like image 97
akuhn Avatar answered Sep 28 '22 01:09

akuhn