Java 10 New Features

Java SE 10 was released in March 2018.

The full list of new features in JDK 10 can be found here:
http://openjdk.java.net/projects/jdk/10/

In this tutorial, we will look at some of these new features and examine some of them.

1. JEP 286: Local-Variable Type Inference

To decrease the boilerplate coding, Java 10 introduces local-variable type inference feature.

With this feature it is not mandatory explicitly declaring the type of a local variable. Instead, the compiler infers the type of the expression.

Without JEP 286: 

List<String> list = new ArrayList<>();
Stream<String> stream = list.stream();

With JEP 286:

var list = new ArrayList<String>();
var stream = list.stream(); 

2. JEP 307: Parallel Full GC For G1

The G1 garbage collector was made the default in JDK 9. However it uses a single threaded mark-sweep-compact algorithm. With Java 10, G1 now does full GC in parallel.

The number of threads used during parallel phases of the garbage collectors can be set via -XX:ParallelGCThreads.

3. JEP 310: Application Class-Data Sharing

Class-Data Sharing, introduced in JDK 5, allows a set of classes to be pre-processed into a shared archive file that can then be memory-mapped at runtime to reduce startup time. 

Currently CDS only allows the bootstrap class loader to load archived classes. Application CDS ("AppCDS") extends CDS to allow the built-in system class loader (a.k.a., the "app class loader"), the built-in platform class loader, and custom class loaders to load archived classes.

Here is a good article about how to do that: Application CDS

References:
http://openjdk.java.net/jeps/310

4. JEP 314: Additional Unicode Language-Tag Extensions

http://openjdk.java.net/jeps/314

5. JEP 317: Experimental Java-Based JIT Compiler

The GraalVM compiler became available as an experimental JIT compiler.

Graal, a Java-based JIT compiler, is the basis of the experimental Ahead-of-Time (AOT) compiler introduced in JDK 9.

To enable Graal as the JIT compiler, use the following options on the java command line:

-XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler

6. JEP 319: Root Certificates

With this JEP, Java 10 provides a default set of root Certification Authority (CA) certificates in the JDK.

7. Container Support




Popular

Java EE Technology Stack

Dependency Injection In Java and CDI

Proxy Server