What Is New in Java 15
Java 15 delivers several key updates including finalized preview features, new language enhancements, and performance improvements. This release continues to refine the platform with a focus on developer productivity and application modernization.
| Category | Key Changes |
|---|---|
| Finalized Features | EdDSA, Sealed Classes, Hidden Classes, Pattern Matching for instanceof, Text Blocks |
| New Features / Enhancements | ZGC, Shenandoah, Records (2nd Preview), Foreign-Memory Access API (2nd Incubator) |
| Deprecations & Removals | Deprecation of RMI Activation, Biased Locking, Nashorn JavaScript Engine |
| Security | New DatagramSocket API, Enhanced Certificates |
Which Language Features Were Finalized in Java 15?
Java 15 finalized several preview features that were introduced in earlier releases. Text Blocks and Pattern
Matching for instanceof are now standard, making them stable for production use without needing to
enable preview features.
Sealed Classes remain in preview but have been updated based on community feedback. This model gives library authors precise control over which classes can extend or implement a sealed interface, a significant step for modeling complex domains.
How Do Records Improve Java Development?
Records are in their second preview, refining the shorthand for declaring data carrier classes. They
automatically generate equals(), hashCode(), toString(), and accessor
methods, drastically reducing boilerplate code.
In practice, this means you can define a simple data aggregate with a single line:
record Point(int x, int y) { }. The refinements in this preview include support for local records
and a more precise specification.
What Garbage Collector Improvements Are Included?
Both the Z Garbage Collector (ZGC) and the Shenandoah garbage collector are now production features. They were previously available as experimental options, but are now fully supported for use in production environments.
These low-pause-time GCs are a major benefit for applications where latency and responsiveness are critical. You
can enable them with the -XX:+UseZGC or -XX:+UseShenandoahGC flags.
Are There Any New Low-Level APIs for Developers?
The Foreign-Memory Access API enters its second incubator stage, providing a safe and efficient way to access memory outside the Java heap. This is crucial for libraries that need to interact with native code and avoid the overhead of the Java Native Interface (JNI).
Hidden Classes are also now a standard feature. They are ideal for frameworks that generate classes at runtime, like Lambda expressions, as they are unobservable by reflection and have a limited lifecycle, which improves efficiency.
What Has Been Deprecated or Removed?
This release continues the cleanup of legacy features. The Nashorn JavaScript engine, along with its APIs, has been removed. Biased Locking and RMI Activation have been deprecated, signaling their eventual removal in a future release.
For most developers, these changes have minimal impact. The Nashorn removal primarily affects applications that embedded a JavaScript runtime; alternatives like GraalVM are the recommended path forward.
FAQ
Are Text Blocks now a permanent feature?
Yes, Text Blocks were finalized in Java 15 (JEP
378). You can use them for multi-line string literals without enabling preview features.
Is it safe to use ZGC in production now?
Absolutely. Both ZGC (JEP 377) and Shenandoah (JEP
379) were promoted from experimental to production-grade features in this release.
What happened to the Nashorn JavaScript engine?
Nashorn was removed in Java 15. If your
application depends on it, you need to migrate to another JavaScript implementation such as GraalVM.
Why are Sealed Classes still in preview?
While finalized features like Text Blocks are
stable, Sealed Classes (JEP 360) received further community feedback. Keeping them in preview allows for
additional refinements before being permanently added to the language.
What is the main benefit of Hidden Classes?
Hidden Classes (JEP 371) improve the efficiency
of frameworks that generate classes dynamically at runtime. They cannot be discovered by reflection and have a
controlled lifecycle, which reduces memory footprint.