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 25
90Long.parseLong("1");
0ldc #41// "1"
2invokestatic #43// Long.parseLong(String) : long
91Integer.parseInt("2");
6ldc #49// "2"
8invokestatic #51// Integer.parseInt(String) : int
11pop
92}

Open in the viewer

Peek(Nestmates) in Nestmates.Peek, compiled by javac 25
9class Peek {
0aload_0 // this
1aload_1 // this$0
2dup
3invokestatic #1// Objects.requireNonNull(Object) : Object
6pop
7putfield #7// Nestmates$Peek.this$0 : Nestmates
10aload_0 // this
11invokespecial #13// new Object()

Open in the viewer

Related 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).