Java 21 - Java 17 = 42 JEPs view
Tags: java
Published: 2023-07-11 19:20:06

[Java 21](https://openjdk.org/projects/jdk/21/) is in Rampdown Phase One since the beginning of June, which means the feature set is frozen. The target date for general availability is September 19, 2023. It will be the next LTS version after Java 17 released in September 2021.

Teams usually update Java from one LTS version to another, skipping non-LTS releases, and our team is no different here. And since the Java 21 feature set is frozen now, I was curious which features will be available in Java 21 since Java 17.

This means not only new features in Java 21 itself but also features delivered in Java 18, 19, and 20.

The diff between the latest and planned LTS versions.

The delta... Okay, what am I talking about? Here is the code:

```java
javaVersions.stream()
        .filter(v -> v.version() > 17)
        .filter(v -> v.version() <= 21)
        .flatMap(v -> v.features().stream())
        .toList()
```

So, here is the list of all JDK Enhancement Proposals (JEPs), which were targeted into Java 18-21 plus some related JEPs from Java 17 (42 JEPs total) grouped by the feature name and the feature state in Java 21.

Features in each table go in order of my personal preference as a developer, meaning the higher row indicates the higher chances I would use this feature in my daily work.

## Production-ready features in Java 21

| Feature | Java 17 | Java 18 | Java 19 | Java 20 | Java 21 |
|---|---|---|---|---|---|
| Sequenced Collections | - | - | - | - | Production: [JEP 431](https://openjdk.org/jeps/431) |
| Pattern Matching for switch | Preview: [JEP 406](https://openjdk.org/jeps/406) | 2nd Preview: [JEP 420](https://openjdk.org/jeps/420) | 3rd Preview: [JEP 427](https://openjdk.org/jeps/427) | 4th Preview: [JEP 433](https://openjdk.org/jeps/433) | Production: [JEP 441](https://openjdk.org/jeps/441) |
| Record Patterns | - | - | Preview: [JEP 405](https://openjdk.org/jeps/405) | 2nd Preview: [JEP 432](https://openjdk.org/jeps/432) | Production: [JEP 440](https://openjdk.org/jeps/440) |
| Virtual Threads | - | - | Preview: [JEP 425](https://openjdk.org/jeps/425) | 2nd Preview: [JEP 436](https://openjdk.org/jeps/436) | Production: [JEP 444](https://openjdk.org/jeps/444) |
| Generational ZGC | - | - | - | - | Production: [JEP 439](https://openjdk.org/jeps/439) |
| UTF-8 by Default | - | Production: [JEP 400](https://openjdk.org/jeps/400) | + | + | + |
| Code Snippets in Java API Documentation | - | Production: [JEP 413](https://openjdk.org/jeps/413) | + | + | + |
| Simple Web Server | - | Production: [JEP 408](https://openjdk.org/jeps/408) | + | + | + |
| Internet-Address Resolution SPI | - | Production: [JEP 418](https://openjdk.org/jeps/418) | + | + | + |
| Prepare to Disallow the Dynamic Loading of Agents | - | - | - | - | Production: [JEP 451](https://openjdk.org/jeps/451) |
| Key Encapsulation Mechanism API | - | - | - | - | Production: [JEP 452](https://openjdk.org/jeps/452) |
| Deprecate Finalization for Removal | - | Production: [JEP 421](https://openjdk.org/jeps/421) | + | + | + |
| Deprecate the Windows 32-bit x86 Port for Removal | - | - | - | - | Production: [JEP 449](https://openjdk.org/jeps/449) |
| Linux/RISC-V Port | - | - | Production: [JEP 422](https://openjdk.org/jeps/422) | + | + |
| Reimplement Core Reflection with Method Handles | - | Production: [JEP 416](https://openjdk.org/jeps/416) | + | + | + |

## Preview features in Java 21

| Feature | Java 17 | Java 18 | Java 19 | Java 20 | Java 21 |
|---|---|---|---|---|---|
| String Templates | - | - | - | - | Preview: [JEP 430](https://openjdk.org/jeps/430) |
| Unnamed Patterns and Variables | - | - | - | - | Preview: [JEP 443](https://openjdk.org/jeps/443) |
| Unnamed Classes and Instance Main Methods | - | - | - | - | Preview: [JEP 445](https://openjdk.org/jeps/445) |
| Scoped Values | - | - | - | Incubator: [JEP 429](https://openjdk.org/jeps/429) | Preview: [JEP 446](https://openjdk.org/jeps/446) |
| Structured Concurrency | - | - | Incubator: [JEP 428](https://openjdk.org/jeps/428) | 2nd Incubator: [JEP 437](https://openjdk.org/jeps/437) | Preview: [JEP 453](https://openjdk.org/jeps/453) |
| Foreign Function & Memory API | Incubator: [JEP 412](https://openjdk.org/jeps/412) | 2nd Incubator: [JEP 419](https://openjdk.org/jeps/419) | Preview: [JEP 424](https://openjdk.org/jeps/424) | 2nd Preview: [JEP 434](https://openjdk.org/jeps/434) | 3rd Preview: [JEP 442](https://openjdk.org/jeps/442) |

## Incubator features in Java 21

| Feature | Java 17 | Java 18 | Java 19 | Java 20 | Java 21 |
|---|---|---|---|---|---|
| Vector API | 2nd Incubator: [JEP 414](https://openjdk.org/jeps/414) | 3rd Incubator: [JEP 417](https://openjdk.org/jeps/417) | 4th Incubator: [JEP 426](https://openjdk.org/jeps/426) | 5th Incubator: [JEP 438](https://openjdk.org/jeps/438) | 6th Incubator: [JEP 448](https://openjdk.org/jeps/448) |

## Experimental features in Java 21

| Feature | Java 17 | Java 18 | Java 19 | Java 20 | Java 21 |
|---|---|---|---|---|---|
| Generational Shenandoah | - | - | - | - | Experimental: [JEP 404](https://openjdk.org/jeps/404) |

## Note

There are also changes in JDK that have no specific JEPs, but they are not covered in this post.

---

*Dream your code, code your dream.*