Jump subroutine (wide index)
Bytecode
Type | Description |
u1 | jsr_w opcode = 0xC9 (201) |
s4 | branchoffset |
Description
This calls a local subroutine defined within the body of a method. It
is used to implement Java's finally clause.
jsr_w first pushes the address (pc + 5) onto the operand stack, where pc is the address of this jsr_w instruction in the bytecode. The address (pc + 5) is the address of instruction that immediately follows the jsr_w instruction in bytecode - it is used used by the ret instruction to return from the subroutine.
Next, execution branches to the address (pc + branchoffset), where pc is the address of the jsr_w opcode in the bytecode and branchoffset is the 32-bit signed integer parameter following the jsr_w opcode in the bytecode. If you are using Jasmin, branchoffset is computed for you from the address of <label>.
Notes
The jsr_w instruction is used with the ret instruction
in the implementation of the finally
clauses of the Java language. Note that jsr_w
pushes the address onto the stack and ret gets it out of a local variable. This
asymmetry is intentional.
Although the jsr_w instruction has a 4-byte branch offset, other factors limit the size of a Java method to 65535 bytes. This limit may be raised in a future release of the Java Virtual Machine.