jsr
Bytecode
Type | Description |
u1 | jsr opcode = 0xA8 (168) |
u2 | branchoffset |
Description
This calls a local subroutine defined within the body of a method. It is used to implement
Java's finally clause.
jsr first pushes the address (pc + 3) onto the operand stack, where pc is the address of this jsr instruction in the bytecode. The address (pc + 3) is the address of instruction that immediately follows the jsr 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 opcode in the bytecode and branchoffset is the 16-bit signed integer parameter following the jsr opcode in the bytecode. If you are using Jasmin, branchoffset is computed for you from the address of <label>.
Notes
The jsr instruction is used with the ret instruction in
the implementation of the finally
clauses of the Java language . Note that jsr
pushes the address onto the stack and ret gets it out of a local variable. This
asymmetry is intentional.