invokestatic 0xb8

Calls a static method.

Opcode
0xb8 (184)
Family
Method calls
Operands
  • 2 bytes: constant pool index
Length
3 bytes
Operand stack
…, arg1, … → …, result
Can throw
nothing at run time (beyond linking errors)

What it does

Calls a static method: no receiver, no dispatch. The first call initialises the method's class. Since Java 8 it can also call static methods of interfaces, through an InterfaceMethodref.

javac also uses it for the synthetic access$ methods of old inner classes and for Integer.valueOf when it boxes an int. If the method returns void, nothing is pushed. Long and double arguments take two stack slots each.

How often javac uses it

In JDK 25.0.5's java.base module, invokestatic appears 52,122 times in 4,455 of its 7,391 classes: 2.7% of all instructions, the 10th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.fill, java.io.BufferedOutputStream.initialBufferSize, java.io.BufferedReader.fill, java.io.BufferedReader$1.<init>.

Examples

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

String call() in Nestmates.Peek, compiled by javac 25
15return hidden();
0invokestatic #25// Nestmates.hidden() : String

Open in the viewer

static { … } in Constants, compiled by javac 25
6static final int COMPUTED = Integer.parseInt("7");
0ldc #27// "7"
2invokestatic #29// Integer.parseInt(String) : int
5putstatic #23// Constants.COMPUTED : int

Open in the viewer

Related instructions

invokevirtual Calls an instance method, chosen by the receiver's class.invokespecial Calls a constructor, a private method or a superclass method directly.getstatic Pushes the value of a static field.

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