pop 0x57
Discards the top stack slot.
- Opcode
0x57(87)- Family
- Stack manipulation
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value → …- Can throw
- nothing at run time (beyond linking errors)
What it does
Discards the top value. javac emits it when a method's result is ignored, as in a call used as a statement: list.add(x); calls a method that returns a boolean, then pops it.
The value must be one slot (not a long or double); pop2 discards those.
How often javac uses it
In JDK 25.0.5's java.base module, pop appears 15,497 times in 2,445 of its 7,391 classes: 0.79% of all instructions, the 35th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.transferTo, java.io.BufferedReader.read, java.io.BufferedReader$1.<init>, java.io.BufferedWriter.write.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; pop is highlighted.
static void discard() in Tour, compiled by javac 25Peek(Nestmates) in Nestmates.Peek, compiled by javac 25Related instructions
pop2 Discards the top two stack slots (or one long or double).dup Duplicates the top of the stack.dup_x1 Duplicates the top value and inserts it two slots down.
Specification: JVMS §6.5, pop (Java SE 25).