Oracle is proposing an update to the Java Virtual Machine to allow for direct-value class types, a modernization required by the advent of multicore processors. There is no schedule for when the changes might appear in the JVM.
The changes to the JVM specification would support a prototype of value classes—classes for which primitive-like non-reference value instances can be created and acted upon. “The proposals for value types in Java are about giving developers the alternative to give up identity and polymorphism so that the runtime can represent the underlying data in a way which is both far more compact and much better suited for processing in bulk operations,” said Georges Saab, Oracle’s vice president of software development in the Java platform group.
In explaining the plan, Saab said when Java was created in 1995, memory access and CPU instructions took about the same amount of time. Since then, the introduction of multicore processors has increased the speed of CPU instructions but made memory locality a challenge.
For Java primitives, this time mismatch is not an issue. But it is an issue for objects, because of inherent assumptions about identity and polymorphism, Saab said.
The update would also introduce the
ValueCapableClass attribute and describe how value classes are derived from classes with this attribute. Also, the relationship between classes and types would be decoupled, and some instructions enhanced to operate on direct-value class types.
The JVM expects that nearly all type-checking is done before runtime, usually by the compiler rather than by the JVM itself. Thus, the proposed direct values would not need to be tagged or otherwise inspectable to determine their type at runtime or to be distinguished from reference values.