Core Java Archives

Lazy Constants (JEP 531): JIT’s Best Friend You Haven’t Met (opens in new tab)

How ofLazy() unlocks constant-folding without static final, why it finally replaces double-checked locking, and what the numbers look like in practice. Every Java developer knows the tension. You want a value to be immutable so the JIT can inline it, skip null checks, and apply constant-folding — but you also want it to initialize lazily, not at class-load time. …

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help