Java 17
Table of contents
Java 17 New features
Java 17 is a version of the Java programming language that was released in September 2021. It includes a number of new features and improvements, including:
- Sealed Classes: Sealed classes allow developers to explicitly specify which classes can extend or implement a given class, and provide a way to control which methods can be called on instances of those classes.
- Records: Records are a new kind of type in Java that provide a concise way to define a simple data holder class, similar to a struct in C or a data class in Kotlin.
- Pattern Matching for instanceof: The instanceof operator now supports pattern matching, which allows developers to write more concise and readable code when working with complex data structures.
- Text Blocks: Text blocks are a new kind of string literal that can span multiple lines of code and preserve line breaks and white space.
- Foreign-Memory Access API: The Foreign-Memory Access API is a new set of low-level APIs that allow Java programs to directly access and manipulate memory outside the Java heap.
- Hidden Classes: Hidden classes are a new kind of class that can be created at runtime, but are not visible to the class loader. They are intended to be used as implementation details of other classes, and can help improve the performance and security of Java programs.
- Improved Socket API: The Socket API has been updated to support new features, including socket options, IPv6 support, and support for datagram sockets.
- Enhanced Deprecation: Deprecated APIs can now be marked with a severity level, which allows developers to indicate the level of impact that their removal will have on users of the API.
- Reimplementation of the Legacy Datagram and MulticastSocket APIs: The legacy Datagram and MulticastSocket APIs have been re-implemented to improve their performance and reliability.
- Improved Performance of java.util.Map: The performance of the java.util.Map interface has been improved, with the addition of new methods and optimizations to existing methods.
- Improved Performance of java.util.stream: The performance of the java.util.stream API has been improved, with the addition of new methods and optimizations to existing methods.
- Enhanced Support for Unicode: Java 17 includes improved support for Unicode, including the addition of new characters and support for new scripts.
- Enhanced Support for TLS 1.3: Java 17 includes improved support for the TLS 1.3 security protocol, including the addition of new APIs and improved performance.
- Enhanced Support for JFR Events: Java Flight Recorder (JFR) is a tool for collecting and analyzing data about the performance and behavior of a Java application. Java 17 includes enhanced support for JFR events, including the ability to trigger events based on custom criteria.
- Enhanced Support for Native Image Generation: The Native Image Generation tool allows developers to create a native executable image from a Java application, which can improve the performance of the application. Java 17 includes enhanced support for native image generation, including the ability to generate images for ARM64 architectures.
- Enhanced Support for Application Class-Data Sharing: Application Class-Data Sharing (AppCDS) is a feature that allows multiple Java applications to share common class data, which can improve the start-up time and memory usage of those applications. Java 17 includes enhanced support for AppCDS, including the ability to create and use shared class data from the command line.
- Enhanced Support for JVM Constants API: The JVM Constants API is a set of APIs that allow Java programs to access and manipulate constants at