DEV Community

Hamza
Hamza

Posted on • Originally published at tekmag.thsite.top

Java's Project Valhalla Finally Lands: Value Classes Coming to JDK 28

After more than a decade of development, Java's long-awaited Project Valhalla has finally reached the finish line — or at least the preview gate. Oracle engineer Lois Foltan confirmed this week that JEP 401, which introduces value classes and objects to the Java language, will be integrated into the OpenJDK mainline early next month, targeting the JDK 28 release in March 2027. The change is massive: 197,000 lines of code across 1,816 modified files, so large that Foltan has asked other OpenJDK committers to pause major work during the integration window.

Project Valhalla addresses one of Java's oldest and most persistent performance limitations: the fact that every non-primitive type in Java is a reference type with unique memory identity, even when two instances hold identical data. This seemingly esoteric detail has real-world consequences that every Java developer has encountered.

What Value Classes DoHere's the problem in plain terms. Two LocalDate objects representing the same calendar date will return false when compared with the == operator, because they occupy different memory locations. The Integer wrapper class internally caches instances for values below 128, so == accidentally works for small numbers but breaks for anything larger — a trap that Java IDEs and linters have been warning developers about for years.

Value classes eliminate object identity entirely. Instances are distinguished solely by the values of their fields, not by where they sit in memory. This unlocks three major benefits: reduced memory overhead, improved CPU cache locality, and dramatically more efficient iteration since the JVM no longer needs to dereference pointers to access underlying data.

Read the full article on TekMag.

Top comments (0)