What’s New in Java 10? A Deep Dive into Its Key Features
This article reviews the major new features of Java 10—including local‑variable type inference with var, a unified JDK repository, enhanced garbage‑collector interfaces, a parallel G1 collector, application class‑data sharing, thread‑local handshakes, Graal JIT, extended Unicode locales, heap allocation on alternative storage, and a time‑based version‑string scheme—highlighting their impact on developers and performance.
Local Variable Type Inference
Java 10 introduces local‑variable type inference, allowing developers to omit explicit type declarations for local variables initialized at declaration. The new reserved word var lets the compiler infer the type, reducing boilerplate while preserving static type safety. It works only for variables with initializers, enhanced‑for loop indices, and traditional for‑loop variables, not for method parameters, return types, fields, or capture expressions.
Example of var usage
var list = new ArrayList<String>(); // ArrayList<String>()
var stream = list.stream(); // Stream<String>Compared with earlier Java versions, the same code required explicit generic types:
List<String> list = new ArrayList<String>();
Stream<String> stream = getStream();And after Java 7 the diamond operator simplified it further:
List<String> list = new LinkedList<>();
Stream<String> stream = getStream();Note that var is a reserved identifier, not a keyword, and overuse may hurt code readability, especially without IDE support.
Consolidated JDK Repository
Java 10 merges the eight separate Mercurial repositories (root, corba, hotspot, jaxp, jaxws, jdk, langtools, nashorn) into a single repository, enabling atomic commits across components and simplifying mirroring to Git.
Unified Garbage‑Collector Interface
The GC interface is refactored to isolate implementations, allowing new collectors to be added more easily and shared code to reside in helper classes.
Parallel G1 Garbage Collector
Java 10 adds a parallel version of the G1 collector, using the same number of worker threads as young‑generation and mixed‑generation collections. The thread count can be tuned with -XX:ParallelGCThreads.
Application Class‑Data Sharing (AppCDS)
AppCDS extends the existing class‑data sharing mechanism, allowing application classes to be placed in the shared archive, reducing startup time and memory footprint for large enterprise applications and micro‑services.
Thread‑Local Handshakes
Java 10 introduces the -XX:ThreadLocalHandshakes option, enabling safe points for individual threads without stopping the entire JVM, improving performance for thread‑specific operations.
Removal of the javah Tool
The legacy javah tool is removed; header generation for JNI is now performed by javac.
Extended Unicode Language Tags
Java 10 adds support for additional Unicode locale extensions (cu, fw, rg, tz) in java.util.Locale, enabling richer locale‑specific data.
Heap Allocation on Alternative Storage
JVM can allocate the heap on non‑volatile memory devices via the -XX:AllocateHeapAt=<path> option, leveraging DAX‑enabled file systems.
Experimental Graal JIT Compiler
Graal, a Java‑based JIT compiler, is available as an experimental option on Linux/x64. Enable it with -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler.
Root Certificate Store
Java 10 ships a default set of CA root certificates in the JDK, fixing the empty cacerts store issue present in earlier releases.
Time‑Based Version‑String Scheme
Java 10 adopts a time‑based version‑string format while retaining compatibility with the JEP 223 scheme, simplifying identification of release dates.
Source: IBM DeveloperWorks
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
