JDK 18 · JSR 393

Java 18

JDK 18 is Java SE 18, JSR 393, generally available on 22 March 2022. The charset default becomes UTF-8. The JDK includes a simple web server. Pattern matching for switch is a second preview. Finalization is deprecated for removal.

How to read the status

Language

Pattern Matching for switch (Second Preview)

JEP 420 · Preview · Language

Pattern matching for switch is previewed again. It is not final.

First preview in Java 17 (JEP 406). Final in Java 21 (JEP 441).

OpenJDK JEP 420 (leaves JavaMastery)

Related reading: Control flow

APIs / Libraries

Foreign Function & Memory API (Second Incubator)

JEP 419 · Incubator · APIs / Libraries

The foreign function and memory API incubates a second time.

First incubator in Java 17 (JEP 412). Preview in Java 19 (JEP 424).

OpenJDK JEP 419 (leaves JavaMastery)

Vector API (Third Incubator)

JEP 417 · Incubator · APIs / Libraries

The Vector API incubates a third time.

Still incubating in Java 25 (JEP 508).

OpenJDK JEP 417 (leaves JavaMastery)

JVM / Runtime

UTF-8 by Default

JEP 400 · Final · JVM / Runtime

Charset.defaultCharset() is UTF-8 unless the user overrides it. Programs that assumed the operating system’s charset can change behavior.

OpenJDK JEP 400 (leaves JavaMastery)

Related reading: Strings

Deprecate Finalization for Removal

JEP 421 · Final · JVM / Runtime

Finalizers are deprecated for removal. The deprecation is the change in this release. Finalizers still run.

OpenJDK JEP 421 (leaves JavaMastery)

Tools / Platform

Code Snippets in Java API Documentation

JEP 413 · Final · Tools / Platform

Javadoc can include code snippets from source files, so an example can be compiled rather than copied into a comment.

OpenJDK JEP 413 (leaves JavaMastery)

Related reading

Historical notes

Java 18 does not finalize virtual threads, record patterns, or structured concurrency. Those are not in this release. There is no Java 18 sample. UTF-8 by default is a change of default, not a new API, and jwebserver is a command-line tool rather than a small library program.

Sources. General availability, JSR 393, and the JEP list: OpenJDK JDK 18. OpenJDK JDK 18 (leaves JavaMastery)

All versions