https://github.com/neiljbrown/java17-examples
Examples of Java language features available in Java 17 (new features introduced since previous LTS release, Java 11).
https://github.com/neiljbrown/java17-examples
examples java java17
Last synced: 9 months ago
JSON representation
Examples of Java language features available in Java 17 (new features introduced since previous LTS release, Java 11).
- Host: GitHub
- URL: https://github.com/neiljbrown/java17-examples
- Owner: neiljbrown
- Created: 2021-09-25T16:34:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-06T15:58:14.000Z (about 4 years ago)
- Last Synced: 2025-03-28T02:11:11.346Z (9 months ago)
- Topics: examples, java, java17
- Language: Java
- Homepage:
- Size: 134 KB
- Stars: 4
- Watchers: 1
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
= Java 17 Examples
:sectlinks:
:sectnums:
:sectnumlevels: 4
:toclevels: 4
== Purpose
This project provides a set of runnable Java code examples illustrating new language features and APIs that have been
introduced in Java since JDK 11, up to and including JDK 17, the next Long Term Support (LTS) release, which is
scheduled to become generally available in Sept 2021.
== Showcased Java Language Features
The project showcases examples of language features that were finalised in JDK releases 12 to JDK 17 inclusive. These
are summarised below, categorised by JDK release, along with a link to their final Java Enhancement Proposal (JEP).
1) Language Features Finalised in JDK 14 (March 2020) -
* *Switch Expressions* - See https://openjdk.java.net/jeps/361[JEP 361: Switch Expressions].
2) Language Features Finalised in JDK 15 (Sept 2020) -
* *Text Blocks* - See https://openjdk.java.net/jeps/378[JEP 378: Text Blocks].
3) Language Features Finalised in JDK 16 (March 2021) -
* *Pattern Matching for instanceof* - See https://openjdk.java.net/jeps/394[JEP 394: Pattern Matching for instanceof].
* *Records* - See https://openjdk.java.net/jeps/395[JEP 395: Records].
4) Language Features Finalised in JDK 17 (Sept 2021) -
* *Sealed Classes* - See https://openjdk.java.net/jeps/409[JEP 409: Sealed Classes].
For a full list of the JEPs that were added since the previous JDK 11 LTS release, see
https://openjdk.java.net/projects/jdk/17/jeps-since-jdk-11.
== Source Code
The examples are implemented as a set of easy to run tests, using JUnit (5). The source code for the examples can be
found in the src/test/java folder.
An explanation of the showcased language features, along with guidance on their usage, can be found in the Javadoc of
each of the code examples. (See the commands for generating Javadoc below).
== Building and Running the Examples
You will need to install a Java 17 JDK. (Use of sdkman is recommended).
Support is provided for building and running the project using either Gradle or Maven as described in the sections
below.
=== Gradle
The minimum required version of Gradle will be installed if you execute the build using the supplied Gradle wrapper
script (./gradlew).
To compile and run all the example tests, enter the following command in the project's root folder:
`./gradlew clean test`
To generate the Javadoc, use the following command:
`./gradlew clean javadocTests`
The generated Javadoc can be found in the standard location for a Gradle project - build/docs/javadoc/index.html.
For more details of Gradle build support see build.gradle in the project's root folder.
=== Maven
The minimum required version of Maven will be installed if you execute the build using the supplied Maven wrapper
script (./mvnw).
To compile and run all the example tests, enter the following command in the project's root folder:
`./mvnw clean test`
To generate the Javadoc, use the following command:
`./mvnw javadoc:test-javadoc`
The generated Javadoc can be found in the standard location for a Maven project - target/site/testapidocs/index.html.
For more details of Maven build support see pom.xml in the project's root folder.
== Other Examples
You can find similar code examples for the new features introduced in earlier versions in Java in my other code
repos, including -
* Java 11 - See https://github.com/neiljbrown/java11-examples[GitHub project neiljbrown/java11-examples]
* Java 10 - See https://github.com/neiljbrown/java10-examples[GitHub project neiljbrown/java10-examples]
* Java 9 - See https://github.com/neiljbrown/java9-examples[GitHub project neiljbrown/java9-examples]
* Java 7 and 8 - See my https://bitbucket.org/neilbrown/[Bitbucket projects]
End.