Java/JDK 21 is officially released! 15 features at a glance

JDK 21 has been officially released on September 19, 2023. This article summarizes the new features released in JDK 21.

Release Notes

According to the release plan, the JDK 21 released this time will be a long-term support version (LTS version). LTS versions are released every 2 years, and the last long-term support version was JDK 17 released in September 21.

This version is the reference implementation of Java SE Platform version 21, as specified by JSR 396 in the Java Community Process .

Installation package download

It is mainly divided into OpenJDK version and Oracle version. The download address is as follows:

If the above version is used for personal study, there is not much difference. But if it is used for commercial purposes, you need to carefully check the relevant authorization. Commercial use of Oracle JDK requires compliance with the Oracle No-Fee Terms and Conditions (NFTC) agreement, while OpenJDK is licensed under the GPL v2 license.

For more basic knowledge about Java, you can refer to the book " Java Core Programming ", which is described in great detail.

JDK 21 new feature description

Formal stable features

JEP 431: Sequence Collections

Sequenced Collections are in core-libs/java.util:collectionsthe package.

The JEP proposes the introduction of "a new family of interfaces for representing the concept of collections whose elements are arranged in a predefined sequence or order as structural properties of the collection." The motivation for this proposal was due to the Lack of predefined order and unified set of operations.

JEP 439: Generational ZGC

Generational ZGC is in hotspot/gcthe package.

Improve application performance by extending the Z Garbage Collector (ZGC) to maintain independent generation of young and old objects. This will allow the ZGC to collect young objects more frequently - objects that tend to die young.

JEP 440: Recording Mode

Enhance the Java programming language with Record Patterns to deconstruct record values. Record schemas and type schemas can be nested to enable powerful, declarative, and composable forms of data navigation and processing.

JEP 441: switch pattern matching

Enhance the Java programming language with pattern matching of switch expressions and statements. By extending pattern matching to switch, expressions can be tested against multiple patterns, each with a specific operation, allowing complex data-oriented queries to be expressed concisely and safely.

JEP 444: Virtual Threads

Introducing virtual threads (Virtual Threads) to the Java platform. Virtual threads are lightweight threads that significantly reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.

For details, see "Java Next Generation High Concurrency Technology - Virtual Threads (Virtual Threads)" .

JEP 449: Deprecation of Windows 32-bit x86 port

The Windows 32-bit x86 port is deprecated and is intended to be removed in a future release.

JEP 451: Prepare to disable dynamic loading of proxies

Warn when dynamically loading agents into a running JVM. These warnings are intended to prepare users for a future version that will not allow dynamic loading of proxies by default to improve integrity by default. Loading the agent's serviceability tool on startup does not cause a warning to be issued in any build.

JEP 452: Key Encapsulation Mechanism API

Introduces an API for Key Encapsulation Mechanism (KEM), an encryption technology that uses public key encryption to protect symmetric keys.

Preview phase functionality

JEP 430: String Templates (Preview)

Enhance the Java programming language with String Templates. String templates complement Java's existing string literals and text blocks by coupling text with embedded expressions and template processors to produce specialized results. This is a preview of language features and APIs.

JEP 442: External Functions and Memory API (Third Preview)

Introduces APIs through which Java programs can interoperate with code and data outside the Java runtime. By efficiently calling external functions (i.e., code outside the JVM), and by safely accessing external memory (i.e., memory not managed by the JVM), the API enables Java programs to call native libraries and process native data without Vulnerabilities and dangers of JNI. This is a preview API.

JEP 443: Unnamed patterns and variables (preview)

Use unnamed patterns and unnamed variables to enhance the Java language. Unnamed pattern matching records components without specifying the name or type of the component. Unnamed variables can be initialized but not used. Both are _represented by the underscore character. This is a preview language feature.

JEP 445: Unnamed class and instance main methods (preview)

Develop the Java language so that students can write their first programs without understanding the language features designed for large programs. Without using a separate Java dialect, students can write compact declarations for a single class of programs and then seamlessly extend the program to use more advanced functionality as their skills develop. This is a preview language feature.

JEP 446: Scoped Values ​​(Preview)

Introduces scoped values ​​that can be safely and efficiently shared to methods without using method parameters. They take precedence over threaded local variables, especially when using a large number of virtual threads. This is a preview API.

In fact, the scope value is an implicit method parameter. It's "as if" each method in a series of calls had an extra, invisible parameter. No method declares this parameter, only methods that have access to the scoped value object can access its value (data). Scoped values ​​allow data to be safely passed from the caller to remote callees through a series of intermediate methods that do not declare parameters for the data and have no access to the data.

JEP 453: Structured Concurrency (Preview)

Simplify concurrent programming by introducing APIs for Structured Concurrency. Structured concurrency treats groups of related tasks running in different threads as a single unit of work, simplifying error handling and elimination, improving reliability, and enhancing observability. This is a preview API.

Incubation stage function

JEP 448: Vector API (Incubator Phase 6)

Introduces APIs to represent vector computations that are reliably compiled at runtime into the best vector instructions on supported CPU architectures, enabling performance superior to equivalent scalar computations.

References

JetBrains releases Rust IDE: RustRover Java 21 / JDK 21 (LTS) GA With so many Java developers in China, an ecological-level application development framework .NET 8 should be born. The performance is greatly improved, and it is far ahead of .NET 7. PostgreSQL 16 is released by a former member of the Rust team I deeply regret and asked to cancel my name. I completed the removal of Nue JS on the front end yesterday. The author said that I will create a new Web ecosystem. NetEase Fuxi responded to the death of an employee who was "threatened by HR due to BUG". Ren Zhengfei: We are about to enter the fourth industrial revolution, Apple Is Huawei's teacher Vercel's new product "v0": Generate UI interface code based on text
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/waylau/blog/10112170