CONSTANT_Long tag 5

A long constant, loaded with ldc2_w.

Tag
5
Since
class file 45.0 (Java 1.0)
Size
9 bytes
Loadable
yes, with ldc2_w
Referred to by
  • ldc2_w
  • ConstantValue of long fields

Layout

TypeFieldWhat it holds
u1tag5
u4high_bytesupper 32 bits
u4low_byteslower 32 bits

What it is for

A long constant, loaded with ldc2_w. 0L and 1L have lconst instructions.

A Long takes two constant pool slots: if it is entry 7, the next entry is 9, and index 8 is unusable. The specification itself says that in retrospect this was a poor choice. It is why constant_pool_count is not simply the number of entries.

How common it is

JDK 25.0.5's java.base has 4,374 Long constants in 1,156 of its 7,391 classes: 0.41% of all 1,059,609 constants.

A real one, byte by byte

Constant #44 of Constants.class, compiled by javac 25:

OffsetBytesFieldValue
4019 bytes#44 Long1099511627776L
40105tag5 (Long)
40200 00 01 00high_bytes256
40600 00 00 00low_bytes0

Open in the viewer

Specification: JVMS §4.4, CONSTANT_Long_info (Java SE 25).