New features between Java 8 and Java 17

Java Duke surfing

Since version 9, Java has new features every 6 months and it’s very hard to keep track of these new changes. Most of the information on the internet describes changes between the last 2 Java versions. However, if you’re in a similar situation as me, you’re not using the last Java version but a version several releases older.

Then it’s useful to know which new features were added since the version you use now, or between the versions that you use now and the one you want to start using next. Therefore I’ve compiled a table with all new features added since Java 8 for each new Java version.

Note that I didn’t include all the new features and API additions, only those that are useful for most developers, to keep the list brief.

Below you can find tables for:

New Java language features since Java 8

FeatureSincePreview since
Context-Specific Deserialization Filters – allow applications to configure deserialization filters, either specify a pattern via a system property, or a filter factory via a system property or via ObjectInputFilter.Config17
Pattern Matching for switch
switch (o) {
case null -> System.out.println("null");
case String s -> System.out.println("String");
case Point p -> System.out.println(p.toString());
case int[] ia -> System.out.println("Array length" + ia.length);
default -> System.out.println("Something else");
}
17
Vector API – express computations that compile to optimal hardware instructions16
Sealed classes (inheritance only for allowed classes):
public abstract sealed class Shape permits Circle, Rectangle, Square {...}
1715
Record type – data classes with implicit getters, constructor, equals, hashCode and toString methods:
record Point(int x, int y) { }
1614
Pattern Matching for instanceof:
if (x instanceOf String s) { String a = s; }
1614
Text blocks:
String query = """
SELECT "EMP_ID", "LAST_NAME"
FROM "EMPLOYEE_TB";
"""
1513
Switch expressions:
boolean isWeekend = switch (day) {
case SATURDAY, SUNDAY -> true;
default -> false;
};
1412
New String methods (indent, transform)12
CompactNumberFormat class12
New String methods (repeat, isBlank, strip, lines)11
var type allowed in Lambda Parameters:
(@NonNull var x) -> process(x)
11
New HTTP client API119
TLS v1.3 – support for a new SSL/TLS protocol version11
var type allowed for local variables:
var length = str.length();
10
Flow API (reactive streams)9
Java Platform Module System (modules)9
Collection factory methods:
List.of(a, b, c); Set.of(d, e, f, g); Map.of(k1, v1, k2, v2);
9
Stream API improvements (takeWhile, dropWhile, ofNullable, iterate with condition)9
Multi-Resolution Image API9
Stack-Walking API9
this.getClass().getPackageName()9
Process API updates (detailed info about processes, e.g. ID, onExit, destroy)9
new methods in CompletableFuture API (delay, timeout)9
Interface private methods9
since and forRemoval in @Deprecated9
Interface Default and Static Methods8
Method References8
Optional class8
Lambda expressions8
Functional interfaces8
Stream API8
Effectively Final Variables8
Repeating Annotations8
New Date Time API 8

New JDK tools and features since OpenJDK 8

Tool / featureSinceExperimental since
Foreign Function & Memory API (an alternative to JNI)17
Experimental Java-Based JIT Compiler (Graal VM)10
Packaging Tool14
Epsilon (no-op) GC11
Shenandoah GC1512
Z GC (JEP 377)1511
Helpful NullPointerExceptions14
Launching Java files as scripts11
Flight recorded (data collection framework for troubleshooting)11
Docker Container Support:
-XX:-UseContainerSupport
10,
8u191
Flexible heap size selection:
-XX:MaxRAMPercentage
10,
8u191
Application Class-Data Sharing (CDS)10
jlink – custom JRE image, subset of JRE9
JShell (Java REPL) – run Java commands interactively9
Multi-Release JAR Files9
Compact Strings9

Deprecated/removed features and APIs:

Feature / APIDeprecated sinceRemoved since
Deprecate the Security Manager for Removal17
Deprecate the Applet API for Removal17
Constructors of primitive wrapper classes (e.g. new Integer(1))16
RMI Activation1517
ParallelScavenge + SerialOld GC Combination14
Strongly Encapsulate JDK Internals (except sun.misc.Unsafe and some more)
– internal JDK classes won’t be available anymore
917
Nashorn JavaScript Engine1115
Solaris and SPARC Ports1415
CMS GC914
Pack200 Tools and API1114
Java FX (moved to OpenJFX)11
Java EE and CORBA modules911
javah Native-Header Generator10
jhat Heap Visualizer9
Launch-Time JRE Version Selection9
Rarely-Used GC Combinations 89
Applet API (Deprecate the Applet API for Removal in Java 17)9

For more details, the javaalmanac.io/ catalog is very useful to browse the changes in Java thoughout all its history. It can give you complete diff of APIs between selected Java versions, e.g. between Java 8 and Java 11. Very useful If you’re thinking about migrating to a specific Java version.

Dávid Csákvári also wrote a similar article as mine for new features between Java 8 and Java 16, which is more detailed and with a lot of useful examples.

Leave a Reply

Your email address will not be published. Required fields are marked *