Java Development Kit (JDK) 21, due in September as the next long-term support release of Oracle’s standard Java implementation, is beginning to take form, with sequenced collections and string templates slated for the release so far.

Although the JDK 21 release page still lists no features as of March 3, 2023, two Java Enhancement Proposals covering these two features already have been designated for JDK 21. The specific proposals include:

  • Sequenced collections introduces interfaces to represent collections with a defined encounter order. Each collection has well-defined first and second elements and so forth, to the last element. Uniform APIs are provided for accepting first and last elements and processing elements in reverse order. Motivating the proposal is a situation in which Java’s collections framework lacks a collection type to represent a sequence of elements with a defined encounter order. It also lacks a uniform set of operations that apply across these collections. These gaps have been a problem and a source of complaints. The proposal calls for defining interfaces for sequencing for collections, sets, and maps, and retrofitting this into the existing collections type hierarchy. All of these new methods have default implementations.
  • String templatesto appear as a previewfeature, complementing Java’s existing string literals and text blocks by coupling literal text with embedded expressions and processors to produce specialized results. This API is intended to simplify writing of Java programs by making it easy to express strings that include computed values ​​at runtime. It promises to enhance readability of expressions, improve program security, retain flexibility, and simplify the use of APIs that accept strings written in non-Java languages. Enabling development of non-string expressions derived from combining literal text and embedded expressions also is a goal.

As a long-term support (LTS) release, JDK 21 would get five years of premier support and extended support until September 2031. The current LTS release is JDK 17, published in September 2021. Non-LTS releases, such as the JDK 20 release due March 21, and the current JDK 19 release, receive only six months of Premier support and no extended support.

New versions of Oracle’s standard Java implementation arrive every six months. Other possible features for JDK 21 include all the incubating and preview features in JDK 20, such as scoped values, record patternsand virtual threads. Universal generics and the asynchronous stack trace VM API could also be included.

Copyright © 2023 IDG Communications, Inc.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *