Latest in branch Java SE 10
10.0.2
Released 17 Jul 2018
(7 years ago)
SoftwareJava/Java SE
VersionJava SE 10
Status
End of life
Class file version54.0
Initial release10
20 Mar 2018
(8 years ago)
Latest release10.0.2
17 Jul 2018
(7 years ago)
End of
premier support
Sep 2018
(Ended 7 years, 7 months ago)
End of
extended support
Unavailable
Release noteshttps://www.oracle.com/java/technologies/javase/10-0-2-relnotes.html
Documentationhttps://docs.oracle.com/javase/10
Downloadhttps://www.oracle.com/java/technologies/java-archive-javase10-downloads.html
Java/Java SE Java SE 10 ReleasesView full list

What Is New in Java 10

Java 10 is a feature release that introduced several key improvements focused on developer productivity, application performance, and the start of a new release cadence. The most significant changes include local-variable type inference, a consolidated garbage collection interface, and application class-data sharing.

Category Key Changes
New Features Local-Variable Type Inference (JEP 286), Application Class-Data Sharing (JEP 310)
Improvements Consolidated GC Interface (JEP 304), Parallel Full GC for G1 (JEP 307), Thread-Local Handshakes (JEP 312)
APIs & Tools Optional.orElseThrow(), Unicode Language-Tag Extensions, New GC Combinations
Deprecations/Removals Deprecated java.security.acl and javax.security.auth.Policy, Removed the javah tool

What are the main language changes in Java 10?

The headline feature is JEP 286: Local-Variable Type Inference. This allows you to declare local variables using var instead of an explicit type, reducing boilerplate code while maintaining static typing. The compiler infers the type from the initializer expression.

// Before Java 10
ArrayList<String> list = new ArrayList<String>();
// With Java 10
var list = new ArrayList<String>();

In practice, this makes code less verbose, especially with complex generic types. It's strictly limited to local variables with initializers and cannot be used for method parameters or return types.

How did garbage collection improve?

Java 10 cleaned up the garbage collection architecture with two key JEPs. JEP 304 introduced a clean garbage collector interface, making it easier to add new GCs without touching the rest of the codebase. This is a foundational change for future GC development.

JEP 307 enabled parallel full garbage collection for the G1 garbage collector. Previously, G1's full GC used a single-threaded algorithm which could cause noticeable pauses. This change parallelizes that work, significantly reducing full GC pause times for G1 users.

What is Application Class-Data Sharing?

Application Class-Data Sharing (AppCDS) extends the original CDS feature to include application classes. It allows you to create a shared archive of pre-loaded classes that can be used by multiple JVM instances, reducing startup time and memory footprint.

This matters because it can lead to significant performance improvements for microservices and serverless environments where fast startup is critical. You create the archive once and then all JVMs on the same machine can benefit from it.

Were there any useful API additions?

Yes, a handy addition was the Optional.orElseThrow() method. This is a direct shortcut for Optional.get() but with a more descriptive name that clearly indicates it can throw an exception if no value is present.

// Before
String value = optionalValue.get();
// After
String value = optionalValue.orElseThrow();

Other API updates included full support for Unicode extensions in the Locale class and new methods for working with unmodifiable collections.

FAQ

Is the `var` keyword similar to JavaScript's dynamic typing?
No, it's completely different. Java's var maintains strong static typing - the compiler infers the type at compile time and it remains fixed. The variable is still statically typed, just with less verbose syntax.

Can I use `var` everywhere in my code?
No, it has specific limitations. You can only use var for local variables with explicit initializers. It cannot be used for method parameters, return types, constructor parameters, field declarations, or catch formal parameters.

Does G1 become the default garbage collector in Java 10?
G1 became the default GC in Java 9. Java 10 improves G1 by making its full garbage collection parallel, which addresses one of its main weaknesses compared to other collectors.

How much faster is startup with Application Class-Data Sharing?
The improvement varies by application, but typical savings range from 10% to 30% faster startup time. The benefit is most noticeable for applications with large numbers of classes or complex dependency graphs.

What was removed in Java 10 that might affect my code?
The javah tool for generating C header files was removed. Its functionality was integrated into javac. The java.security.acl package and javax.security.auth.Policy were deprecated and scheduled for removal.

Releases In Branch Java SE 10

VersionRelease date
10.0.217 Jul 2018
(7 years ago)
10.0.117 Apr 2018
(8 years ago)
1020 Mar 2018
(8 years ago)