This article is supposed to be an up-to-date source of curated information about changes that arrived in Java recently and those that are about to – everything condensed into just a few minutes of reading.
After adopting a new cadence-based release cycle, new Java versions started appearing like crazy, and if you haven’t caught up yet – this is an excellent place to start.
Last update: 4.06.2023
Main Source of Confusion: New Release Cycle
In the past, Java releases were driven by prominent features like Lambda Expressions or Generics. Unfortunately, this approach was quite harmful since numerous improvements could not be released until the main feature was ready.
Now, a Java version appears every six months and all the ready features get released, which speeds up the evolution of Java – which is a great thing on its own but can generate confusion for people that got used to the fact that one would expect a new Java version to be released after years not months of waiting. We’re also more likely to see more Preview, Incubating, and Experimental features.
But not all Java versions are made equal – only one release every three years can be considered LTS (Long Term Support), with the last LTS being Java 17.
Java 9 was the last feature-oriented Java release ever and featured an impressive number of 81 JEPs.
The most important addition was JPMS (also known as Project Jigsaw), but besides that, we got:
- VarHandles – public sun.misc.Unsafe replacements
- JShell – a dedicated REPL (Read-Eval-Print-Loop)
- G1 as the default garbage collector
- StackWalking API – API providing lazy access to the information in stack traces.
- Convenience Factory Methods for Collections – collections can now be initialized using of() methods
Release date: 21 September 2017
Java 10 was the first one to be released under the new release cycle. Hence it featured only 12 JEPs and various small API additions accumulated within six months after Java 9 was released.
The most notable changes involved an introduction of local-variable-type-inference(var), Garbage Collector interface, G1 improvements (parallel full GC), and application class-data sharing.
Among other stuff, we received new handy Collectors to be used with unmodifiable collections:
Release date: 20 March 2018
Java 11 (LTS)
Java 11 was the first Long-Term-Support release and featured 17 JEPs.
The most notable changes involved the addition of HTTPClient, Flight Recorder, an experimental low-pause garbage collector(ZGC), and an experimental no-op garbage collector(Epsilon). Additionally, Java EE and CORBA modules got removed, and Nashorn deprecated.
We also got a tiny addition to Optional API: isEmpty(), which is the opposite of isPresent().
And a few interesting methods in String API:
Release date: 25 September 2018
Another relatively small release featuring only 8 JEPs.
Language-wise Switch Expressions were introduced as a preview feature, we got two G1 improvements(1, 2), and a new experimental low-pause garbage collector – Shenandoah.
Release date: 19 March 2019
The smallest release to date, bringing only 5 JEPs.
Switch Expressions were refined, Text Blocks got introduced as a preview feature, and Socket API reimplemented. Additionally, we got Linux/AArch64 support for ZGC.
Release date: 17 September 2019
Java 14 had quite a few interesting additions:
- Pattern Matching for instanceof (preview)
- JFR Event Streaming
- Records (preview)
- Helpful NullPointerExceptions with extra hints about what caused it
- Switch Expressions get promoted to standard
- and CMS garbage collector permanently removed
Release date: 17 March 2020
Java 15 is already out and has brought a few interesting additions:
- Nashorn and biased locking removed
- Text Blocks, ZGC and Shenandoah GC promoted to standard features
- Sealed(Preview) and Hidden classes added
- DatagramSocket API reimplemented
As well as second previews of:
And the second incubator release of Foreign Memory Access API!
Release date: 17 September 2020
Java 16 brought some cool additions:
- Records were promoted to GA
- jpackage was promoted to GA
- Unix Domain Socket Channels support
- Elastic metaspace (to minimize metaspace waste)
- ZGC improvements (Concurrent Thread-Stack Processing)
- Vector API (incubator)
Other than this, OpenJDK development took a huge leap of faith… and migrated to Git and Github. Which makes the whole project much more accessible.
Other than this, we’ll see newer C++ constructs in JVM’s code and Java internals are now encapsulated by default.
Release date: 16 March 2021
Java 17 is another LTS release. This means you can safely migrate from Java 11 and not worry about the next migration for a couple of years (at least if you choose to take the blue pill).
The most notable features involve:
- Sealed Classes becoming production-ready
- Introduction of switch-case pattern matching (preview only!)
Other than that, we can anticipate enhanced pseudo-random numbers generators, deprecation of the Applet API, and… a controversial decision to remove experimental support for AOT and Graal(don’t mix with GraalVM) JIT compiler and deprecate the Security Manager for removal.
There’s also quite interesting last-minute change:
JDK 17 is now feature complete.
One of the last minute enhancements was a new JFR event (jdk.SystemGC). If you have lurking System.gc() calls in your Java code, you can now see the stack trace in JDK Mission Control. @ID_AA_Carmack
— Erik Gahlin (@ErikGahlin) June 10, 2021
Release date: 14 September 2021
Java 18’s feature set is frozen. Let’s have a look at the most notable additions:
- UTF-8 will be recognized as the default charset (a small thing, but it will unify behaviour across implementations, locales, and operating systems)
- Vector API is getting another revision
- Some Reflection APIs will be reimplemented with MethodHandles
- Deprecate Finalization for Removal for removal
- SPI for java.net.InetAddress’s resolvers
Surprisingly… we’ll even be getting a simple web server!
Release date: 22 March 2022
Java 19 was full of exciting new features. Unfortunately, all of them were introduced in preview mode, but it’s still a huge step forward.
Let’s have a look at the most notable additions:
- Foreign Function & Memory API
- Project Loom
- Vector API
- Pattern Matching for switch
- Structured Concurrency
Release date: 20 September 2022
It seems like Java 20 will be another release full of experimental and preview features. Most of those will be revised JEPs from Java 19, but there’s one totally new feature:
- Record Patterns (Second Preview)
- Pattern Matching for switch (Fourth Preview)
- Foreign Function & Memory API (Second Preview)
- Virtual Threads (Second Preview)
- Structured Concurrency (Second Incubator)
- Vector API (Fifth Incubator)
Let’s have a look at the most notable additions:
Release date: 21 March 2023
Java 21 might be a pretty exciting release full of hot features. Let’s have a look:
- Virtual Threads going GA!
- Record Patterns and Pattern Matching for switch
- Key Encapsulation Mechanism API
- Sequenced Collections
- Generational ZGC
And a couple of interesting previews:
- Scoped Values
- Structured Concurrency
- String Templates (Preview)
- Foreign Function & Memory API (Third Preview)
- Unnamed Patterns and Variables (Preview)
- Unnamed Classes and Instance Main Methods (Preview)
- Vector API (Sixth Incubator)
Release date: 20 September 2023