Monthly Archives: March 2023

Java 20 – What’s included, and is it worth adopting?

Java 20 was announced as production-ready (GA) this week. 

Coming after Java 19 in Sept last year, Java 20 is the next release of Java produced in accordance with the six-monthly time-based release schedule that Oracle have been reliably producing since Sept 2017.

Java 20 contains a total of 7 JDK Enhancement Proposals (JEPs) (enhancements to the language, Java APIs or platform). None of these JEPs are final – i.e. there are no stable new features in the release you can rely upon. 4 of the 7 JEPs are in secondary phases of preview – they’re complete and production ready, but the API has not yet been finalised, subject to receiving further feedback. The remaining 3 JEPs are in an earlier incubation state – they may not yet be fully complete. One of which is brand new.

All of the JEPs are associated with features being developed under the following three ongoing long-term, umbrella OpenJDK development projects

  • Project Amber
  • Project Loom
  • Project Panama

Project Amber Related JEPs

Project Amber aims to provide (relatively) small Java language features to boost developer productivity. The Amber associated JEPs in Java 20 include –

Project Loom Related JEPs

Project Loom aims to provide features to make it easier to write, maintain and debug non-blocking multi-threaded Java apps to maximise throughput and scalability. The Loom associated JEPs in Java 20 include –

  • 429: Scoped Values (Incubator) – A newly proposed feature being produced by the Loom team, which aims to address the drawbacks of thread-local variables, particularly those which are more acute when using a much larger number of virtual threads. 
  • 436: Virtual Threads (Second Preview) – This main feature produced by the OpenJDK Loom project has moved a step further towards being made final. For an overview of Virtual Threads, their goal, and how it might impact how you write Java applications in the future see my blog post Preparing for Virtual Threads.
  • 437: Structured Concurrency (Second Incubator) – A further feature being produced by the Loom team, which aims to simplify multithreaded programming by providing a new API which supports treating multiple (asynchronously executed) tasks running in different threads as a single unit of work, with the goals of streamlining error handling and cancellation, improving reliability, and enhancing observability.

Project Panama Related JEPs

Project Panama aims to improve the support the JDK provides for writing Java apps that need to interoperate with “foreign” (i.e., non-Java) code/APIs – commonly invoking functions in C libraries. The Panama associated JEPs in Java 20 include –

Closing Thoughts

Given there are no finalised features in Java 20, and the next release (Java 21) is planned to be an LTS release, it’s reasonable to question why you would commit to upgrading your production apps to this new release, rather than waiting for 6 months. However, like other major releases, Java 20 does include some other minor enhancements (which I’ve still yet to explore), bug fixes and performance improvements, which might be reason enough.

Alternatively, you and your team may just want to take Java 20 for a test drive to try out (and possibly provide feedback on) one of the above JEPs. Or perhaps more importantly as a means of preparing and expediting your adoption of Java 21.

Neil.