Significant Changes in JDK 18 Release
See JDK 18 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 18.
The following are some of the updates in Java SE 18 and JDK 18:
Tools
- The new command-line tool
jwebserver
enables you to start a minimal web server that serves static files. This tool is useful for prototyping and testing. See JEP 408: Simple Web Server. - A
@snippet
tag is added to JavaDoc's Standard Doclet, which simplifies the inclusion of example source code in API documentation. See JEP 413: Code Snippets in Java API Documentation and Programmer's Guide to Snippets.
Library Changes
- UTF-8 is now the default charset for the Java SE APIs. With this change, APIs that depend on the default charset will behave consistently across all implementations, operating systems, locales, and configurations. See JEP 400: UTF-8 by Default and Be Aware Of The Default Charset.
- A service-provider interface (SPI) is defined for the host name and
address resolution, so that
java.net.InetAddress
can make use of resolvers other than the platform's built-in resolver. See JEP 418: Internet-Address Resolution SPI. See also the section Specify Mappings from Host Names to IP Addresses in Java Platform, Standard Edition Core Libraries for information about thejdk.net.hosts.file
system property, which enables you to configure InetAddress to use a specifichosts
file, rather than the system-wide resolver, to map host names to IP addresses. - Core reflection with method handles has been reimplemented. This
will reduce the maintenance and development cost of both the
java.lang.reflect
andjava.lang.invoke
APIs. See JEP 416: Reimplement Core Reflection with Method Handles.
Preview Features and Incubator Modules
See JEP 12: Preview Features for more information about preview features and JEP 11: Incubator Modules for more information about incubator modules.
- The preview feature Pattern Matching for
switch
Expressions and Statements has been re-previewed in this release. This feature allows an expression to be tested against a number of patterns, each with a specific action, so that complex data-oriented queries can be expressed concisely and safely. See JEP 420: Pattern Matching for switch (Second Preview) and Pattern Matching for switch Expressions and Statements in Java Platform, Standard Edition Java Language Updates. - The Foreign Function and Memory API, which was introduced in Java SE 17, allows Java programs to interoperate with code and data outside of the Java runtime. The API is re-incubated in this release along with enhancements. See JEP 419: Foreign Function & Memory API (Second Incubator).
- The Vector API was introduced in Java SE 16 as an incubating API. In this release the API is re-incubated with enhancements and performance improvements. See JEP 417: Vector API (Third Incubator).
Removed APIs, Tools, and Components
For more details on removals and deprecations, see:
In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 18.