KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jas > CatchEntry


1 /**
2  * This class
3  * is used to build up entries in a catch table.
4  * @see Catchtable
5  * @author $Author: fqian $
6  * @version $Revision: 1.1 $
7  */

8
9 package jas;
10
11 import java.io.*;
12
13 public class CatchEntry
14 {
15   Label start_pc, end_pc, handler_pc;
16   CP catch_cpe;
17   /**
18    * Catch entries are created and then added to the Catchtable.
19    * @param start Label marking the beginning of the area
20    * where the catch table is active.
21    * @param end Label marking the end of the area where the
22    * table is active.
23    * @param handler Label marking the entrypoint into the
24    * exception handling routine.
25    * @param cat (usually a classCP) informing the VM to direct
26    * any exceptions of this (or its subclasses) to the handler.
27    * @see Catchtable
28    */

29   public
30   CatchEntry(Label start, Label end, Label handler, CP cat)
31   {
32     start_pc = start;
33     end_pc = end;
34     handler_pc = handler;
35     catch_cpe = cat;
36   }
37
38   void resolve(ClassEnv e)
39   { if (catch_cpe != null) e.addCPItem(catch_cpe); }
40
41   void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
42     throws IOException, jasError
43   {
44     start_pc.writeOffset(ce, null, out);
45     end_pc.writeOffset(ce, null, out);
46     handler_pc.writeOffset(ce, null, out);
47     if (catch_cpe != null)
48       { out.writeShort(e.getCPIndex(catch_cpe)); }
49     else
50       { out.writeShort(0); }
51   }
52 }
53
Popular Tags