JDK 19: The new features in Java 19

JDK 19: The new features in Java 19


Java Improvement Kit 19, due this September, has just had a seventh attribute proposed for it: structured concurrency, to simplify multithreaded programming. Structured concurrency joins 6 previous attributes like document designs, a preview of a foreign operate and memory API, and help for the open resource Linux/RISC-V instruction established architecture (ISA).

JDK 19, or simply just Java 19, possibly could host a extensive variety of options, ranging from common generics to worth objects, according to plans underway for improving Java. JDK 19 would follow JDK 18, which arrived March 22. Regular Java is on a six-thirty day period release cadence.

OpenJDK’s developers have released an official release routine for JDK 19, which has it arriving September 20 as a creation launch, preceded by rampdown phases June 9 and July 21, and launch candidates to be posted August 11 and August 25.

Early entry builds of JDK 19 can be accessed from jdk.java.net/19. Proposed JDK 19 functions incorporate:

  • Structured concurrency, in an incubator section, is supposed to simplify multithreaded programming by way of a structured concurrency library. This concurrency treats multiple duties working in various threads as a solitary device of function, to streamline error handling and cancellation. Reliability and observability are improved.
  • A preview of record designs, to deconstruct record values. Document patterns and variety designs can be nested to permit a declarative, strong, and composable form of info navigation and processing. Goals of the proposal contain extending sample matching to categorical far more complex, composable data queries though not switching the syntax or semantics of sort styles. This proposal builds on pattern matching for instanceof, sent in JDK 16  in March 2021. Foreseeable future ideas may connect with for report patterns to be extended with capabilities these types of as array designs and vararg designs. Report patterns is portion of Job Amber, an effort and hard work to investigate and incubate more compact, efficiency-oriented Java options.
  • A preview of a foreign function and memory API, which would introduce an API by which Java systems can interoperate with code and information exterior the Java runtime. By effectively invoking overseas features (i.e., code exterior the Java runtime) and properly accessing international memory (i.e., memory not managed by the JVM) the API permits Java courses to connect with indigenous libraries and approach native information without the hazard and brittleness of the Java Indigenous Interface (JNI). The overseas purpose and memory API brings together two earlier incubating APIs: the overseas memory access API and the overseas linker API. The foreign function and memory API was formerly incubated in JDK 17 and reincubated in JDK 18. The proposal’s ambitions involve relieve of use, effectiveness, generality, and safety.
  • A preview of digital threads, which are light-weight threads that significantly reduce the exertion of writing, retaining, and observing large-throughput, concurrent purposes. Goals include enabling server programs composed in the very simple thread-for every-ask for model to scale with close to-exceptional components utilization, enabling current code that makes use of the java.lang Thread API to undertake virtual threads with minimum change, and permit troubleshooting, debugging, and profiling of digital threads with existing JDK tools. It is not a intention of this proposal to improve the primary concurrency design in Java or present a new data parallelism build in possibly the Java language or Java libraries. Nor is it a goal to take out the conventional implementation of threads or to silently migrate current apps to use digital threads.
  • A 3rd preview of pattern matching for switch expressions and statements, extending pattern matching to switch, to make it possible for an expression to be analyzed versus a quantity of patterns, each and every with a particular motion, so elaborate information-oriented queries can be expressed concisely and properly. This functionality earlier was previewed in JDK 17 and JDK 18. The third preview would include refinements which include the replacement of guarded styles with when clauses in switch blocks. Also, the runtime semantics of a sample switch when the value of the selector expression is null are a lot more intently aligned with legacy switch semantics. The plan’s ambitions contain expanding the expressiveness and applicability of change expressions and statements by enabling patterns to look in scenario labels. Other targets include allowing for builders to loosen up the historic null-hostility of change when wished-for, increasing the security of change statements and making certain that current swap expressions and statements continue on to compile with no adjustments and execute with similar semantics.
  • A fourth incubation of a vector API that would convey vector computations that reliably compile at runtime to optimal vector guidance on supported CPU architectures, consequently obtaining performance top-quality to equal scalar computations. Developers working with the API get a way to produce complex vector algorithms in Java, using the HotSpot auto-vectorizer but with a user model that would make vectorizations far more predictable and robust. The vector API earlier was incubated into JDK 16, JDK 17, and JDK 19.
    Enhancements to the API proposed for JDK 19 contain enhancements to load and retail store vectors to and from MemorySegments, as described by the International Purpose and Memory API preview. JDK 19 would also include two cross-lane vector operations, compress and extend, with each other with a complementary vector mask compress procedure. The compress vector operation maps lanes of a supply vector, selected by a mask, to a place vector in lane purchase, although the develop procedure does the inverse. The compress procedure is practical in filtering question success.
    In a further addition to the vector API, bitwise integral lanewise functions would be expanded, such as functions such counting the selection of a single bits, reversing the purchase of bits, and compressing and expanding bits. Aims of the API provided remaining distinct and concise, system-agnostic, owning trusted runtime and compilation functionality on x64 and AArch64 architectures, and enabling “graceful” degradation, for circumstances in which a vector computation can not be entirely expressed at runtime as a sequence of vector functions.
  • With the Linux/RISC-V port, Java would get support for a components instruction established that is previously supported by a huge assortment of language toolchains. RISC-V truly is a household of connected ISAs. The Linux/RISC-V port would only aid the RV64GV configuration of RISC-V, a basic reason 64-little bit ISA that involves vector instructions. The developers of Java could look at other RISC-V configurations in the potential.

The port would help the next HotSpot VM options: the template interpreter, C1 (client) JIT compiler, C2 (server) JIT compiler, and all recent mainline garbage collectors such as ZGC and Shenandoah. The true porting is nearly complete the focus of the JDK Enhancement Proposal (JEP) is integration of the port into the JDK mainline repository.

Like JDK 18, JDK 19 is owing to be a small-phrase release, with only 6 months of best-stage, Premier assist.

The preceding release, JDK 17, was a Extended Time period Assistance (LTS) release, with many many years of aid. It arrived September 14, 2021.

Copyright © 2022 IDG Communications, Inc.


Source link