Site Tools

Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:6.9.1_exception_handler_info

6.9.1 exception_handler_info

The exception_handler_info structure is defined as follows:

The items in the exception_handler_info structure are as follows:

start_offset, active_length

The start_offset and active_length pair indicate the active range (try block) an exception handler. The start_offset item indicates the beginning of the active range while the active_length item indicates the number of bytes contained in the active range.

end_offset is defined as start_offset plus active_length.

The start_offset item and end_offset are byte offsets into the info item of the Method Component. The value of the start_offset must be a valid offset into a bytecodes array of a method_info structure to an opcode of an instruction. The value of the end_offset either must be a valid offset into a bytecodes array of the same method_info structure to an opcode of an instruction, or must be equal to the method's bytecode count, the length of the bytecodes array of the method_info structure. The value of the start_offset must be less than the value of the end_offset.

The start_offset is inclusive and the end_offset is exclusive; that is, the exception handler must be active while the execution address is within the interval [start_offset, end_offset).

stop_bit

The stop_bit item indicates whether the active range (try block) of this exception handler is contained within or is equal to the active range of any succeeding exception_handler_info structures in this exception_handlers array. At the Java source level, this indicates whether an active range is nested within another, or has at least one succeeding exception handler associated with the same range. The latter occurs when there is at least one succeeding catch block or a finally block.

The stop_bit item is equal to 1 if the active range does not intersect with a succeeding exception handler's active range, and this exception handler is the last handler applicable to the active range. It is equal to 0 if the active range is contained within the active range of another exception handler, or there is at least one succeeding handler applicable to the same active range.

The stop_bit provides an optimization to be used during the interpretation of the athrow bytecode. As the interpreter searches for an appropriate exception handler, it may terminate the search of the exception handlers in this Method Component under the following conditions:

  • the location of the current program counter is less than the end_offset of this exception handler, and
  • the stop_bit of this exception handler is equal to 1.

When these conditions are satisfied it is guaranteed that none of the succeeding exception handlers in this Method Component will contain an active range appropriate for the current exception.

In CODE EXAMPLE 6-1, the stop_bit item is set for both the third and fourth handlers.

handler_offset

The handler_offset item represents a byte offset into the info item of the Method Component. It indicates the start of the exception handler. At the Java source level, this is equivalent to the beginning of a catch or finally block. The value of the item must be a valid offset into a bytecodes array of a method_info structure to an opcode of an instruction, and must be less than the value of the method's bytecode count.

catch_type_index

If the value of the catch_type_index item is non-zero, it must be a valid index into the constant_pool[] array of the Constant Pool Component ( Section 6.7, Constant Pool Component). The constant_pool[] entry at that index must be a CONSTANT_Classref_info structure, representing the class of the exception caught by this exception_handlers array entry.

If the exception_handlers table entry represents a finally block, the value of the catch_type_index item is zero. In this case the exception handler is called for all exceptions that are thrown within the start_offset and end_offset range.

The order of constants in the constant pool is constrained such that all entries referenced by catch_type_index items that represent catch block (not finally blocks) are located at non-zero entries.

javacard/jcvm/6.9.1_exception_handler_info.txt · Last modified: 2017/05/13 04:12 (external edit)