Java 22 Brings Developers Better Usability, Promise of Simplification
The new Java release introduces incremental technology improvements designed to make the programming language easier to use.
The first major release of Java in 2024 is now available with the launch of Java 22 on March 19.
Java 22 arrives six months after Java 21 and is an incremental feature update, not a Long-Term Support (LTS) release. With each new Java update, the community of developers led by Oracle works on a series of Java Enhancement Proposals (JEPs) that are typically clustered under larger projects. The major Java projects include Loom, Panama, and Amber, each having specific long-term goals for improving Java, with incremental capabilities landing in each new Java update.
Related: Should Developers Learn Java Programming Language?
A major focus for Java 22 is reducing complexity for developers.
Among the key updates to Java 22 are:
JEP 454: Foreign Function & Memory API, enabling calling native libraries and processing native data
JEP 456: Unnamed Variables & Patterns, adding unnamed variables and patterns to improve readability and reduce errors
JEP 457: Class-File API (Preview), providing API for parsing and processing class files
JEP 458: Launch Multi-File Source-Code Programs, running programs supplied as multiple Java source files
JEP 459: String Templates (Second Preview), simplifying string creation with embedded expressions
JEP 460: Vector API (Seventh Incubator), expressing vector computations for improved performance
JEP 461: Stream Gatherers (Preview), adding custom intermediate stream operations
JEP 462: Structured Concurrency (Second Preview), adding API for structured concurrency to simplify error handling
JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview), simplifying writing single-class programs for beginners
JEP 464: Scoped Values (Second Preview), allowing sharing immutable data between threads
"I've been working on Java for the past 25 years, and we now have the most interesting and innovative pipelines of innovation in the platform that we have had in a long time," Bernard Traversat, vice president of software development in the Java Platform Group at Oracle, told ITPro Today.
How Java 22 Is Aiming to Simplify Development
One of the major focuses of Java 22 is reducing complexity for developers.
New features in Java 22 that Traversat highlighted include standardizing API interfaces and improving concurrency management to make the language more expressive.
One key set of enhancements comes from Project Amber — the changes are designed to make writing Java code less tedious. Constructors can now include statements before explicit superclass constructor invocations, removing the need to factor out logic into separate methods. Developers can also use unnamed variables and patterns where declarations are required but names are irrelevant. These improvements promise to eliminate boilerplate code and reduce errors.
For structured concurrency, Java 22 previews new APIs from Project Loom to handle errors and cancellation more elegantly. Immutable data sharing between threads also becomes easier. Both features aim to improve the robustness and comprehension of multi-threaded code.
"It's all around this area of, How do we make sure that Java is attractive to developers?" Traversat said.
Project Babylon Is Coming
One of the newest initiatives to improve Java is Project Babylon.
Project Babylon's goal is to unify CPU and GPU execution models for more efficient code processing, according to Traversat. He explained that Project Babylon aims to expand the CPU/GPU model by collecting information to help with code transformation and targeting efficient execution to GPUs.
Project Babylon has the potential to automate optimizations so code can seamlessly take advantage of GPUs without needing low-level programming. It represents an effort to bring GPU computing capabilities directly to the Java language.
Focus on Developer Experience
Beyond the specific features, Oracle is trying to improve the overall developer experience.
One way it is doing that is with an updated Java Playground on dev.java. Here developers can try out Java features with sample code.
"This is our mechanism to offer a browser-based method for seasoned developers to see how specific net new features in Java actually look like before they use them in production," Sharat Chander, director, Java SE Product Management, at Oracle, told ITPro Today.
About the Author(s)
You May Also Like