Java 18 

Java 18 is a non-LTS feature release following Java 17 LTS. It preceded Java 19 (September 2022). Java 18 reached end-of-life in September 2022 and receives no further updates. 

Java 18 Release Details 

Release DateMarch 22, 2022
LTSNo
OpenJDK End-of-LifeSeptember 20, 2022
Class File Version62.0
Unicode Version13.0.0
Notable ForUTF-8 by default, simple web server, pattern matching for switch second preview 

Java 18 is end-of-life. Organizations running it should upgrade to a current LTS release: Java 21 or Java 25

Java 18 Language Features 

Pattern Matching for switch (Second Preview, JEP 420) 

Second preview of pattern matching in switch expressions and statements. Builds on the first preview from Java 17 (JEP 406). Added support for guarding patterns with when clauses. Previewed through Java 18-20, finalized in Java 21 (JEP 441). 

Java 18 API Changes 

Simple Web Server (JEP 408) 

A minimal HTTP static file server in com.sun.net.httpserver. Not a replacement for production servers. Intended for prototyping, testing, and ad-hoc file sharing. 

java -m jdk.httpserver -p 8080 -d /path/to/files 

Reimplement Core Reflection with Method Handles (JEP 416) 

java.lang.reflect.Method, Field, and Constructor are now implemented via java.lang.invoke method handles. The API surface is unchanged. This reduces maintenance burden by unifying reflection and method handle code paths and prepares for virtual thread integration. 

Internet-Address Resolution SPI (JEP 418) 

An SPI for customizing DNS and hostname resolution. Applications can inject their own resolver via InetAddressResolverProvider. Enables custom DNS implementations, service discovery integration, and testing with deterministic hostname resolution. 

Foreign Function and Memory API (Second Incubator, JEP 419) 

Second incubation of the combined foreign function and memory API. Merged the Foreign Linker API and Foreign-Memory Access API into a single API. Continued incubating through Java 20-21, finalized in Java 22 (JEP 454). 

Vector API (Third Incubator, JEP 417) 

Third incubation. Provides a Java API for expressing vector computations that compile to optimal SIMD instructions on x86 (AVX) and ARM (NEON/SVE) processors. Still incubating as of Java 26 (JEP 529, tenth incubator). 

Deprecate Finalization for Removal (JEP 421) 

Object.finalize() and the finalization mechanism are deprecated for removal. Finalizers have been problematic since Java 1.0: no ordering guarantees, unpredictable timing, and unhandled exceptions in finalizers silently disappear. Applications should migrate to try-with-resources or Cleaner (added in Java 9). 

Java 18 JVM Changes 

UTF-8 by Default (JEP 400) 

The default charset is now UTF-8 on all platforms. Previously, the default charset depended on the operating system locale (Cp1252 on Windows English, Shift-JIS on Japanese Windows, UTF-8 on Linux). This caused bugs when code ran on different platforms without explicit charset specification. 

// Before Java 18: platform-dependent behavior 

new FileReader(“config.properties”) 

// Explicit charset (always recommended) 

new FileReader(“config.properties”, StandardCharsets.UTF_8) 

Code Snippets in Java API Documentation (JEP 413) 

@snippet tag for JavaDoc. Allows inline code examples with compile-time validation and syntax highlighting. Replaces <pre>{@code …}</pre> blocks that had no validation. 

/** 

 * {@snippet : 

 * var result = stream.map(String::toUpperCase) 

 *                    .filter(s -> s.startsWith(“A”)) 

 *                    .toList(); 

 * } 

 */ 

Java 18 Upgrade Path 

Java 18 has been end-of-life since September 2022. Recommended upgrade targets: 

  • Java 21 LTS: Adds virtual threads (final), pattern matching for switch (final), record patterns, generational ZGC 
  • Java 25 LTS: Current LTS. Adds scoped values, compact source files, AOT method profiling, compact object headers 

Java 18 applications should upgrade directly to Java 21 LTS rather than Java 19 or 20, which are also end-of-life. 

Azul’s Java 18 Support 

Azul Platform Core provides TCK-certified builds of current LTS releases with extended support. A single subscription covers all supported versions from Java 6 through Java 26. 

Contact Us

Contact us to learn more about our migration services, support, modernization services, and more!