Catch Java 22, available from Oracle for a limited time
Latest release of coffee-themed programming language aspires to simplicity with a dozen new features
Oracle released Java 22 (JDK 22) on Tuesday, sporting a dozen new features for Java developers.
Based on OpenJDK, the open source reference implementation of the Java SE Platform Edition, the commercial Oracle JDK is offered under a subscription license while OpenJDK is offered under a GPL license.
JDK 22 is a Feature release, meaning Oracle will support it for six months until the next Feature release. LTS releases, like JDK 21, are supported for up to eight years. The next LTS release will be Java 25, scheduled for September 2025.
Oracle says Java is the "#1 Language for today's Technology Trends" – whatever that means – and that it's the "#1 Overall Enterprise/IT Organizational use," which is also a bit vague but nonetheless plausible. Someone is using the 63 billion active Java Virtual Machines (JVMs) and 41 billion cloud-based JVMs that Oracle insists exist.
Java in less qualified contexts continues to rank among the top programming languages in various surveys, and remains a core enterprise technology despite concerns raised last year about the cost of Oracle's licensing terms.
A 2024 survey [PDF] of 440 Java developers conducted by software firm Perforce found "60 percent of respondents say their companies plan to add Java developers in the coming year, and 42 percent plan to increase their Java development tool budget."
Java appears to have benefited from the industry-wide push to avoid languages without strong memory safety guarantees – notably C++ – even though Java's memory safety story isn't entirely spotless.
Bernard Traversat, VP of development for Java, told The Register that the national push for memory safety has worked out well for the Java community.
"The US government is already now pushing people and the industry to start to adopt memory safety languages because there is so much complexity now, so much risk around data, that you really want to try to build into your programming runtime environment all the safety and control that you can," he explained, noting that memory safety is one of the reasons Java has remained so popular – particularly among enterprises.
Oracle's revised Java licensing terms 2-5x more expensive for most orgs
READ MORE"And as we are getting into the world of AI now, where you would have a system that controls pretty much everything in real time very quickly, you really want to build all those systems, systems in control, in a technology that provides you the best benefits of security and memory access control."
Asked whether industry interest in AI has shaped Java development, Traversat replied that the answer is both yes and no.
"Typically what we do is when we are building on those features, it's not that we're going to say, 'Hey we're going to bring this feature just for that specific use case," he explained. "We tend to take a much more holistic view of where we see the need for development. Clearly, AI/ML is very important, but [so is] the scale of running large services."
"But you're right in the sense that some of the features that we have, especially around the memory management, starting with ZGC, we know that it's going to be very important that as a class of applications that's going to want to have all their data, be able to process all this data in memory. And so the age of Petabyte systems is coming. We have customers that are deploying at terabyte scale, now multi-terabyte scale, into applications. So we know we need to push, and clearly in the age of AI ML there's going to be data, data, data, data."
Java 22 incorporates a dozen JDK Enhancement Proposals, or JEPS.
Region Pinning for G1 (JEP 423) refers to the Garbage-First (G1) Garbage Collector (GC), the mechanism by which Java code frees up memory. The default garbage collection behavior for G1 is to disable garbage collection in certain critical operations, to avoid moving objects in memory and messing up associated pointers. Region pinning keeps critical objects in place while others get moved during cleanup. So this proposal means Java threads no longer have to wait for G1 garbage collection operations to complete.
Improvements in Java garbage collection from JDK 21, specifically the Z Garbage Collector, were recently adopted by Netflix, which has reported a reduced computational workload as a result.
Statements before super(...) (Preview) (JEP 447) offers an improvement in the way Java constructors can be invoked by allowing statements to be placed prior to the constructor invocation of its parent class.
- 'We had to educate Oracle about our contract,' CIO says after Big Red audit
- March Patch Tuesday sees Hyper-V join the guest-host escape club
- Mamas, don't let your babies grow up to be coders, Jensen Huang warns
- Starting over: Rebooting the OS stack for fun and profit
Foreign Function & Memory API (JEP 454) refines prior proposals in JDK 19 (JEP 424), JDK 20 (JEP 434), and JDK 21 (JEP 44) to implement a way for Java code to invoke foreign functions from outside the Java Virtual Machine (JVM). It's intended to be a replacement for the Java Native Interface (JNI).
Unnamed Variables & Patterns (JEP 456) refines JEP 443 from JDK 21 to provide a way to implement unused variables and patterns in a safe way, to avoid setting off static analyzer alarm bells. Compilers, analyzers, linters, and the like tend to complain when variables are declared but never used.
Class-File API (Preview) (JEP 457) presents a standard API parsing, generating, and transforming Java class files, which contain Java bytecode for the JVM.
Launch Multi-File Source-Code Programs (JEP 458) amends the Java launcher's source-file mode so that it can run a program that consists of multiple Java source code files.
"With JEP 458, you just put your Java file, multiple Java files, on the Java command and automatically underneath, if you have done different javac compilations, Java will just call javac [the Java compiler] for you, and then you can run your application directly," explained Traversat.
String Templates (Second Preview) ) (JEP 459) expands upon JEP 430 in JDK 21 to support string templates – text strings that include values computed at run time.
Vector API (Seventh Incubator) (JEP 460) provides a way to make vector calculations that compile at runtime using hardware-optimized vector instructions.
Stream Gatherers (Preview) (JEP 461) makes the Stream API more flexible, so streaming data pipelines can process data through custom intermediate operations.
Structured Concurrency (Second Preview) (JEP 462) adds an API for structured concurrency, in an effort to promote a style of concurrent programming that eliminates thread leaks and cancellation delays. Structured concurrency handles groups of tasks in different threads as a single work unit, which makes code easier to observe.
Scoped Values (Second Preview) (JEP 464) provide a safe way to share immutable data within threads and with child threads.
Finally, there's Implicitly Declared Classes and Instance Main Methods (Second Preview) (JEP 463), which represents an effort to make Java more approachable for students. It allows a source file to implicitly declare a class and a main method so the programmer doesn't have to bother with what's essentially boilerplate. So Java's Hello, World! Program will have fewer lines of code.
An Oracle slide showing the simplification to Hello, World! code promised by JEP 463 – Click to enlarge
This fits with the Java community's need to bring younger programmers onboard – something that becomes more difficult if educational institutions focus on other languages.
Traversat said this is part of Project Amber – a Java initiative to make the language less verbose and more approachable for beginners: "We're spending a lot of investment to try to reduce the verbosity [of Java]." ®
Don't miss Tim Anderson's take of the Java news right here on DevClass.com.