What is new in Java 18 ?


This is an alive post of what will become Java 18, and, as expected, this post will expand and change over time, until the development of Java 18 is frozen in 2022. I am planning to update this post when a new feature (JEP) is targeted for JDK 18, or when there is an important update on an already targeted JEP.

If something is implemented in an incubator module, it is not a permanent feature and it is released to get feedback from developers. API in such a module may change or completely removed (not released in any future JDK release). You need to use --add-modules to use incubator modules.

If something is a preview feature, it is fully specified and implemented, but provided in a release to gather feedback, so it is not a permanent change yet. You need to use --enable-preview to use such features.


  • 2022/03/22: Java 18 is released.
  • 2022/01/05: Update. Rampdown Phase One since 2021/12/09, so the feature set is frozen.
  • 2021/11/20: First post.

Java 18 Features

The list is taken from the OpenJDK JDK 18 project page.

JEP 400: UTF-8 by Default

Many methods in standard API depends on a default charset that can be configured in different ways. This JEP aims to make the default charset UTF-8. This will be accomplished by two values of file.encoding system property. If it is set to COMPAT, then the default charset will be found as in JDK 17 and before. If it is set to UTF-8, then the default charset will be UTF-8.

JEP 408: Simple Web Server

A very simple web server will be provided to serve static files.

It can be run like this:

$ jwebserver
Binding to loopback by default. For all interfaces use "-b" or "-b ::".
Serving /home/ubuntu and subdirectories on port 8000

It serves only static files, and creates an index file for a directory, and serves only HEAD and GET requests. These is also an API which can be used to extend the functionality. Here how a directory listing is displayed:

JEP 413: Code Snippets in Java API Documentation

This JEP will introduce @snippet tag to Java documentations that can be used to write an inline code fragment or link an external source file.

JEP 416: Reimplement Core Reflection with Method Handles

At the moment, different parts of java.lang.reflect uses different mechanisms. These will be reimplemented on top of method handles to simplify maintenance.

JEP 417: Vector API (Third Incubator)

This is the continuation of Vector API introduced in JDK 16 with JEP 338, and as JEP 414 in Java 17. Some improvements and enhancements will be done particularly to support ARM Scalar Vector Extensions and to improve vector operations accepting masks.

JEP 418: Internet-Address Resolution SPI

At the moment, java.net.InetAddress resolves the host names to IP addresses using the system (OS) domain name resolver. This JEP will introduce a way to provide a service loader to InetAddress to locate name resolution provider. By default, InetAddress will use the native resolver.

JEP 419: Foreign Function & Memory API (Second Incubator)

This is the second iteration of this API in incubation. This API contains functions to access off-heap data (out of Java Heap space) and invoke native code (without JNI).

JEP 420: Pattern Matching for switch (Second Preview)

This is the second preview of pattern matching for switch statements that is first released in Java 17.

JEP 421: Deprecate Finalization for Removal

“finalization” in Java is going to be deprecated. It will still be enabled but it can be fully disabled with command-line option --finalization=disabled. This includes all finalize() methods, but not finally in try-catch-finally blocks.