2

Java 19 Delivers Features for Projects Loom, Panama and Amber

 1 year ago
source link: https://www.infoq.com/news/2022/09/java19-released/?itm_source=infoq&itm_medium=popular_widget&itm_campaign=popular_content_list&itm_content=
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Java 19 Delivers Features for Projects Loom, Panama and Amber

Sep 20, 2022 4 min read

Oracle has released version 19 of the Java programming language and virtual machine. The seven JEPs in this final feature set include:

The feature cadence for Java 19 is similar to that of the nine new features in JDK 18, but lower than the: 14 features in JDK 17; 17 features in JDK16; 14 features in JDK 15; and 16 features in JDK 14.

This release features JEPs that provide continued contribution toward Project Amber, Project Loom and Project Panama along with a new feature that ports the JDK to the Linux/RISC-V instruction set. We examine a few of these new features here. It is worth noting that there were no JEPs representing Project Valhalla in JDK 19.

Project Panama

JEP 424 and JEP 426 fall under the auspices of Project Panama, a project designed to improve and enrich interoperability between the JVM and well-defined "foreign," i.e., non-Java, APIs that will most-likely include interfaces commonly used within C libraries.

JEP 424, Foreign Function & Memory API (Preview), introduces an API for Java applications to interoperate with code and data outside of the Java runtime by efficiently invoking foreign functions and by safely accessing foreign memory that is not managed by the JVM. This JEP evolves: JEP 419, Foreign Function & Memory API (Second Incubator), delivered in JDK 18; and JEP 412, Foreign Function & Memory API (Incubator), delivered in JDK 17; to incorporate improvements based on Java community feedback.

JEP 426, Vector API (Fourth Incubator), incorporates enhancements in response to feedback from the previous three rounds of incubation: JEP 417, Vector API (Third Incubator) (delivered in JDK 18), JEP 414, Vector API (Second Incubator) (delivered in JDK 17), and JEP 338, Vector API (Incubator), delivered as an incubator module in JDK 16. JEP 426 proposes to enhance the Vector API to load and store vectors to and from a MemorySegment as defined by JEP 424, Foreign Function & Memory API (Preview).

A working application on how to implement the Foreign Function & Memory API may be found in this GitHub repository by Carl Dea, senior developer advocate at Azul.

Project Loom

JEP 425 and JEP 428 fall under the auspices of Project Loom, a project designed to explore, incubate and deliver Java VM features and APIs built for the purpose of supporting easy-to-use, high-throughput lightweight concurrency and new programming models. This would be accomplished via virtual threads, delimited continuations and tail calls.

JEP 425, Virtual Threads (Preview), introduces virtual threads, lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications, to the Java platform.

JEP 428, Structured Concurrency (Incubator), proposes to simplify multithreaded programming by introducing a library to treat multiple tasks running in different threads as a single unit of work. This can streamline error handling and cancellation, improve reliability, and enhance observability.

Working applications on how to implement the Virtual Threads and Structured Concurrency APIs may be found in: this GitHub repository by Nicolai Parlog, Java developer advocate at Oracle; and this GitHub repository by Bazlur Rahman, Senior Software Engineer at Contrast Security.

Project Amber

JEP 405 and JEP 427 fall under the auspices of Project Amber, a project designed to explore and incubate smaller Java language features to improve productivity.

JEP 405, Record Patterns (Preview), proposes to enhance the language with record patterns to deconstruct record values. Record patterns may be used in conjunction with type patterns to "enable a powerful, declarative, and composable form of data navigation and processing." Type patterns were recently extended for use in switch case labels via JEP 406, Pattern Matching for switch (Preview) (delivered in JDK 17), and JEP 420, Pattern Matching for switch (Second Preview) (delivered in JDK 18).

JEP 427, Pattern Matching for switch (Third Preview), incorporates enhancements in response to feedback from the previous two rounds of preview: JEP 406, Pattern Matching for switch (Preview) (delivered in JDK 17), and JEP 420, Pattern Matching for switch (Second Preview) (delivered in JDK 18). Changes from JEP 420 include: guarded patterns are replaced with when clauses in switch blocks; and runtime semantics of a pattern switch are more closely aligned with legacy switch semantics when the value of the selector expression is null.

A working application on how to implement the Record Patterns and Pattern Matching for switch APIs may be found in this GitHub repository, java-19 folder, by Wesley Egberto, Java technical lead at Global Points.

JDK 20

No JEPs have been Targeted or Integrated for inclusion in JDK 20 at this time. However, based on recently submitted JEP drafts and JEP candidates, we have surmised which JEPs have the potential to be included in JDK 20 in this more detailed news story.

The formal release date for JDK 20 has not yet been announced, but it is expected to be delivered in mid-March 2023 as per the six-month release cadence. Developers can anticipate a feature freeze in mid-December 2022.

JDK 19 may now be downloaded from Oracle with binaries from other vendors expected to become available in the coming days.

About the Author

Michael Redlich

Michael Redlich is a Senior Research Technician at ExxonMobil Research & Engineering in Clinton, New Jersey (views and opinions provided here are his own and not those of his employer).

He is an IT Professional with a BS in Computer Science from Rutgers University. He has facilitated the Garden State Java User Group (formerly ACGNJ Java Users Group) since 2001, an experienced conference speaker, and co-authored several articles with Barry Burd before joining InfoQ.

As a long-time employee of heritage Exxon and ExxonMobil since December 1989, Mike has enjoyed numerous assignments with the Company including automotive testing, analytical sciences practicing infrared spectroscopy and chemometrics, developing scientific IT applications, and, in his current assignment, polymer science practicing rheology and polymer physics.

Throughout his career, Mike has developed leadership skills which he utilized having previously served as President of the Amateur Computer Group of New Jersey, a non-profit 501(c)(3) computer education organization, and currently as Director of the Garden State Java User Group, also a non-profit 501(c)(3) organization.

Mike is a member of Toastmasters International and has recently achieved his Advanced Communicator Silver certificate.

He is also an avid runner/cyclist having completed numerous marathons.

Mike resides in Flemington, New Jersey with his wife, Rowena, where they spend quality time cycling/running and traveling primarily to New Orleans, LA and Newport, RI.

Show more

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK