Summary
Enhance the JVM with value classes and objects.
Problem
The JEP provides a high-level discussion motivating the feature.
The JVM, in particular, needs enhancement in --enable-preview mode, doing all of the following:
- Distinguish between value classes (which do not require/assume identity) and identity classes (which do)
 - Modify the instance creation mechanism to ensure that value objects are created with final fields that can never be observed to mutate
 - Automatically configure loading of modified JDK classes when the 
--enable-previewflag is set - Allow for and signal the loading of the value classes used by a particular class early enough to influence the class's layout and method calling conventions
 - Provide identity-free semantics for the 
if_acmpeq,if_acmpne, andmonitorenterinstructions 
Solution
Our solution enhances the JVM as follows:
- Repurpose the 
ACC_SUPERflag to be interpreted (in preview class files) asACC_IDENTITY; identity classes set this flag, while value classes and interfaces do not. Validate that value classes conform to various constraints: do not extend identity classes, do not declare inappropriate instance fields, do not declare synchronized methods - Ensure that all instance fields of a value class are strictly-initialized: they must be marked with the 
ACC_STRICTflag (formerly used to express floating-point properties on methods), which instructs verification to prevent anyputfieldoperations after thesuper()constructor call. Field initialization is only allowed before that point. - Have the launcher reconfigure the 
java.basemodule to load special preview class files when preview features are enabled - Introduce a new attribute, 
LoadableDescriptors, to indicate classes mentioned in descriptors that can be speculatively loaded during class loading, and might be loaded earlier than usual during linking - Update 
if_acmpeqandif_acmpneto compare instances of value classes in terms of their field values; updatemonitorenterto reject value class instances 
A more comprehensive outline of the solution can be found in the JDK-8317278 description.
Specification
JVMS changes are included in the attached spec change document bundle. See the file specs/value-objects-jvms.html.
- csr of
 - 
                    
JDK-8317278 JVM implementation of value classes and objects
-         
     - In Progress
 
 -         
 
- relates to
 - 
                    
JDK-8339181 Java language implementation of value classes and objects
-         
     - Draft
 
 -         
 - 
                    
JDK-8339199 Standard library implementation of value classes and objects
-         
     - Draft
 
 -