What Is New in Java 23
Java 23 delivers targeted enhancements across the platform, focusing on developer productivity, performance, and preview features that shape the future of the language.
| Category | Key Items |
|---|---|
| New Features | Statements before super(...), Stream Gatherers (Preview), Implicitly Declared Classes (Preview) |
| Improvements | Launch Multi-File Source-Code Programs, Foreign Function & Memory API, Vector API |
| Deprecations & Removals | Deprecation of the Security Manager for Removal, Removal of Solaris and SPARC Ports |
What are the main language updates in Java 23?
Java 23 introduces several preview features and a final refinement to constructor syntax. The most significant language change allows statements before super() in constructors, provided they don't reference the instance under construction. This simplifies constructor logic, especially when dealing with validation or intermediate calculations.
Stream Gatherers (JEP 461) enter preview, offering a powerful new model for complex, stateful intermediate stream operations. This finally gives developers a built-in way to do operations like windowing or custom reductions directly in the Stream API.
Implicitly Declared Classes (JEP 463) also return for another preview round, further refining the experience for beginners by simplifying the ceremony required for simple programs.
How does Java 23 improve application launch and performance?
You can now run multi-file Java source-code programs without compiling them first. The java launcher will automatically compile and run all the .java files in the specified directory, streamlining the development and scripting process.
The Foreign Function & Memory API (JEP 454) graduates to final and stable status. This is a huge deal because it provides a pure-Java, high-performance, and safe replacement for the outdated JNI, making native interop significantly less painful.
The Vector API (JEP 469) enters its eighth incubator stage, inching closer to finalization with performance improvements and bug fixes for expressing vector computations that reliably compile to optimal hardware instructions.
What is being deprecated or removed in this release?
The Security Manager is now officially deprecated for removal. In practice, most modern applications already run without it, and its removal paves the way for future innovation in the platform's security model.
The Solaris and SPARC ports have been removed, reflecting the diminished relevance of these platforms in today's ecosystem. This allows the OpenJDK community to focus resources on more widely used operating systems and architectures.
FAQ
Is the Foreign Function & Memory API production-ready now?
Yes. JEP 454 has promoted the API from Preview to Final. It is now a standard, supported part of the Java platform and safe for production use as a modern replacement for JNI.
What's a practical use case for Stream Gatherers?
Imagine you need to process a stream of data in overlapping batches (windows) or group elements until a certain condition is met. Before Gatherers, you'd need an external library or a complex collector. Now, you can define this logic directly as a gatherer.
Why allow statements before super()?
This change eliminates a common pain point. Previously, if you needed to validate arguments or compute a value to pass to the superclass constructor, you had to resort to static methods. Now, you can write that logic inline, making constructors more intuitive.
Should I be worried about the Security Manager deprecation?
For the vast majority of applications, no. The Security Manager was rarely used. If your app does rely on it, start planning your migration now, as it will eventually be removed in a future release.
How do I run a multi-file source code program?
Place all your .java files in a directory and run java --source 23 <path_to_directory>/Main.java. The launcher will find and compile all necessary classes in that directory automatically.