01 logo

What are the New Features in Java (JDK) 18 in 2022

Build 27 of the JDK 18 early-access builds was made available this past week, featuring updates from Build 26 that include fixes to various issues.

By varunsnghPublished 4 years ago 4 min read

Java Development Kit (JDK) 18 will be released on March 22, 2021. The new version of standard Java will have nine new features, with the feature set having been frozen as of December 9.

The release has moved into an initial ramp-down phase. Upgrades to standard Java are released every six months, with the most recent, JDK 17, arriving in September.

The OpenJDK page lists the following features as officially targeting JDK 18.

A service provider interface, a simple web server, a vector API, code snippets, a reimplementation of core reflection, a UTF-8 charset, the second incubator of a foreign function, and memory API, the second preview of pattern matching for switch statements, and the deprecation of finalization, which was the last addition.

Before general availability, a second ramp-down phase is set for January 20, 2022. Release candidates are due February 10 and February 24 of next year.

While JDK 17 was long-term support (LTS) release that will receive at least eight years of support from Oracle, JDK 18 will be a short-term feature release that is supported for six months.

Early-access builds of JDK 18 can be found for Linux, Windows, and macOS at java.net. To understand the detailed Java concept sign up for any Java training online.

Specifics of the JDK 18 proposals include:

Internet-address resolution SPI, the proposal is to define an SPI for host and name address resolution so that Inet. The address can use resolvers other than the platform's built-in resolver.

Motivations for this effort include better enablement of Project Loom, concurrency and new programming models in Java, and integrating new network protocols, customization, and enabling testing. The proposal does not involve developing an alternative resolver for the JDK.

The second preview of pattern matching for the switch, in which the Java language would be enhanced with pattern matching for switch expressions and statements, along with extensions to the language of patterns. This was previewed in JDK 17.

Extending pattern matching to switch allows an expression to be tested against several patterns, each with a specific action so that that complex data-oriented queries can be expressed concisely and safely.

The reimplementation of core reflection with method handle

Would reimplement lang. Reflect. Method, Constructor, and Field on top of Java. Lang. Invoke method handles. Having method handles serve as the underlying mechanism for reflection will reduce maintenance and development costs of the Java.lang.reflect and Java. Lang. invoke APIs.

Simple web server proposal

A command-line tool would be provided to start a minimal web server that serves static files only. No CGI or servlet-like functionality is available. The tool will be helpful in prototyping, ad-hoc coding, and testing, particularly in educational contexts. The goals of the plan include:

Offering an out-of-the-box static HTTP file server with easy setup and minimal functionality.

Reducing developer activation energy and making the JDK more approachable.

Providing a default implementation via the command line and a small API for programmatic creation and customization.

Providing a feature-rich or commercial-grade server is not a goal of the proposal.

Foreign function and memory API

An API is introduced through which Java programs can interoperate with code and data outside of the Java runtime.

By invoking foreign functions – code outside the JVM – and by safely accessing foreign memory – memory not managed by the JVM – the API lets Java programs call native libraries and process native data without the brittleness and danger of JNI (Java Native Interface).

The intent is to replace JNI with a superior, pure Java development model. This API was incubated in JDK 17.

For JDK 18, refinements would be incorporated, based on feedback, such as support for more carriers such as Boolean and MemoryAddress in memory access var handles, and a new API to copy Java arrays to and from memory segments.

The vector to-vectorizer but with a user model that makes vectorization more predictable.

JDK 18 would also add support for the ARM Scalar Vector Extension platform and improve the performance of vector operations that accept masks on architectures that support masking in hardware API would be incubated for a third time in JDK 18, having previously been incubated in JDK 16 and JDK 17.

This proposal would express vector computations that compile at run time to optimal vector instructions on supported CPU architectures, achieving performance superior to equivalent scalar computations.

Vector operations express a degree of parallelization, enabling more work on a single CPU cycle, thus producing significant performance improvements.

The platform-agnostic vector API aims to provide a way to write complex algorithms in Java using the existing HotSpot

Specifying UTF-8 as the default charset of the standard Java APIs.

UTF-8 is a variable-wide character encoding for electronic communication and is considered the web's standard charset.

The charset is a character encoding capable of encoding all characters on the web. Through this change, APIs that depend on the default charset will behave consistently across all implementations, operating systems, locales, and configurations.

The proposal is not intended to define new Java-standard or JDK-specific APIs. Proponents of the proposal expect that applications in many environments will see no impact from Java's choice of UTF-8, like MacOS, many Linux distributions, and many server applications already support UTF-8. However, there is a risk in other environments.

The most apparent is that applications depending on the default charset will behave incorrectly when processing data produced when the default charset is unspecified. Data corruption may silently occur.

The main impact is expected to occur on users of Windows systems in Asian locales and possibly some server environments in Asia and other locales.

Code snippets in Java API documentation

Involving the introduction of a tag for JavaDoc's Standard Doclet to simplify including example source code in the API documentation. Among the plan's goals is facilitating the validation of source code fragments by providing API access to those fragments.

While correctness is the author's responsibility, enhanced support in JavaDoc and related tools can make it easier to achieve. Other goals include:

Enabling modern styling, such as syntax highlighting.

The automatic linkage of names to declarations.

Enabling better IDE support for creating and editing snippets.

The proposal notes that API documentation authors often include source code fragments in documentation comments.

tech news

About the Creator

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2026 Creatd, Inc. All Rights Reserved.