RC RANDOM CHAOS

After a Decade, Java's Project Valhalla Lands in JDK 28 — But Only Halfway

· via Hacker News

Original source

Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28

Hacker News →

Oracle engineer Lois Foltan confirmed on June 15 that JEP 401, the long-promised Value Classes and Objects work at the heart of Project Valhalla, is merging into the main OpenJDK repository and targeting JDK 28. The integration is massive — a single pull request adding more than 197,000 lines across 1,816 files, large enough that other committers were asked to pause major commits during the merge. After eleven years and a running community joke that contributors would reach the Norse afterlife before the project shipped, this is a genuine milestone.

The tempering caveat: what arrives in JDK 28 is a preview, disabled by default, and what Brian Goetz calls only the first part of Valhalla. The project’s goal has always been captured in one slogan — ‘codes like a class, works like an int.’ Outside of Java’s eight primitives, every value is a reference, meaning a variable is really a pointer to a heap object carrying its own header and requiring allocation and garbage collection. At scale, an array of a million objects becomes a million scattered pointers, wrecking cache locality at a time when memory access is roughly two orders of magnitude slower than CPU operations. Value classes aim to let developers write normal, validated, readable types that the JVM can lay out flat and dense in memory.

The existing workarounds all fall short: escape analysis can flatten objects but is fragile and unpredictable, breaking on a minor refactor or JDK update, while hand-encoding data as raw primitives sacrifices names, validation, and safety. Valhalla’s path to this point was long and littered with discarded ideas — five prototypes since 2014, including the abandoned ‘Q World’ design that doubled the JVM type system, before the 2019 ‘L World’ breakthrough let value types share the same reference descriptor as ordinary objects.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.