Homework: Exception

Problem 1: (Exception handling library for C) In this exrecise, we would like to add a "poor-man's" exception handling mechanism to C, in order to understand the "longjmp-based" exception handling technique. First, download the code skeleton we offered, and read it carefully. This code demonstrates one specific method to make a library-style exception handling mechnism for C.

Compile the program and run:

  $ gcc main.c estack.c
  $ ./a.out
Question: explain briefly how the last line message print:
Uncaught exception: in file: "main.c", at line: 48 with value 99. Exiting...
Problem 2: Downdload this Java program, compile and then dis-assemble it:
  $ javac Main.java
  $ javap -c Main
Answer the following questions:
Question 1: the exception table for method main looks like:
Exception table:
       from    to  target type
           8    16    19   Class java/lang/Exception
           0    28    31   Class java/lang/Exception
Can we change the order of these two table entry, that is, can we change it to:
Exception table:
       from    to  target type
           0    28    31   Class java/lang/Exception
           8    16    19   Class java/lang/Exception
Question 2: the exception table for method f looks like:
   Exception table:
       from    to  target type
           0     8    19   Class java/lang/Exception
           0     8    39   any
          19    28    39   any
          39    40    39   any
Explain the meaning of every table entry.