JDK 19: The new features in Java 19

Java Development Kit 19, because of this September, is now element-entire, and is now in a next rampdown section. 7 attributes focus on the release which includes structured concurrency, document styles, a preview of a international function and memory API, and assistance for the open up supply Linux/RISC-V instruction established architecture (ISA).

With this most recent milestone in the launch course of action for common Java, other prepared capabilities this sort of as universal generics and price objects will have to hold out for a later on edition of the system. JDK 19 follows the March 22 arrival of JDK 18. Conventional Java is on a 6-month launch cadence.

JDK 19 is slated to be officially introduced for production use on September 20, preceded by launch candidates to be posted August 11 and August 25. An first rampdown phase was achieved last thirty day period. Early obtain builds of JDK 19 can be accessed from jdk.java.web/19. The JDK 19 characteristics include:

  • Structured concurrency, in an incubator period, is supposed to simplify multithreaded programming through a structured concurrency API. This concurrency treats numerous duties managing in distinct threads as a one device of get the job done, to streamline error handling and cancellation. Reliability and observability are improved.
  • A preview of file patterns, to deconstruct history values. Report designs and form styles can be nested to help a declarative, highly effective, and composable variety of data navigation and processing. Plans of the proposal contain extending sample matching to categorical additional complex, composable information queries while not changing the syntax or semantics of style designs. This proposal builds on pattern matching for instanceof, shipped in JDK 16  in March 2021. Potential ideas might phone for history designs to be prolonged with abilities this sort of as array patterns and vararg patterns. Record designs is portion of Undertaking Amber, an effort and hard work to take a look at and incubate smaller sized, productiveness-oriented Java characteristics.
  • A preview of a international operate and memory API, which would introduce an API by which Java programs can interoperate with code and info exterior the Java runtime. By successfully invoking overseas features (i.e., code outside the JVM) and safely and securely accessing international memory (i.e., memory not managed by the JVM) the API allows Java courses to contact native libraries and approach native information without having the threat and brittleness of the Java Indigenous Interface (JNI). The international operate and memory API combines two before incubating APIs: the foreign memory accessibility API and the overseas linker API. The foreign functionality and memory API was previously incubated in JDK 17 and reincubated in JDK 18. The proposal’s goals involve ease of use, efficiency, generality, and basic safety.
  • A preview of virtual threads, which are light-weight threads that considerably lower the effort and hard work of creating, protecting, and observing large-throughput, concurrent apps. Plans consist of enabling server apps penned in the easy thread-for each-request design to scale with near-exceptional hardware utilization, enabling present code that makes use of the java.lang Thread API to adopt virtual threads with nominal improve, and empower troubleshooting, debugging, and profiling of digital threads with current JDK applications. It is not a target of this proposal to transform the simple concurrency product in Java or offer you a new info parallelism construct in possibly the Java language or Java libraries. Nor is it a goal to take out the regular implementation of threads or to silently migrate current apps to use digital threads.
  • A third preview of pattern matching for swap expressions and statements, extending pattern matching to change, to allow for an expression to be tested against a number of styles, just about every with a unique action, so sophisticated facts-oriented queries can be expressed concisely and safely. This capacity beforehand was previewed in JDK 17 and JDK 18. The third preview would increase refinements together with the substitution of guarded styles with when clauses in change blocks. Also, the runtime semantics of a pattern change when the price of the selector expression is null are much more intently aligned with legacy change semantics. The plan’s objectives involve growing the expressiveness and applicability of switch expressions and statements by allowing styles to show up in circumstance labels. Other goals involve letting builders to chill out the historic null-hostility of swap when wanted, escalating the safety of change statements and making certain that current swap expressions and statements continue to compile with no modifications and execute with identical semantics.
  • A fourth incubation of a vector API that would specific vector computations that reliably compile at runtime to optimal vector guidelines on supported CPU architectures, therefore attaining efficiency excellent to equal scalar computations. Developers employing the API gain a way to generate intricate vector algorithms in Java, applying the HotSpot car-vectorizer but with a user model that will make vectorizations a lot 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 enhancements to load and store vectors to and from MemorySegments, as outlined by the International Operate and Memory API preview. JDK 19 would also insert two cross-lane vector functions, compress and extend, collectively with a complementary vector mask compress operation. The compress vector procedure maps lanes of a supply vector, chosen by a mask, to a destination vector in lane get, when the expand procedure does the inverse. The compress procedure is valuable in filtering question final results.
    In an additional addition to the vector API, bitwise integral lanewise functions would be expanded, together with functions these counting the variety of just one bits, reversing the purchase of bits, and compressing and expanding bits. Ambitions of the API involved being very clear and concise, platform-agnostic, acquiring reliable runtime and compilation efficiency on x64 and AArch64 architectures, and enabling “graceful” degradation, for circumstances in which a vector computation simply cannot be totally expressed at runtime as a sequence of vector operations.
  • With the Linux/RISC-V port, Java would attain assistance for a hardware instruction established that is already supported by a large assortment of language toolchains. RISC-V truly is a household of relevant ISAs. The Linux/RISC-V port would only help the RV64GV configuration of RISC-V, a normal reason 64-little bit ISA that includes vector instructions. The builders of Java might take into consideration other RISC-V configurations in the long run.

The port would guidance the subsequent HotSpot VM solutions: the template interpreter, C1 (client) JIT compiler, C2 (server) JIT compiler, and all present-day mainline garbage collectors which include ZGC and Shenandoah. The genuine porting is virtually full the concentrate of the JDK Improvement Proposal (JEP) is integration of the port into the JDK mainline repository.

Like JDK 18, JDK 19 is thanks to be a limited-term launch, with only six months of best-amount, Premier support.

The preceding release, JDK 17, was a Lengthy Phrase Support (LTS) release, with quite a few years of assistance. It arrived September 14, 2021.

Copyright © 2022 IDG Communications, Inc.

Supply backlink