This project provides a collection of Java code examples demonstrating finalized language features and APIs introduced between Java 22 and Java 25. It is designed to help developers understand changes between LTS releases and make upgrading from Java 21 to Java 25 easier.
All examples are implemented as JUnit 5 tests, allowing you to run and verify each feature in action. All included features are finalized and ready for production use.
| Java Version | Key Features (Finalized, Production-Ready) |
|---|---|
| Java 22 | - JEP 456: Unnamed Variables & Patterns - JEP 454: Foreign Function & Memory API - JEP 458: Launch Multi-File Source-Code Programs |
| Java 23 | - JEP 467: Markdown Documentation Comments |
| Java 24 | - JEP 485: Stream Gatherers |
| Java 25 | - JEP 506: Scoped Values - JEP 510: Key Derivation Function API - JEP 512: Compact Source Files and Instance Main Methods - JEP 513: Flexible Constructor Bodies |
⚠️ Note: This table includes only finalized, production-ready features. Features in preview or incubator status are not included.
This project serves as a practical reference to understand new finalized features and API changes across LTS releases, making the migration smoother:
- Explore examples in each version folder to identify new language syntax or API changes.
- Run the JUnit tests to ensure your code behaves consistently across versions.
- Use this project as a step-by-step guide for upgrading your projects incrementally.
All examples are safe for production environments.
-
Install JDK 25 (latest release).
Although examples are grouped by version, the project is compiled and executed with Java 25.
-
Build and run with either Gradle or Maven using the included wrappers (
./gradlew,./mvnw).
The wrapper will ensure the correct Gradle version is used.
To clean and run all tests:
./gradlew clean testIf you’re having issues with Gradle, try these commands to fix them:
- Stop all running Gradle daemon processes:
./gradlew --stop- Clean build, refresh dependencies, and run tests (forces re-download of dependencies)
./gradlew clean test --refresh-dependenciesFor more details of Gradle build support see build.gradle in the project's root folder.
The wrapper will download and use the correct Maven version. To clean and run all tests:
./mvnw clean testFor more details of Maven build support see pom.xml in the project's root folder.
- JEPs in Java 22
- JEPs in Java 23
- JEPs in Java 24
- JEPs in Java 25
- Java Foreign Function & Memory API (FFM API)
- Markdown in Java Docs? Shut Up and Take My Comments!
- Stream Gatherers in JDK 24
- Java 25 Launch Stream