• Mon. Nov 18th, 2024

JDK 23: The new features in Java 23

Byadmin

Mar 29, 2024


Java Development Kit (JDK) 23, the next planned version of standard Java, is off and running, with two features now scheduled for the release.Due September 19, JDK 23 has just added a second preview of a class-file API, providing a standard API for parsing, generating, and transforming Java class files. This feature was previously previewed in JDK 22, which was released on March 19. Previously slotted for JDK 23 was a preview of primitive types in patterns, instanceof, and switch.The class-file API is intended to provide an API for processing class files that tracks the class file format defined by the Java Virtual Machine specification. It also would enable JDK components to migrate to the standard API and eventually remove the JDK’s internal copy of the third-party ASM library. The class-file API would add refinements including streamlining the CodeBuilder class, which has factory methods for bytecode instructions, including low-level factories, mid-level factories, and high-level builders for basic blocks.For JDK 23, Java’s builders removed mid-level methods that duplicated low-level methods or were infrequently used, while renaming the remaining mid-level methods to improve usability. They also refined the ClassSignature class model, which has been improved to model the generic signatures of superclasses and superinterfaces more accurately. According to the OpenJDK proposal behind this feature, the Java platform should define and implement a standard class-file API that evolves together with the class-file format, which can evolve every six months.Previously cited for inclusion in JDK 23 is another preview feature, primitive types in patterns, instanceof, and switch. This feature would enhance pattern matching by allowing primitive type patterns in all pattern contexts, and extend instanceof and switch to work with all primitive types. Goals include allowing type patterns for all types (primitive or reference), allowing primitive type patterns in both nested and top-level contexts, and providing easy-to-use constructs that eliminate the risk of losing information due to unsafe casts. Other goals include aligning pattern types with instanceof, aligning instanceof with safe casting, and allowing switch to process values of any primitive type.A number of other features previewed in JDK 22 could make it into JDK 23. These include statements before super(…), which would give developers greater freedom in expressing constructor behavior; string templates, which would make it easy to express strings that include values computed at run time; stream gatherers, which would make stream pipelines more flexible and expressive; scoped values, which would enable sharing of immutable data within and across threads; and implicitly declared classes and instance main methods, which would make it easier for beginning programmers to write programs without needing to understand language features designed for large programs. A vector API, which would express vector computations that reliably compile at run time to optimal vector instructions on supported architectures, is another potential feature in JDK 23. A vector API was in a seventh incubator stage in JDK 22. Derived record creation and a hot code heap proposal, which would reduce application execution times, also are possibilities.Java steward Oracle also has revealed plans for Java in 2024. Oracle outlined improvements that involve  OpenJDK projects ranging from Amber, for developing smaller, productivity-oriented features, to Babylon, for extending Java to foreign programming models such as GPUs, to Valhalla, for augmenting the Java object model with value objects to eliminate longstanding performance bottlenecks.

Copyright © 2024 IDG Communications, Inc.



Source link