In March 2027, in JDK 28 (JVM gods willing!), after more than 12 years of effort, the Valhalla project will deliver its first feature: Value Classes (JEP 401) as a preview feature. Value classes are defined as regular classes with a "value" keyword in front. They are backward compatible with your code written before Java 28, without you having to recompile it.
Value classes bring new optimization opportunities at the JVM level: scalarization on stack and flattening on heap. For that, the Java specification had to be reinterpreted and enhanced, challenging us to reconsider some of the fundamentals on which Java was created 30 years ago. What does == mean? Is a reference always a pointer? Can an instance of a value class be null? Can you observe the transition between the default values and the final values of fields during object construction? And more.
This presentation covers all these questions, showing the trade-offs that need to be made in order to bring value classes to the Java platform.
You will hear about new code patterns, performance, and type safety. And, as value classes are just the first step, we will cover what Valhalla should bring in the future.