☕⚔️ Are you really ready for VALHALLA in JAVA 28?
☕⚔️ Are you really ready for VALHALLA in JAVA 28?
Your existing Java code could behave differently without changing a line.
🔸 TL;DR
After more than a decade of development, Project Valhalla is reaching a major milestone with JEP 401: Value Objects (Preview), integrated into JDK 28, scheduled for March 9, 2027.
▪️ Objects without identity.
▪️ New opportunities for JVM memory optimization.
▪️ 30 existing JDK classes becoming value classes.
▪️ New semantics for ==.
▪️ Compatibility risks for existing applications.
▪️ Primitive Patterns withdrawn after five previews.

🔸 OBJECTS WITHOUT IDENTITY
Value classes represent immutable, interchangeable data.
You can declare your own:
value record Point(int x, int y) {} var p1 = new Point(10, 20); var p2 = new Point(10, 20); p1 == p2; // true Objects.hasIdentity(p1); // false
Concrete value classes and their instance fields are implicitly final.
Ordinary records do not automatically become value records.
🔸 BETTER MEMORY LAYOUT
Without object identity, the JVM gains more freedom to optimize memory.
Traditional layout:
Array → [ref][ref][ref] ↓ ↓ ↓ [10] [20] [30] Possible flattened layout: Array → [10][20][30]
▪️ Reference flattening.
▪️ Reference scalarization.
▪️ Better CPU cache locality.
▪️ Reduced heap allocations and GC pressure.


⚠️ These optimizations are not guaranteed. Value objects remain nullable through references, and generic specialization is future work.
🔸 YOUR EXISTING CODE IS ALREADY CONCERNED
With preview enabled, 30 JDK classes become value classes, including:
▪️ Integer, Double and other primitive wrappers.
▪️ Optional and its primitive variants.
▪️ LocalDate, Duration, Instant and many more.
+------------------------------------------------------------+ | JAVA 28 - THE 30 VALUE CLASSES | | Project Valhalla - JEP 401 | +------------------+---------------------------------+-------+ | PACKAGE | VALUE CLASSES | COUNT | +------------------+---------------------------------+-------+ | java.lang | Integer | | | | Long | | | | Float | | | | Double | | | | Byte | | | | Short | | | | Character | | | | Boolean | | | | Number (*) | | | | Record (*) | 10 | +------------------+---------------------------------+-------+ | java.util | Optional | | | | OptionalInt | | | | OptionalLong | | | | OptionalDouble | 4 | +------------------+---------------------------------+-------+ | java.time | LocalDate | | | | LocalTime | | | | LocalDateTime | | | | ZonedDateTime | | | | OffsetTime | | | | OffsetDateTime | | | | Duration | | | | Instant | | | | Period | | | | Year | | | | YearMonth | | | | MonthDay | 12 | +------------------+---------------------------------+-------+ | java.time.chrono | MinguoDate | | | | HijrahDate | | | | JapaneseDate | | | | ThaiBuddhistDate | 4 | +------------------+---------------------------------+-------+ | TOTAL | 30 | +----------------------------------------------------+-------+ | (*) Abstract value classes | | Requires --enable-preview in JDK 28 | +------------------------------------------------------------+
Consider:
var a = LocalDate.of(2026, 7, 31); var b = LocalDate.of(2026, 7, 31); a == b; // Without preview: false // With preview: true
Even previously compiled code can be affected!
Before Valhalla

After Valhalla

Keep using equals() for logical equality. String remains an identity class.
🔸 COMPATIBILITY TRAPS
Review your code for:
▪️ Synchronization on value objects.
▪️ WeakReference and WeakHashMap keys.
▪️ Final field mutation through reflection.
▪️ Identity-dependent comparisons.
Use dedicated lock objects instead.
Even ordinary record constructors may fail to compile with preview enabled if they access this before initialization is complete.
🔸 VALHALLA RESHAPES PROJECT AMBER
On November 9, Angelos Bimpoudis and Gavin Bierman announced the withdrawal of Primitive Patterns after five previews, from Java 23 to 27.
Why?
🅰️ Valhalla is exploring user-defined numeric types. Finalizing exact numeric conversion rules now could constrain their future design. See 📺: https://inside.java/podcast/68/
🅱️ Constant Patterns are planned to carry forward some of this work:
// Before case Point(int x, int y) when x == 0 && y == 0 -> "Origin"; // With Constant Patterns (syntactic sugar) case Point(0, 0) -> "Origin";
🔸 TEST YOUR APPLICATIONS
Following Nicolai Parlog's Quality Outreach recommendation, test your CI pipelines against JDK 28 both with and without --enable-preview.
🔸 TAKEAWAYS
▪️ Value objects combine object-oriented abstractions with primitive-like optimization opportunities.
▪️ Identity is becoming an explicit design choice.
▪️ Preview features are not promises.
▪️ Prepare your codebase before Valhalla becomes permanent.
Are you really ready for Valhalla? ⚔️
#Java #JDK28 #ProjectValhalla #ValueObjects #OpenJDK #JVM #Performance #SoftwareEngineering
📘Fullstack Dev 2027 for Java Tech👉 https://a.co/d/0crUwEQ6