Oracle Java 21 Delivers Major Update to Open Source Programming Language

Java 21 gains a long list of new features, including virtual threads and a strong focus on improving Java for AI workloads.

Sean Michael Kerner, Contributor

September 20, 2023

4 Min Read
Java logo on tablet screen
Alamy

Oracle announced a significant update to the Java programming language on Sept. 19 with the release of Java 21.

The new version of Java is the second update of the language this year, following the release of Java 20 in March. The latest version delivers new features and improvements focused on enhancing developer productivity and application performance. Java 21 also integrates features that will help accelerate artificial intelligence (AI) and machine learning (ML) development efforts.

Oracle is taking steps to engage more with the Java developer community as well. The company is launching the Java Playground, an online sandbox for testing Java code snippets without local installation. 

Related: What Is the State of the Java Ecosystem in 2023?

Oracle has committed to supporting the significant changes in Java 21 with long-term support. It will support Java 21 for at least eight years, giving organizations flexibility in migrating applications. Support for the popular Java 11 has also been extended — to January 2032.

Among the key updates to Java 21 are:

  • JEP 430: String Templates (Preview). Streamlines the process of developing Java programs by providing a straightforward method to incorporate strings with values calculated in real time.

  • JEP 440: Record Patterns (Third Preview). Empowers developers to broaden pattern matching to more intricate and combinable data queries, thereby enhancing productivity levels, which helps increase productivity.

  • JEP 441: Pattern Matching for Switch. Aids developers in enhancing the efficiency and reliability of their projects by enriching the semantic nature of the Java language. 

  • JEP 443: Unnamed Patterns and Variables (Preview). Assists in streamlining the development process by enhancing the legibility of record patterns and boosting the overall maintainability of the codebase.

  • JEP 439: Generational Z Garbage Collector (ZGC). Helps improve developer productivity by lowering the overhead of required heap memory and garbage collection CPU for applications.

  • JEP 444: Virtual Threads. Optimizes the process of writing, maintaining, and observing high-throughput, concurrent applications by introducing lightweight virtual threads to Java.

  • JEP 446: Scoped Values (Preview). Enables the sharing of immutable data within and across threads.

  • JEP 448: Vector API (Sixth Incubator). Introduces an API to express vector computations that reliably compile at runtime to vector instructions on supported CPU architectures.

  • JEP 453: Structured Concurrency (Preview). Helps developers streamline error handling and cancellation, improve reliability, and enhance observability.

Virtual Threads in Java 21 Provides a Real Boost to Developers

According to Georges Saab, senior vice president of Oracle Java Platform and chair of the OpenJDK governing board, one of the most significant new features is the finalization of virtual threads (JEP 444) as part of Project Loom.

Virtual threads are an important new feature in Java because they allow developers to more easily write scalable and responsive applications without having to deal with low-level threading APIs.

Related: Should Developers Learn Java Programming Language

"Virtual threads has come into the last couple of Java releases as a preview feature, and now in 21 is being made final," Saab told SDxCentral. "I think this is probably the main feature that people point to, even though many developers won't encounter it directly as they'll actually encounter it through third-party libraries and frameworks that are worrying about that low level of threading and scalability."

Saab noted that finalizing virtual threads in Java 21 allows libraries and frameworks to take advantage of it to build highly concurrent applications without developers having to deal with threads directly. This makes it easier to write scalable programs that can utilize all available CPUs.

Java 21 Takes a New Vector Approach to AI

AI is a major focus area for the new features and improvements in Java 21.

Saab pulled quote

Saab-Oracle-Java-Platform

JEP 448, which provides a new vector API to help runtime execution, is the most obvious AI-focused feature. The use of vector embeddings in databases is a foundational element of modern AI applications.

The new vector API isn't the only update that will help with AI workloads, according to Saab. He noted that projects like Valhalla and Panama, and improvements to the garbage collector directly support AI and machine learning workloads by making Java better able to process large, complex data sets efficiently.

"We get asked sometimes why not just add a machine learning language learning library to Java?" Saab said. "Our answer is, we don't want to add a machine learning library, we want to make Java the platform to run all machine learning libraries on."

About the Author(s)

Sean Michael Kerner

Contributor

Sean Michael Kerner is an IT consultant, technology enthusiast and tinkerer. He consults to industry and media organizations on technology issues.

https://www.linkedin.com/in/seanmkerner/

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like