athrow 0xbf
Throws the exception on top of the stack.
- Opcode
0xbf(191)- Family
- Objects and types
- Operands
- none
- Length
- 1 byte
- Operand stack
…, objectref → …, objectref- Can throw
NullPointerException,IllegalMonitorStateException
What it does
Throws the exception on top of the stack. The JVM looks for a handler covering this instruction in the method's exception table; if there is none, the frame is popped and the search continues in the caller. Throwing null throws a NullPointerException instead.
javac emits it for throw, and at the end of every finally block's exception path, to rethrow what was caught.
How often javac uses it
In JDK 25.0.5's java.base module, athrow appears 16,191 times in 2,698 of its 7,391 classes: 0.83% of all instructions, the 34th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.getInIfOpen, java.io.BufferedOutputStream.<init>, java.io.BufferedReader.<init>, java.io.BufferedReader$1.hasNext.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; athrow is highlighted.
static String cast(Object o) in Tour, compiled by javac 25static int half(int n) in Asserts, compiled by javac 25Related instructions
new Allocates an object (uninitialised until its constructor runs).monitorexit Pops an object and unlocks its monitor.return Returns from a void method.
Specification: JVMS §6.5, athrow (Java SE 25).