Paul Krill
Editor at Large

OpenJDK proposal would bring value classes and objects to Java

Value objects would be distinguished only by their field values, not by identity, providing an easier programming model for simple values.

An OpenJDK proposal would preview value classes and objects in a forthcoming version of Java. The feature would provide Java class instances that have only final fields and lack object identity.

The Java enhancement proposal, which dates back to August 2020, was updated on June 21. The plan would allow developers to opt into a programming model for simple values in which objects are distinguished by their field values, much as the int value 3 is distinguished from the int value 4. A second goal is to migrate popular classes that represent simple values in the JDK, such as Integer, to this programming model. This is intended support compatible migration of user-defined classes. A third goal is to maximize the freedom of the JVM to encode simple values in ways that improve memory footprint, locality, and garbage collection efficiency.

The proposal is slotted as a preview language and JVM feature. It currently does not state a targeted version number for Java. It is not a goal of the plan to introduce a struct feature in the Java language. Java would continue to operate on two kinds of data, namely objects and primitives. It also is not a goal to change the treatment of primitive types or to automatically treat existing classes as value classes.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorldโ€™s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorldโ€™s audience of software developers and other information technology professionals. Paul has won a โ€œBest Technology News Coverageโ€ award from IDG.

More from this author