summaryrefslogtreecommitdiff
path: root/core/java12/com/vladium/jcd/cls/attribute/IExceptionHandlerTable.java
blob: 572ac2774b748210b1792d3857ba6f62cbab3bfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
 * 
 * This program and the accompanying materials are made available under
 * the terms of the Common Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/cpl-v10.html
 * 
 * $Id: IExceptionHandlerTable.java,v 1.1.1.1 2004/05/09 16:57:48 vlad_r Exp $
 */
package com.vladium.jcd.cls.attribute;

import com.vladium.jcd.compiler.IClassFormatOutput;

// ----------------------------------------------------------------------------
/**
 * This table is a structure nested within the {@link CodeAttribute_info}.
 * It is a table of {@link Exception_info} entries, each entry representing an
 * exception handler range. The order of these entries is the order in which
 * a JVM will check for a matching exception handler when the parent method
 * throws an exception.
 * 
 * @author (C) 2001, Vlad Roubtsov
 */
public
interface IExceptionHandlerTable extends Cloneable, IClassFormatOutput
{
    // public: ................................................................

    // ACCESSORS:
    
    /**
     * Returns {@link Exception_info} descriptor at a given offset.
     * 
     * @param offset exception offset [must be in [0, size()) range; input not checked]
     * @return Exception_info descriptor [never null]
     * 
     * @throws IndexOutOfBoundsException if 'offset' is outside of valid range
     */
    Exception_info get (int offset);
    
    /**
     * Returns the number of descriptors in this collection [can be 0].
     */
    int size ();
    
    /**
     * Returns the total length of this table when converted to
     * .class format [including 2 count bytes]
     */
    long length ();
    
    // Cloneable: adjust the access level of Object.clone():
    Object clone ();


    // MUTATORS:
    
    /**
     * Adds a new Exception_info descriptor to this collection. No duplicate
     * checks are made. It is the responsibility of the caller to ensure
     * that all data referenced in 'exception' will eventually be consistent
     * with method's bytecode and the class's constant pool.
     * 
     * @param exception new exception descriptor [may not be null]
     */
    int add (Exception_info exception);
    
    /**
     * Replaces the Exception_info descriptor at a given offset. No duplicate
     * checks are made. No exception type compatibility checks are made. It is
     * the responsibility of the caller to ensure that all data referenced
     * in 'exception' will eventually be consistent with method's bytecode and
     * the class's constant pool.
     * 
     * @param offset exception offset [must be in [0, size()) range; input not checked]
     * @param exception new exception descriptor [may not be null]
     * @return previous exception descriptor at this offset [never null]
     * 
     * @throws IndexOutOfBoundsException if 'offset' is outside of valid range
     */
    Exception_info set (int offset, Exception_info exception);
    
} // end of interface
// ----------------------------------------------------------------------------