Overview of New Features in Java 15

Introduction Java 15 was released on 15th September 2020, with fourteen JDK Enhancement Proposals (JEPs). It made text blocks a standard language feature, made the ZGC and Shenandoah low-pause garbage collectors ready for production, added hidden classes for frameworks and the EdDSA signature algorithm, previewed sealed classes, and removed the Nashorn JavaScript engine. This article gives an overview of the new features in Java 15, with links to detailed tutorials. Language features
  1. Text Blocks - JEP 378 - after previews in Java 13 and 14, multi-line string literals delimited by """ are a standard feature. Read the tutorial on text blocksClick to read tutorial: Java Text Blocks: Multi-line Strings with Examples. Java 15 also added three String methods which go with them - read about formatted(), stripIndent() and translateEscapes()Click to read tutorial: Java 15 String Methods: formatted, stripIndent and More.
  2. Sealed Classes (Preview) - JEP 360 - classes and interfaces which list exactly which classes may extend them. Finalized in Java 17 - read the sealed classes tutorialClick to read tutorial: Java 17 Sealed Classes Tutorial with Examples.
  3. Pattern Matching for instanceof (Second Preview) - JEP 375 and Records (Second Preview) - JEP 384 - both previewed again, and finalized in Java 16. Read about pattern matching for instanceofClick to read tutorial: Java 16 Pattern Matching for instanceof and recordsClick to read tutorial: Java 16 Records Tutorial with Examples.
JVM and garbage collection
  1. ZGC: A Scalable Low-Latency Garbage Collector - JEP 377 and Shenandoah: A Low-Pause-Time Garbage Collector - JEP 379 - both collectors moved from experimental to production features, keeping pause times short regardless of heap size. Read about ZGC and ShenandoahClick to read tutorial: ZGC and Shenandoah: Low-Pause GCs in Java 15.
  2. Hidden Classes - JEP 371 - classes which frameworks generate at runtime, which cannot be found by name and can be unloaded independently. Read about hidden classesClick to read tutorial: Java 15 Hidden Classes Explained with Examples.
  3. Disable and Deprecate Biased Locking - JEP 374 - biased locking, an old optimization for uncontended synchronized blocks, was disabled by default because modern code rarely benefits from it and it complicated the JVM.
Security and networking
  1. Edwards-Curve Digital Signature Algorithm (EdDSA) - JEP 339 - support for the modern Ed25519 and Ed448 signature algorithms, which are fast and resistant to several implementation mistakes, through the standard Signature and KeyPairGenerator APIs with the name "Ed25519".
  2. Reimplement the Legacy DatagramSocket API - JEP 373 - like the socket API in Java 13, the old DatagramSocket implementation was replaced by a simpler, maintainable one.
Removals and deprecations
  1. Remove the Nashorn JavaScript Engine - JEP 372 - Nashorn, deprecated in Java 11Click to read: Java 11, was removed, along with the jjs tool. It continues as a separate library, org.openjdk.nashorn:nashorn-core.
  2. Remove the Solaris and SPARC Ports - JEP 381 - the JDK no longer builds for Solaris or SPARC.
  3. Deprecate RMI Activation for Removal - JEP 385 - the rarely used RMI Activation mechanism was deprecated, and it was removed in Java 17.
  4. Foreign-Memory Access API (Second Incubator) - JEP 383 - continued work on what became the Foreign Function & Memory APIClick to read: Foreign Function & Memory API.
Other changes Java 15 also added CharSequence.isEmpty(), and made helpful NullPointerException messages, introduced in Java 14, the default - read about helpful NullPointerExceptionsClick to read tutorial: Java 14 Helpful NullPointerExceptions Explained. Summary In this article we went through the new features of Java 15. Text blocks became standard, with new String methods to go with them, sealed classes were previewed, and records and pattern matching for instanceof got their second previews. ZGC and Shenandoah became production-ready, hidden classes gave frameworks a supported way to generate classes, and EdDSA signatures were added. Lastly, Nashorn and the Solaris and SPARC ports were removed. Next, read the overview of new features in Java 16Click to read tutorial: Overview of New Features in Java 16.