See why a recent announcement in OpenJDK concerning the ValueBased annotation could hint at a movement towards inline classes in Java.
Candidate JEP 390 ("Warnings for Value-Based Classes") was announced this past week by Mark Reinholdon the OpenJDK jdk-dev mailing list. This is a JDK Enhancement Proposal that may be more exciting in what it indicates (progress toward inline classes) than what it actually is (annotation and warnings about "improper attempts to synchronize on instances" of
**@ValueBased**-annotated JDK classes that might be come inline classes).
The term " Value-based Classes" was included in the Java SE 8 Javadoc documentation, which identified the following characteristics of "instances of a value-based class" at that time:
finaland immutable (though may contain references to mutable objects)"
toString... solely [computed] from the instance's state and not from its identity or the state of any other object or variable"
==) between instances, identity hash code of instances, or synchronization on an instances's intrinsic lock"
equals()" rather than "on reference equality (
That Java SE 8 documentation also warned that "a program may produce unpredictable results if it attempts to distinguish two references to equal values of a value-based class, whether directly via reference equality or indirectly via an appeal to synchronization, identity hashing, serialization, or any other identity-sensitive mechanism." It further emphasizes, "Use of such identity-sensitive operations on instances of value-based classes may have unpredictable effects and should be avoided." This documentation remains essentially the same today (Java 15). This documentation is linked to from certain identified JDK classes' Javadoc comments. A good overview on value-based classes is available in Nicolai Parlog's blog post " Value-Based Classes."
Although some JDK classes have been identified in their Javadoc as value-based classes since Java 8, JEP 390 aims to provide the annotation
**@ValueBased** for these types of JDK classes. The annotation is a stronger construct than a comment and is specifically intended to be used in conjunction with "warnings about improper attempts to synchronize on instances of such classes." The advantage of such an annotation is that developers can be warned about current uses in their code to synchronize on instances of classes that may one day be unsuitable for such synchronization. Because some likely significant time will pass between the availability of this warning and the actual coversion of these
@ValueBased-annotated classes to inline classes (the JEP word this as, "several releases before the migration occurs"), developers will have ample opportunity to change the classes upon which they apply synchronization.
The warning about use of JDK classes for synchronization has benefit in its own right. In addition, I think this JEP is an exciting step toward inline types and the JEP is full of details about inline types. Specifically, the first paragraph of the "Motivation" section of JEP 390 states:
What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).
Java.util package contains the collection's framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array). Here is the list of most commonly used top ten Java utility classes. Top 10 Java Classes from Utility Package
Java File class represents the path of directories and files. It provides the methods for renaming, deleting, and obtaining the properties of file or directory.
Java Object class can be thought of as the father of all other classes. This is because every class defined in Java extends directly or indirectly from the Object class.
Java String is an inbuilt class that deals with all that is written in double quotation marks, or other words string is a collection of characters.