sipush 0x11

Pushes a short, sign-extended to int.

Opcode
0x11 (17)
Family
Constants
Operands
  • 2 bytes: signed short value
Length
3 bytes
Operand stack
… → …, value (int)
Can throw
nothing at run time (beyond linking errors)

What it does

Pushes the signed two-byte operand as an int. javac uses it for int, short, byte and char constants from -32768 to 32767 that do not fit in a byte.

Larger constants go in the constant pool and are loaded with ldc.

How often javac uses it

In JDK 25.0.5's java.base module, sipush appears 34,361 times in 834 of its 7,391 classes: 1.8% of all instructions, the 19th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.<init>, java.io.BufferedOutputStream.initialBufferSize, java.io.BufferedReader.<init>, java.io.BufferedWriter.initialBufferSize.

Examples

From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; sipush is highlighted.

static int check(int n) in Constants, compiled by javac 25
9if (n > LIMIT) {
0iload_0 // n
1sipush 1000
10System.out.println(NAME + " exceeded");
7getstatic #9// System.out : PrintStream
10ldc #15// "limit exceeded"
12invokevirtual #17// PrintStream.println(String) : void
11return COMPUTED;
15getstatic #23// Constants.COMPUTED : int
13return (int) (BIG >> 38);

Open in the viewer

static int ints(int a, int b) in Tour, compiled by javac 25
… 21 instructions before
12x = (x << 3) | (x >> 2) ^ (x >>> 1) & 0xff;
23ishr
24iload_2 // x
27sipush 255
30iand
31ixor
32ior
33istore_2 // x
13return ~x;
34iload_2 // x
… 2 instructions after

Open in the viewer

Related instructions

iconst_0 Pushes the int constant 0.bipush Pushes a byte, sign-extended to int.ldc Pushes a constant from the constant pool (index in one byte).

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