JDK 19: The new features in Java 19


Java Enhancement Package 19, because of this September, is now characteristic-complete, possessing just arrived at an original rampdown phase. Seven attributes target the launch like structured concurrency, file styles, a preview of a international perform and memory API, and aid for the open source Linux/RISC-V instruction established architecture (ISA).

With this most recent milestone in the launch procedure for regular Java, other prepared capabilities such as universal generics and benefit objects will have to hold out for a later model of the platform. JDK 19 follows the March 22 arrival of JDK 18. Common Java is on a six-month release cadence.

JDK 19 is slated to be officially produced for manufacturing use on September 20, preceded by a second rampdown phase commencing July 21, and release candidates to be released August 11 and August 25. Early access builds of JDK 19 can be accessed from jdk.java.web/19. The JDK 19 characteristics include:

  • Structured concurrency, in an incubator stage, is meant to simplify multithreaded programming by a structured concurrency library. This concurrency treats a number of responsibilities working in diverse threads as a solitary device of perform, to streamline error handling and cancellation. Reliability and observability are enhanced.
  • A preview of file styles, to deconstruct history values. Record designs and sort designs can be nested to allow a declarative, potent, and composable kind of knowledge navigation and processing. Goals of the proposal incorporate extending pattern matching to express extra sophisticated, composable data queries although not changing the syntax or semantics of sort designs. This proposal builds on pattern matching for instanceof, shipped in JDK 16  in March 2021. Future options may possibly contact for file patterns to be prolonged with abilities this sort of as array patterns and vararg patterns. File patterns is part of Project Amber, an work to investigate and incubate scaled-down, productiveness-oriented Java capabilities.
  • A preview of a overseas function and memory API, which would introduce an API by which Java packages can interoperate with code and data outdoors the Java runtime. By proficiently invoking overseas capabilities (i.e., code outside the Java runtime) and securely accessing international memory (i.e., memory not managed by the JVM) the API allows Java systems to phone indigenous libraries and approach indigenous facts without the threat and brittleness of the Java Native Interface (JNI). The overseas operate and memory API brings together two previously incubating APIs: the overseas memory entry API and the foreign linker API. The international functionality and memory API was previously incubated in JDK 17 and reincubated in JDK 18. The proposal’s objectives include things like ease of use, effectiveness, generality, and safety.
  • A preview of virtual threads, which are light-weight threads that dramatically cut down the energy of creating, keeping, and observing large-throughput, concurrent apps. Goals incorporate enabling server programs written in the very simple thread-for each-ask for model to scale with in the vicinity of-ideal hardware utilization, enabling existing code that makes use of the java.lang Thread API to undertake digital threads with minimal modify, and empower troubleshooting, debugging, and profiling of digital threads with existing JDK applications. It is not a goal of this proposal to alter the essential concurrency product in Java or supply a new info parallelism assemble in either the Java language or Java libraries. Nor is it a target to eliminate the traditional implementation of threads or to silently migrate existing programs to use virtual threads.
  • A third preview of pattern matching for change expressions and statements, extending sample matching to change, to let an expression to be examined versus a selection of styles, every with a unique action, so sophisticated information-oriented queries can be expressed concisely and safely and securely. This capability previously was previewed in JDK 17 and JDK 18. The 3rd preview would increase refinements including the substitution of guarded styles with when clauses in swap blocks. Also, the runtime semantics of a pattern switch when the price of the selector expression is null are a lot more carefully aligned with legacy change semantics. The plan’s targets include things like growing the expressiveness and applicability of change expressions and statements by allowing styles to show up in case labels. Other aims include making it possible for developers to take it easy the historic null-hostility of switch when wished-for, escalating the safety of swap statements and ensuring that present change expressions and statements continue on to compile with no improvements and execute with equivalent semantics.
  • A fourth incubation of a vector API that would categorical vector computations that reliably compile at runtime to optimal vector directions on supported CPU architectures, consequently acquiring overall performance exceptional to equal scalar computations. Builders utilizing the API gain a way to publish complex vector algorithms in Java, making use of the HotSpot automobile-vectorizer but with a consumer design that makes vectorizations far more predictable and strong. The vector API previously was incubated into JDK 16, JDK 17, and JDK 19.
    Advancements to the API proposed for JDK 19 include things like enhancements to load and store vectors to and from MemorySegments, as outlined by the International Perform and Memory API preview. JDK 19 would also include two cross-lane vector operations, compress and increase, collectively with a complementary vector mask compress procedure. The compress vector operation maps lanes of a resource vector, picked by a mask, to a place vector in lane buy, although the extend procedure does the inverse. The compress operation is practical in filtering question final results.
    In yet another addition to the vector API, bitwise integral lanewise operations would be expanded, together with operations these kinds of counting the quantity of 1 bits, reversing the get of bits, and compressing and expanding bits. Objectives of the API included currently being obvious and concise, platform-agnostic, owning trusted runtime and compilation efficiency on x64 and AArch64 architectures, and enabling “sleek” degradation, for cases in which a vector computation are not able to be entirely expressed at runtime as a sequence of vector operations.
  • With the Linux/RISC-V port, Java would acquire help for a components instruction set that is previously supported by a wide array of language toolchains. RISC-V in fact is a family of relevant ISAs. The Linux/RISC-V port would only guidance the RV64GV configuration of RISC-V, a standard objective 64-bit ISA that features vector directions. The developers of Java may perhaps contemplate other RISC-V configurations in the long term.

The port would support the adhering to HotSpot VM choices: the template interpreter, C1 (shopper) JIT compiler, C2 (server) JIT compiler, and all present-day mainline garbage collectors which includes ZGC and Shenandoah. The genuine porting is just about comprehensive the focus of the JDK Enhancement Proposal (JEP) is integration of the port into the JDK mainline repository.

Like JDK 18, JDK 19 is thanks to be a shorter-phrase launch, with only six months of prime-stage, Premier guidance.

The previous release, JDK 17, was a Very long Phrase Assist (LTS) release, with several several years of assistance. It arrived September 14, 2021.

Copyright © 2022 IDG Communications, Inc.


Resource url