The Next Version of Standard Java: Universal Generics, Primitive Types, Virtual Threads, and Structured Concurrency
With Java 19 having just arrived on September 20, Java 20 is next on the docket, expected in March 2023. This release could potentially add new functionality for universal generics, immutable data, and string templates, and finalize capabilities such as record patterns.
Potential Features in JDK 20
While the current OpenJDK webpage for JDK 20 lists no officially proposed features as of September 23, this will change soon. Here are some capabilities that could make it into Java 20:
1. Universal Generics: This feature aims to unify the treatment of reference and primitive types in generic code. Although it didn’t make it into JDK 19, it remains a strong candidate for JDK 20.
2. Extent-Local Variables: These variables enable sharing of immutable data within and across threads, providing a new way to handle data immutability in concurrent programming.
3. String Templates: String templates simplify Java programming by making it easy to express strings that include values computed at runtime. This feature aims to reduce the complexity of string manipulation.
4. Value Objects: Value objects enhance the Java object model with class instances that have only final instances and lack object identity, promoting immutability and reducing side effects.
5. Primitive Classes: Primitive classes are special kinds of value classes that define new primitive types, providing a more efficient way to handle basic data types.
6. Sequenced Collections: This feature introduces a Collection interface to represent a collection with a defined encounter order, improving the handling of ordered collections.
7. Asynchronous Stack Traces API: This API provides information on Java and native frames, aiding in debugging and performance monitoring of asynchronous operations.
8. Classfile API: A new API to parse, generate, and transform Java class files, facilitating more advanced manipulation and analysis of bytecode.
9. Record Patterns: Previewed in JDK 19, record patterns allow for deconstructing record values, enhancing pattern matching capabilities.
10. Foreign Function and Memory API: Also previewed in JDK 19, this API provides a mechanism for Java programs to interoperate with code and data outside the Java runtime, improving interaction with native libraries.
11. Virtual Threads: Previewed as lightweight threads in JDK 19, virtual threads aim to make it easier to write and maintain high-throughput concurrent applications.
12. Vector API: Incubated for a fourth time in JDK 19, the vector API expresses vector computations that compile at runtime to optimal instructions on supported CPU architectures, achieving better performance than scalar computations.
13. Structured Concurrency: In an incubator phase in JDK 19, structured concurrency would simplify multithreaded programming via an API, making it easier to manage concurrent tasks.
14. Pattern Matching for Switch: Previewed for a third time in JDK 19, this feature enhances switch expressions and statements with pattern matching, making code more expressive and concise.
Release Schedule
Based on Java’s six-month release cadence, Java 20, or Java Development Kit 20, would arrive as a production release in March 2023. Like JDK 19, JDK 20 would be a short-term release with only six months of premium support from Oracle. The following JDK 21, due in a year, would be an LTS (Long Term Support) release with several years of backing by Oracle. This cadence ensures continuous improvement and innovation in the Java ecosystem, with regular updates and new features for developers to leverage.