News

What's New in JDK 18?

The latest update of the Java Development Kit (JDK 18), becomes generally available (GA) next Tuesday, and though it’s not a Long-Term Support (LTS) release, there's a lot to look forward to in this update.  

JDK 18, which is the reference implementation of version 18 of the Java SE Platform (as specified by JSR 393 in the Java Community Process), is set to go GA on March 22, on schedule with the accelerated, six-month release cadence Oracle announced in 2017. JDK 17, which was the second LTS since JDK 11 went GA in 2018, was announced in September 2021.

The JDK 18 release implements a relatively short list of JDK Enhancement Proposals (JEPs), including:

JEP 400: UTF-8 by Default
Specify UTF-8 as the default charset of the standard Java APIs. With this change, APIs that depend upon the default charset will behave consistently across all implementations, operating systems, locales, and configurations.

JEP 408: Simple Web Server
Provide a command-line tool to start a minimal web server that serves static files only. No CGI or servlet-like functionality is available. This tool will be useful for prototyping, ad-hoc coding, and testing purposes, particularly in educational contexts.

JEP 413: Code Snippets in Java API Documentation
Introduce an @snippet tag for JavaDoc's Standard Doclet, to simplify the inclusion of example source code in API documentation.

JEP 416: Reimplement Core Reflection with Method Handles
Reimplement java.lang.reflect.MethodConstructor,and Field on top of java.lang.invoke method handles. Making method handles the underlying mechanism for reflection will reduce the maintenance and development cost of both thejava.lang.reflect and java.lang.invoke APIs.

JEP 417: Vector API (Third Incubator)
Introduce an API to express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.

JEP 418: Internet-Address Resolution SPI
Define a service-provider interface (SPI) for host name and address resolution, so that java.net.InetAddress can make use of resolvers other than the platform's built-in resolver.

JEP 419: Foreign Function & Memory API (Second Incubator)
Introduce an API by which Java programs can interoperate with code and data outside of the Java runtime. By efficiently invoking foreign functions (i.e., code outside the JVM), and by safely accessing foreign memory (i.e., memory not managed by the JVM), the API enables Java programs to call native libraries and process native data without the brittleness and danger of JNI.

JEP 420: Pattern Matching for switch (Second Preview)
Enhance the Java programming language with pattern matching for switch expressions and statements, along with extensions to the language of patterns. Extending pattern matching to switch 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. This is a preview language feature in JDK 18.

JEP 421: Deprecate Finalization for Removal
Deprecate finalization for removal in a future release. Finalization remains enabled by default for now, but can be disabled to facilitate early testing. In a future release it will be disabled by default, and in a later release it will be removed. Maintainers of libraries and applications that rely upon finalization should consider migrating to other resource management techniques such as the try-with-resources statement and cleaners.

Oracle announced last year that it would begin providing an LTS every two years instead of every three years. The company says it will ship the next LTS release (JDK 21) in September 2023.

"One of the biggest challenges Java developers face today is that their organization only allows them to use the latest LTS release," said Georges Saab, VP of development in Oracle's Java Platform Group, when JDK 17 was announced last year. "By moving LTS releases to every two years, developers who are with conservative organizations now have more choice and access to the features that they love and want to use."

All JDK releases will be provided under a free-to-use license, Oracle has said, until a full year after the next LTS release. Oracle also says it will continue providing OpenJDK releases under the open-source General Public License (GPL), as it has since 2017.

GPL-licensed OpenJDK builds from Oracle are available here.

About the Author

John K. Waters is the editor in chief of a number of Converge360.com sites, with a focus on high-end development, AI and future tech. He's been writing about cutting-edge technologies and culture of Silicon Valley for more than two decades, and he's written more than a dozen books. He also co-scripted the documentary film Silicon Valley: A 100 Year Renaissance, which aired on PBS.  He can be reached at [email protected].