Overview of New Features in Java 17

Introduction Java 17 was released on 14th September 2021. It is a long-term support (LTS) release - the first since Java 11Click to read: Java 11 - and the version most teams moved to from Java 11. Its own fourteen JDK Enhancement Proposals (JEPs) finalized sealed classes, reworked random number generation, and completed the strong encapsulation of the JDK's internals. But for anyone upgrading from Java 11, the real story is everything which arrived across Java 12 to 17. This article gives an overview of the new features in Java 17, and then summarizes all the major changes since Java 11, with links to detailed tutorials. Language and library features in Java 17
  1. Sealed Classes - JEP 409 - a class or interface can list exactly which classes may extend or implement it. Read the sealed classes tutorialClick to read tutorial: Java 17 Sealed Classes Tutorial with Examples.
  2. Enhanced Pseudo-Random Number Generators - JEP 356 - a common RandomGenerator interface and modern algorithms. Read about the RandomGenerator APIClick to read tutorial: Java 17 Random Number Generators: RandomGenerator API.
  3. Context-Specific Deserialization Filters - JEP 415 - a JVM-wide filter factory chooses a deserialization filter for every stream. Explained, with HexFormat and InstantSource, in the Java 17 API additionsClick to read tutorial: Java 17 API Additions: HexFormat, InstantSource and More.
  4. Restore Always-Strict Floating-Point Semantics - JEP 306 - all floating-point operations are strict again, so strictfp is no longer needed and results are the same on every platform.
  5. Pattern Matching for switch (Preview) - JEP 406 - patterns in switch cases, finalized in Java 21. Read about pattern matching for switchClick to read: pattern matching for switch.
Platform changes in Java 17
  1. Strongly Encapsulate JDK Internals - JEP 403 - the --illegal-access option was removed; only --add-opens can open internal packages. Read about the strong encapsulation of JDK internalsClick to read tutorial: Strong Encapsulation of JDK Internals in Java 16 and 17.
  2. macOS/AArch64 Port - JEP 391 and New macOS Rendering Pipeline - JEP 382 - native support for Apple Silicon Macs, and Swing and Java 2D rendering using Apple's Metal API instead of the deprecated OpenGL.
  3. Foreign Function & Memory API (Incubator) - JEP 412 and Vector API (Second Incubator) - JEP 414 - continued work on APIs which were finalized (FFM in Java 22Click to read: FFM in Java 22) or are still incubating (Vector).
Removals and deprecations in Java 17
  1. Deprecate the Security Manager for Removal - JEP 411 - the Security Manager, rarely used for its original purpose of sandboxing untrusted code, was deprecated. It was permanently disabled in Java 24.
  2. Deprecate the Applet API for Removal - JEP 398 - no browser had supported applets for years; the API was removed in Java 26.
  3. Remove RMI Activation - JEP 407 and Remove the Experimental AOT and JIT Compiler - JEP 410 - the rarely used RMI Activation mechanism, and the experimental Graal-based jaotc ahead-of-time compiler and JIT option, were removed.
Everything new from Java 11 to Java 17 For teams moving from Java 11 to Java 17, these are the main changes which became standard across the six releases -
AreaFeature (release)
LanguageSwitch expressionsClick to read tutorial: Java Switch Expressions: Arrow Labels and yield (14), text blocksClick to read tutorial: Java Text Blocks: Multi-line Strings with Examples (15), recordsClick to read tutorial: Java 16 Records Tutorial with Examples (16), pattern matching for instanceofClick to read tutorial: Java 16 Pattern Matching for instanceof (16), sealed classesClick to read tutorial: Java 17 Sealed Classes Tutorial with Examples (17)
LibrariesString.indent, Collectors.teeing, Files.mismatchClick to read tutorial: Java 12 API Additions: String.indent, teeing, mismatch (12), String.formatted, stripIndentClick to read tutorial: Java 15 String Methods: formatted, stripIndent and More (15), Stream.toList, mapMulti, Unix-domain socketsClick to read tutorial: Java 16 API Additions: Stream.toList, mapMulti and More (16), RandomGeneratorClick to read tutorial: Java 17 Random Number Generators: RandomGenerator API and HexFormatClick to read tutorial: Java 17 API Additions: HexFormat, InstantSource and More (17)
Debugging and monitoringHelpful NullPointerExceptionsClick to read tutorial: Java 14 Helpful NullPointerExceptions Explained (14, on by default from 15), JFR event streamingClick to read tutorial: Java 14 JFR Event Streaming Tutorial with Examples (14)
Garbage collectionZGC and ShenandoahClick to read tutorial: ZGC and Shenandoah: Low-Pause GCs in Java 15 production-ready (15), G1 returns unused memory (12), CMS removed (14)
Tools and startupDefault and dynamic CDS archives (12, 13), jpackageClick to read tutorial: jpackage Tutorial: Packaging Java Apps (Java 16) (16)
PlatformHidden classesClick to read tutorial: Java 15 Hidden Classes Explained with Examples (15), strong encapsulation of JDK internalsClick to read tutorial: Strong Encapsulation of JDK Internals in Java 16 and 17 (16, 17), Apple Silicon and Alpine Linux ports (16, 17)
RemovedNashorn (15), Pack200 (14), CMS (14), Solaris/SPARC ports (15), RMI Activation (17), experimental AOT/Graal JIT (17)
Each release also has its own overview: Java 12Click to read tutorial: Overview of New Features in Java 12, Java 13Click to read tutorial: Overview of New Features in Java 13, Java 14Click to read tutorial: Overview of New Features in Java 14, Java 15Click to read tutorial: Overview of New Features in Java 15 and Java 16Click to read tutorial: Overview of New Features in Java 16.
Upgrading from Java 11 to 17
  • Libraries and frameworks: the most common upgrade problem is strong encapsulation breaking old versions of libraries which used JDK internals. Upgrade dependencies first - for example, Spring Boot 3 requires Java 17.
  • Removed features: check for Nashorn (use GraalJS or the standalone Nashorn library), CMS GC flags (switch to G1 or ZGC), and Pack200.
  • Build tools: update Maven and Gradle and their plugins to versions which support Java 17 bytecode.
  • Take advantage gradually: new language features can be adopted one class at a time - records for DTOs and value objects, text blocks for embedded SQL and JSON, and switch expressions and pattern matching to simplify conditional logic.
Summary In this article we went through the new features of Java 17, an LTS release. It finalized sealed classes, added the RandomGenerator API and deserialization filter factories, restored strict floating-point semantics, completed the strong encapsulation of JDK internals, added Apple Silicon support, and deprecated the Security Manager and the Applet API. We then summarized everything that became standard from Java 12 to 17, and the main points to check when upgrading from Java 11. Next, continue with the new features in Java 18Click to read: new features in Java 18.