-
Notifications
You must be signed in to change notification settings - Fork 0
Exceptions table management
These functions manage the exceptions table section of the Java class file. The exceptions table describes the exception handlers for different sections of the bytecode.
-
void exceptions_start()
Initializes the exceptions table. Reserves space for theexception_table_lengthand starts the counter for entries. -
void exception_entry(uint16_t start_pc, uint16_t end_pc, uint16_t handler_pc, uint16_t catch_type)
Adds an entry to the exception table for a specific range of bytecode instructions and their associated exception handler. -
void exceptions_end()
Finalizes the exceptions table by patching theexception_table_lengthat the reserved location.
-
void patch_u2(size_t pos, uint16_t v)
Updates a 2-byte value in the buffer (used to finalizeexception_table_length). -
size_t current_offset()
Returns the current offset in the bytecode buffer.
exceptions_start();
exception_entry(0, 10, 20, 1); // Defines an exception handler for a specific bytecode range
exception_entry(30, 50, 60, 2); // Another exception handler
exceptions_end();This will generate an exceptions table with two entries.