JDK 19: The new features in Java 19

ByJosephine J. Romero

Jun 11, 2022 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
JDK 19: The new features in Java 19


Java Progress Package 19, owing this September, is now function-total, obtaining just attained an first rampdown stage. Seven functions concentrate on the release which include structured concurrency, report designs, a preview of a international function and memory API, and support for the open supply Linux/RISC-V instruction set architecture (ISA).

With this most up-to-date milestone in the launch process for normal Java, other prepared abilities these as universal generics and price objects will have to wait for a afterwards model of the platform. JDK 19 follows the March 22 arrival of JDK 18. Common Java is on a 6-thirty day period launch cadence.

JDK 19 is slated to be officially released for production use on September 20, preceded by a next rampdown phase beginning July 21, and launch candidates to be revealed August 11 and August 25. Early entry builds of JDK 19 can be accessed from jdk.java.internet/19. The JDK 19 capabilities include:

  • Structured concurrency, in an incubator section, is meant to simplify multithreaded programming by a structured concurrency library. This concurrency treats numerous responsibilities managing in various threads as a one device of function, to streamline mistake dealing with and cancellation. Reliability and observability are improved.
  • A preview of record patterns, to deconstruct document values. Record styles and style designs can be nested to permit a declarative, highly effective, and composable kind of facts navigation and processing. Plans of the proposal involve extending pattern matching to specific a lot more innovative, composable knowledge queries although not switching the syntax or semantics of type styles. This proposal builds on pattern matching for instanceof, shipped in JDK 16  in March 2021. Upcoming ideas could simply call for report patterns to be prolonged with capabilities these kinds of as array patterns and vararg designs. Report patterns is section of Undertaking Amber, an exertion to check out and incubate scaled-down, productiveness-oriented Java characteristics.
  • A preview of a overseas purpose and memory API, which would introduce an API by which Java courses can interoperate with code and data exterior the Java runtime. By efficiently invoking foreign functions (i.e., code outside the house the Java runtime) and securely accessing overseas memory (i.e., memory not managed by the JVM) the API enables Java programs to simply call native libraries and procedure indigenous knowledge without having the danger and brittleness of the Java Indigenous Interface (JNI). The foreign operate and memory API combines two earlier incubating APIs: the overseas memory accessibility API and the foreign linker API. The overseas perform and memory API was formerly incubated in JDK 17 and reincubated in JDK 18. The proposal’s plans consist of simplicity of use, functionality, generality, and protection.
  • A preview of digital threads, which are lightweight threads that radically reduce the exertion of writing, keeping, and observing superior-throughput, concurrent purposes. Objectives involve enabling server programs published in the very simple thread-for every-request model to scale with around-optimum hardware utilization, enabling existing code that makes use of the java.lang Thread API to undertake digital threads with negligible transform, and empower troubleshooting, debugging, and profiling of digital threads with present JDK applications. It is not a target of this proposal to improve the primary concurrency product in Java or provide a new facts parallelism construct in both the Java language or Java libraries. Nor is it a target to take out the common implementation of threads or to silently migrate present purposes to use virtual threads.
  • A third preview of sample matching for change expressions and statements, extending sample matching to switch, to make it possible for an expression to be analyzed against a quantity of designs, every with a specific motion, so intricate info-oriented queries can be expressed concisely and securely. This capability previously was previewed in JDK 17 and JDK 18. The 3rd preview would incorporate refinements such as the substitution of guarded designs with when clauses in swap blocks. Also, the runtime semantics of a sample switch when the worth of the selector expression is null are additional intently aligned with legacy switch semantics. The plan’s plans include things like growing the expressiveness and applicability of change expressions and statements by enabling designs to show up in case labels. Other goals consist of letting builders to unwind the historic null-hostility of change when preferred, expanding the security of change statements and guaranteeing that current swap expressions and statements keep on to compile with no variations and execute with identical semantics.
  • A fourth incubation of a vector API that would specific vector computations that reliably compile at runtime to ideal vector directions on supported CPU architectures, therefore obtaining effectiveness exceptional to equal scalar computations. Builders applying the API acquire a way to write elaborate vector algorithms in Java, employing the HotSpot vehicle-vectorizer but with a person design that would make vectorizations extra predictable and sturdy. The vector API formerly was incubated into JDK 16, JDK 17, and JDK 19.
    Improvements to the API proposed for JDK 19 include things like enhancements to load and shop vectors to and from MemorySegments, as described by the International Operate and Memory API preview. JDK 19 would also add two cross-lane vector functions, compress and develop, collectively with a complementary vector mask compress procedure. The compress vector procedure maps lanes of a supply vector, picked by a mask, to a place vector in lane order, though the develop operation does the inverse. The compress procedure is beneficial in filtering query outcomes.
    In another addition to the vector API, bitwise integral lanewise operations would be expanded, including operations these types of counting the selection of one bits, reversing the buy of bits, and compressing and expanding bits. Aims of the API involved being obvious and concise, platform-agnostic, obtaining dependable runtime and compilation effectiveness on x64 and AArch64 architectures, and enabling “graceful” degradation, for circumstances in which a vector computation cannot be thoroughly expressed at runtime as a sequence of vector functions.
  • With the Linux/RISC-V port, Java would acquire assistance for a components instruction established that is now supported by a large array of language toolchains. RISC-V actually is a spouse and children of relevant ISAs. The Linux/RISC-V port would only support the RV64GV configuration of RISC-V, a general goal 64-bit ISA that features vector directions. The builders of Java may perhaps take into consideration other RISC-V configurations in the long term.

The port would help the next HotSpot VM options: the template interpreter, C1 (customer) JIT compiler, C2 (server) JIT compiler, and all present mainline rubbish collectors including ZGC and Shenandoah. The genuine porting is just about total the concentration of the JDK Improvement Proposal (JEP) is integration of the port into the JDK mainline repository.

Like JDK 18, JDK 19 is because of to be a shorter-phrase launch, with only six months of leading-level, Leading guidance.

The preceding launch, JDK 17, was a Very long Phrase Support (LTS) release, with numerous a long time of guidance. It arrived September 14, 2021.

Copyright © 2022 IDG Communications, Inc.


Resource backlink