New features of Java9

  java

Java language feature series

Order

This article focuses on the new features of Java9

Property list

For complete features, seeJDK 9 featuresHere are some relatively important ones:

Module system JPMS (Heavy weight)

Relevant specifications and JEP:

Relevant interpretation

G1 becomes default garbage collector

Related JEP:

Relevant interpretation

Unified JVM/GC Logging

Related JEP:

Relevant interpretation

HTTP/2 Client(Incubator)

HTTP2 is supported, while the api of httpclient is improved to support asynchronous mode.

Related JEP

Relevant interpretation

jshell: The Java Shell (Read-Eval-Print Loop)

Related JEP

Relevant interpretation

Convenience Factory Methods for Collections

Related JEP

Most factories that used to use the Guava class library to collect classes, such as

Lists.newArrayList(1,2,3,4,5);
Sets.newHashSet(1,2,3,4,5);
Maps.newHashMap();

Note that the above returned set is mutable

Now java9 can directly utilize jdk’s built-in collection factory, such as

List.of(1,2,3,4,5);
Set.of(1,2,3,4,5);
Map.of("key1","value1","key2","value2","key3","value3");

Note that the collection factory above jdk9 returns immutable

Process API Updates

Related JEP

Relevant interpretation

Stack-Walking API

Related JEP

Relevant interpretation

Variable Handles

Related JEP

Relevant interpretation

Docker support

Other

Summary

Java9 has taken a bold step to introduce modular system, and its jdk class library is also the first to be modular. The newly introduced jlink can simplify the size of jdk, plus the docker image of Alpine Linux, which can greatly reduce the size of the docker image of java applications, while also supporting the cpu and memory restrictions of Docker (Java SE 8u131 and above are supported), is very worth using.

doc