lconst_1 0x0a

Pushes the long constant 1.

Opcode
0x0a (10)
Family
Constants
Operands
none
Length
1 byte
Operand stack
… → …, 1 (long)
Can throw
nothing at run time (beyond linking errors)
Spec name
lconst_<l>

What it does

Pushes the long 1L. Only 0 and 1 have one-byte instructions; any other long constant needs ldc2_w of a Long constant.

How often javac uses it

In JDK 25.0.5's java.base module, lconst_1 appears 987 times in 286 of its 7,391 classes: 0.05% of all instructions, the 109th most common of 194 opcodes in use. Some of the methods that use it: java.io.FileInputStream.traceRead0, java.io.FileOutputStream.traceWrite, java.io.InputStream.skipNBytes, java.io.ObjectInputStream.readObject0.

Examples

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

static long staticLong() in Increments, compiled by javac 25
18return ++counter;
0getstatic #13// Increments.counter : long
6putstatic #13// Increments.counter : long

Open in the viewer

static long constants() in Tour, compiled by javac 25
… 7 instructions before
129int a = -1, b = 5, c = 100, d = 1000, e = 100000;
10istore_3 // d
11ldc #66// 100000
13istore 4// e
130long f = 0, g = 1, h = 123456789012L;
16lstore 5// f
19lstore 7// g
21ldc2_w #67// 123456789012L
24lstore 9// h
131double i = 0.5;
26ldc2_w #69// 0.5
29dstore 11// i
132Object n = null;
… 28 instructions after

Open in the viewer

Related instructions

ldc2_w Pushes a long or double constant from the constant pool.

Specification: JVMS §6.5, lconst_<l> (Java SE 25).