JDK 19: The new features in Java 19

[ad_1]

Java Growth Kit 19, due this September, is now attribute-total, obtaining just attained an initial rampdown section. Seven options goal the launch such as structured concurrency, record designs, a preview of a international perform and memory API, and aid for the open source Linux/RISC-V instruction set architecture (ISA).

With this newest milestone in the launch method for standard Java, other planned abilities these as common generics and worth objects will have to hold out for a later variation of the platform. JDK 19 follows the March 22 arrival of JDK 18. Normal Java is on a six-thirty day period launch cadence.

JDK 19 is slated to be officially produced for production use on September 20, preceded by a 2nd rampdown period starting July 21, and release candidates to be revealed August 11 and August 25. Early accessibility builds of JDK 19 can be accessed from jdk.java.net/19. The JDK 19 functions involve:

  • Structured concurrency, in an incubator stage, is supposed to simplify multithreaded programming via a structured concurrency library. This concurrency treats a number of responsibilities working in distinct threads as a solitary unit of perform, to streamline error managing and cancellation. Trustworthiness and observability are enhanced.
  • A preview of record styles, to deconstruct file values. History designs and style patterns can be nested to allow a declarative, impressive, and composable kind of data navigation and processing. Objectives of the proposal contain extending sample matching to express additional innovative, composable information queries although not switching the syntax or semantics of variety patterns. This proposal builds on pattern matching for instanceof, delivered in JDK 16  in March 2021. Long run ideas may well phone for file patterns to be extended with capabilities these as array styles and vararg designs. File designs is section of Task Amber, an energy to check out and incubate smaller, productivity-oriented Java options.
  • A preview of a international purpose and memory API, which would introduce an API by which Java plans can interoperate with code and knowledge outside the house the Java runtime. By effectively invoking foreign features (i.e., code outside the Java runtime) and securely accessing international memory (i.e., memory not managed by the JVM) the API allows Java programs to connect with indigenous libraries and method native knowledge without the need of the risk and brittleness of the Java Indigenous Interface (JNI). The international function and memory API combines two before incubating APIs: the international memory obtain API and the overseas linker API. The international purpose and memory API was beforehand incubated in JDK 17 and reincubated in JDK 18. The proposal’s targets incorporate ease of use, efficiency, generality, and basic safety.
  • A preview of digital threads, which are lightweight threads that significantly minimize the work of creating, protecting, and observing significant-throughput, concurrent purposes. Plans incorporate enabling server programs written in the straightforward thread-for every-request design and style to scale with close to-exceptional hardware utilization, enabling present code that employs the java.lang Thread API to undertake virtual threads with minimal change, and allow troubleshooting, debugging, and profiling of virtual threads with existing JDK equipment. It is not a goal of this proposal to modify the essential concurrency product in Java or offer a new info parallelism assemble in both the Java language or Java libraries. Nor is it a goal to eliminate the traditional implementation of threads or to silently migrate existing programs to use digital threads.
  • A third preview of sample matching for swap expressions and statements, extending sample matching to switch, to allow an expression to be examined against a amount of designs, each with a certain action, so intricate details-oriented queries can be expressed concisely and securely. This ability earlier was previewed in JDK 17 and JDK 18. The third preview would increase refinements such as the alternative of guarded styles with when clauses in swap blocks. Also, the runtime semantics of a pattern switch when the value of the selector expression is null are more carefully aligned with legacy change semantics. The plan’s objectives include expanding the expressiveness and applicability of switch expressions and statements by enabling patterns to appear in case labels. Other plans include enabling builders to loosen up the historic null-hostility of change when sought after, expanding the security of switch statements and ensuring that present switch expressions and statements carry on to compile with no modifications and execute with equivalent semantics.
  • A fourth incubation of a vector API that would express vector computations that reliably compile at runtime to exceptional vector guidelines on supported CPU architectures, consequently obtaining effectiveness remarkable to equivalent scalar computations. Developers utilizing the API gain a way to write elaborate vector algorithms in Java, employing the HotSpot automobile-vectorizer but with a person model that can make vectorizations additional predictable and robust. 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 retailer vectors to and from MemorySegments, as described by the International Function and Memory API preview. JDK 19 would also increase two cross-lane vector functions, compress and expand, alongside one another with a complementary vector mask compress operation. The compress vector operation maps lanes of a source vector, picked by a mask, to a vacation spot vector in lane buy, whilst the grow procedure does the inverse. The compress operation is valuable in filtering query outcomes.
    In a different addition to the vector API, bitwise integral lanewise operations would be expanded, together with functions these types of counting the number of one particular bits, reversing the get of bits, and compressing and increasing bits. Plans of the API included becoming obvious and concise, system-agnostic, having dependable runtime and compilation efficiency on x64 and AArch64 architectures, and enabling “sleek” degradation, for conditions in which a vector computation are unable to be fully expressed at runtime as a sequence of vector functions.
  • With the Linux/RISC-V port, Java would attain assistance for a components instruction established that is already supported by a wide assortment of language toolchains. RISC-V actually is a loved ones of related ISAs. The Linux/RISC-V port would only assistance the RV64GV configuration of RISC-V, a typical goal 64-little bit ISA that includes vector directions. The builders of Java may perhaps think about other RISC-V configurations in the upcoming.

The port would aid the adhering to HotSpot VM solutions: the template interpreter, C1 (shopper) JIT compiler, C2 (server) JIT compiler, and all existing mainline rubbish collectors including ZGC and Shenandoah. The true porting is nearly entire the emphasis of the JDK Enhancement Proposal (JEP) is integration of the port into the JDK mainline repository.

Like JDK 18, JDK 19 is because of to be a small-term launch, with only six months of prime-level, Leading assist.

The previous release, JDK 17, was a Extensive Expression Assistance (LTS) release, with numerous decades of guidance. It arrived September 14, 2021.

Copyright © 2022 IDG Communications, Inc.

[ad_2]

Supply link