swap 0x5f

Swaps the top two values.

Opcode
0x5f (95)
Family
Stack manipulation
Operands
none
Length
1 byte
Operand stack
…, value2, value1 → …, value1, value2
Can throw
nothing at run time (beyond linking errors)

What it does

Swaps the top two values (both one slot; there is no swap for longs and doubles). javac does not generate it for Java source: java.base does not contain a single one. Other compilers and bytecode generators use it.

How often javac uses it

It does not appear anywhere in JDK 25.0.5's java.base module: none of its 7,391 classes uses it.

Related instructions

pop Discards the top stack slot.pop2 Discards the top two stack slots (or one long or double).dup Duplicates the top of the stack.

Specification: JVMS §6.5, swap (Java SE 25).