JDK 19: The new features in Java 19

JDK 19: The new features in Java 19

Java Growth Kit 19, a non-LTS (prolonged-expression support) release of standard Java, comes nowadays as a production release.

7 functions focus on the release which include structured concurrency, record designs, a preview of a international functionality and memory API, and aid for the open up resource Linux/RISC-V instruction established architecture (ISA). All functions but the Linux/RISC-V capability are possibly in preview or incubator phases.

JDK 19 follows the March 22 arrival of JDK 18. Conventional Java has been on a 6-thirty day period launch cadence for five decades, with JDK 19 getting the tenth 6-thirty day period launch.

JDK 19 is offered at oracle.com. The creation launch follows two launch candidates and two rampdown phases, courting back to June. The JDK 19 features contain:

  • Structured concurrency, in an incubator period, is meant to simplify multithreaded programming by way of a structured concurrency API. This concurrency treats a number of duties jogging in distinct threads as a solitary device of function, to streamline mistake managing and cancellation. Dependability and observability are improved. This aspect is from Job Loom, which launched a new light-weight concurrency model.
  • A preview of report patterns, to deconstruct file values. History styles and form styles can be nested to allow a declarative, strong, and composable type of knowledge navigation and processing. Plans of the proposal contain extending sample matching to express extra innovative, composable knowledge queries whilst not changing the syntax or semantics of variety designs. This proposal builds on pattern matching for instanceof, shipped in JDK 16  in March 2021. Potential designs might phone for history patterns to be extended with capabilities these kinds of as array patterns and vararg styles. Record designs is aspect of Project Amber, an effort to explore and incubate smaller, productiveness-oriented Java attributes.
  • A preview of a foreign purpose and memory API, which would introduce an API by which Java programs can interoperate with code and information exterior the Java runtime. By competently invoking international capabilities (i.e., code outside the house the JVM) and safely accessing foreign memory (i.e., memory not managed by the JVM) the API allows Java plans to call native libraries and method native details devoid of the threat and brittleness of the Java Indigenous Interface (JNI). The overseas purpose and memory API brings together two previously incubating APIs: the overseas memory obtain API and the foreign linker API. The overseas function and memory API was formerly incubated in JDK 17 and reincubated in JDK 18. The proposal’s goals incorporate simplicity of use, efficiency, generality, and security.
  • A preview of digital threads, which are light-weight threads that substantially lower the exertion of creating, retaining, and observing higher-throughput, concurrent applications. Ambitions include enabling server purposes composed in the uncomplicated thread-for every-ask for style to scale with around-best components utilization, enabling existing code that works by using the java.lang Thread API to adopt virtual threads with negligible improve, and enable troubleshooting, debugging, and profiling of digital threads with current JDK instruments. It is not a aim of this proposal to change the essential concurrency product in Java or present a new information parallelism construct in both the Java language or Java libraries. Nor is it a goal to get rid of the regular implementation of threads or to silently migrate current purposes to use digital threads. This aspect is also portion of Venture Loom.
  • A 3rd preview of sample matching for switch expressions and statements, extending pattern matching to swap, to allow an expression to be examined versus a variety of patterns, each and every with a certain action, so advanced info-oriented queries can be expressed concisely and safely and securely. This capacity beforehand was previewed in JDK 17 and JDK 18. The third preview would insert refinements which include the alternative of guarded styles with when clauses in switch blocks. Also, the runtime semantics of a pattern change when the worth of the selector expression is null are far more carefully aligned with legacy swap semantics. The plan’s aims include expanding the expressiveness and applicability of swap expressions and statements by allowing designs to surface in situation labels. Other ambitions include allowing builders to rest the historic null-hostility of swap when ideal, rising the basic safety of swap statements and making sure that current change expressions and statements continue on to compile with no alterations and execute with similar semantics. The hope is to finally assistance sample matching during Java, introducing it to destinations wherever expressions are utilised. This feature also is component of the Amber job.
  • A fourth incubation of a vector API that would express vector computations that reliably compile at runtime to best vector guidance on supported CPU architectures, as a result reaching performance exceptional to equivalent scalar computations. Builders using the API gain a way to create complicated vector algorithms in Java, utilizing the HotSpot auto-vectorizer but with a user design that will make vectorizations more predictable and sturdy. The vector API previously was incubated into JDK 16, JDK 17, and JDK 19.
    Advancements to the API proposed for JDK 19 include enhancements to load and store vectors to and from MemorySegments, as defined by the Foreign Operate and Memory API preview. JDK 19 would also increase two cross-lane vector functions, compress and grow, together with a complementary vector mask compress operation. The compress vector procedure maps lanes of a supply vector, picked by a mask, to a vacation spot vector in lane purchase, while the increase procedure does the inverse. The compress procedure is useful in filtering query results.
    In another addition to the vector API, bitwise integral lanewise operations would be expanded, including operations these counting the number of a person bits, reversing the purchase of bits, and compressing and growing bits. Plans of the API involved staying distinct and concise, platform-agnostic, obtaining responsible runtime and compilation performance on x64 and AArch64 architectures, and enabling “graceful” degradation, for situations in which a vector computation simply cannot be thoroughly expressed at runtime as a sequence of vector operations. The vector API is from Task Panama, which aims to allow less difficult communications amongst indigenous and JVM code.
  • With the Linux/RISC-V port, Java would gain assistance for a components instruction set that is previously supported by a vast array of language toolchains. RISC-V really is a relatives of linked ISAs. The Linux/RISC-V port would only support the RV64GV configuration of RISC-V, a typical reason 64-bit ISA that features vector guidelines. The developers of Java may perhaps take into consideration other RISC-V configurations in the potential.

The port would help the adhering to HotSpot VM possibilities: the template interpreter, C1 (shopper) JIT compiler, C2 (server) JIT compiler, and all existing mainline garbage collectors like ZGC and Shenandoah. The real porting is just about entire the concentrate 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 small-time period release, with only 6 months of best-level, Premier assistance.

The previous release, JDK 17, was a Extensive Time period Guidance (LTS) release, with many a long time of support. It arrived September 14, 2021. The next LTS launch, JDK 21, is because of a single yr from now, preceded by JDK 20, presumably in March 2023.

Copyright © 2022 IDG Communications, Inc.