com.vladium.jcd.cls.attribute
Class DeclaredExceptionTable

java.lang.Object
  extended bycom.vladium.jcd.cls.attribute.DeclaredExceptionTable
All Implemented Interfaces:
java.lang.Cloneable, IClassFormatOutput, IDeclaredExceptionTable

final class DeclaredExceptionTable
extends java.lang.Object
implements IDeclaredExceptionTable

Author:
(C) 2001, Vlad Roubtsov

Field Summary
private  IntVector m_exceptions
           
 
Constructor Summary
(package private) DeclaredExceptionTable(int capacity)
           
 
Method Summary
 int add(int exception_index)
          Appends a new exception class pointer to the collection.
 java.lang.Object clone()
          Performs a deep copy.
 int get(int offset)
          Returns the CONSTANT_Class_info constant pool index for offset'th exception type thrown by the method that contains this this exception index table in its ExceptionsAttribute_info attribute.
 long length()
          Returns the total length of this table when converted to .class format [including 2 count bytes]
 int set(int offset, int exception_index)
          Replaces exception class pointer number 'offset' with new value 'interface_index'.
 int size()
          Returns the number of exception types the containing method professes to throw.
 void writeInClassFormat(UDataOutputStream out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_exceptions

private IntVector m_exceptions
Constructor Detail

DeclaredExceptionTable

DeclaredExceptionTable(int capacity)
Method Detail

get

public int get(int offset)
Description copied from interface: IDeclaredExceptionTable
Returns the CONSTANT_Class_info constant pool index for offset'th exception type thrown by the method that contains this this exception index table in its ExceptionsAttribute_info attribute.

Specified by:
get in interface IDeclaredExceptionTable
Parameters:
offset - thrown exception class number [must be in [0, size()) range]
Returns:
constant pool index [always positive]

size

public int size()
Description copied from interface: IDeclaredExceptionTable
Returns the number of exception types the containing method professes to throw.

Specified by:
size in interface IDeclaredExceptionTable

length

public long length()
Description copied from interface: IDeclaredExceptionTable
Returns the total length of this table when converted to .class format [including 2 count bytes]

Specified by:
length in interface IDeclaredExceptionTable

clone

public java.lang.Object clone()
Performs a deep copy.

Specified by:
clone in interface IDeclaredExceptionTable

writeInClassFormat

public void writeInClassFormat(UDataOutputStream out)
                        throws java.io.IOException
Specified by:
writeInClassFormat in interface IClassFormatOutput
Throws:
java.io.IOException

add

public int add(int exception_index)
Description copied from interface: IDeclaredExceptionTable
Appends a new exception class pointer to the collection. No duplicate checks are made.

Specified by:
add in interface IDeclaredExceptionTable
Parameters:
exception_index - constant pool index [must be positive; input not validated]
Returns:
offset of the new pointer [same as IDeclaredExceptionTable.size()-1 when called after this method]

set

public int set(int offset,
               int exception_index)
Description copied from interface: IDeclaredExceptionTable
Replaces exception class pointer number 'offset' with new value 'interface_index'. No duplicate checks are made. It is the responsibility of the caller to ensure that the relevant CONSTANT_Class_info descriptor will be found in the constant pool, in the slot pointed to by 'exception_index'.

Specified by:
set in interface IDeclaredExceptionTable
Parameters:
offset - thrown exception class number [must be in [0, size()) range]
exception_index - constant pool index [must be positive; input not validated]
Returns:
previous value at the given index [always positive]