DEV Community

Said Olano
Said Olano

Posted on

Java 11 New Features and Performance Improvements: A Practical Guide (2026-08-18 18:42)

Java 11 New Features and Performance Improvements

Released in September 2018, Java 11 is a Long-Term Support (LTS) release, making it one of the most important milestones since Java 8. For teams planning migrations, Java 11 offers a compelling mix of new language features, API enhancements, and under-the-hood performance improvements.

In this post, we'll explore the most impactful changes and how they affect real-world applications.

Why Java 11 Matters

Java 11 is the first LTS release after Java 8, meaning it receives extended support and security updates. Unlike the non-LTS releases (9 and 10), it's designed for production stability, which is why many enterprises skipped straight from 8 to 11.

Language and API Enhancements

1. Local-Variable Syntax for Lambda Parameters

Java 10 introduced var for local variables. Java 11 extends this to lambda parameters, allowing you to apply annotations consistently.

// Now valid in Java 11
list.forEach((var item) -> System.out.println(item));

// Useful for annotations
list.forEach((@Nonnull var item) -> process(item));
Enter fullscreen mode Exit fullscreen mode

2. New String Methods

The String class gained several convenient methods that reduce boilerplate.

// Check if a string is blank (empty or whitespace only)
"   ".isBlank();          // true

// Strip leading/trailing whitespace (Unicode-aware)
"  hello  ".strip();      // "hello"
"  hello  ".stripLeading();  // "hello  "
"  hello  ".stripTrailing(); // "  hello"

// Repeat a string
"ab".repeat(3);           // "ababab"

// Stream lines
"line1\nline2".lines().forEach(System.out::println);
Enter fullscreen mode Exit fullscreen mode

Note: strip() differs from trim() because it uses Character.isWhitespace(), correctly handling Unicode whitespace characters.

3. Files Read/Write Convenience Methods

Reading and writing strings to files is now a one-liner.

import java.nio.file.Files;
import java.nio.file.Path;

Path path = Path.of("example.txt");

// Write
Files.writeString(path, "Hello, Java 11!");

// Read
String content = Files.readString(path);
Enter fullscreen mode Exit fullscreen mode

4. The New HTTP Client (Standardized)

Introduced as an incubator in Java 9, the HttpClient API is now standardized under java.net.http. It supports HTTP/2 and WebSocket, and offers both synchronous and asynchronous request handling.

import java.net.http.*;
import java.net.URI;

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.example.com/data"))
    .GET()
    .build();

// Synchronous
HttpResponse<String> response =
    client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

// Asynchronous
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
    .thenApply(HttpResponse::body)
    .thenAccept(System.out::println);
Enter fullscreen mode Exit fullscreen mode

5. Running Single-File Source Code

You can now run a Java source file directly without explicit compilation—ideal for scripting and quick prototypes.

java HelloWorld.java
Enter fullscreen mode Exit fullscreen mode

No javac step required.

Performance Improvements

1. Epsilon Garbage Collector (Experimental)

The Epsilon GC is a "no-op" garbage collector that allocates memory but never reclaims it. It's useful for performance testing, short-lived jobs, and measuring GC overhead.

java -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC MyApp
Enter fullscreen mode Exit fullscreen mode

Use it to benchmark allocation rates without GC interference. Do not use it in typical long-running production services—the application will crash once memory is exhausted.

2. Z Garbage Collector (Experimental)

ZGC is a scalable, low-latency garbage collector designed for large heaps (multi-terabyte) with pause times under 10ms, regardless of heap size.

java -XX:+UnlockExperimentalVMOptions -XX:+UseZGC MyApp
Enter fullscreen mode Exit fullscreen mode

ZGC performs most of its work concurrently, making it ideal for latency-sensitive applications. It became production-ready in later releases (Java 15), but Java 11 is where it first appeared.

3. Improved G1 Garbage Collector

The default G1 GC received several enhancements in Java 11:

  • Faster full GCs via a parallelized full GC algorithm (previously single-threaded).
  • Better handling of aborted mixed collections.

These changes reduce worst-case pause times for applications still using the default collector.

4. Flight Recorder Now Open Source

Java Flight Recorder (JFR), previously a commercial feature, is now open source and included in the OpenJDK. It provides low-overhead profiling and diagnostics data collection.

java -XX:+FlightRecorder \
     -XX:StartFlightRecording=duration=60s,filename=recording.jfr \
     MyApp
Enter fullscreen mode Exit fullscreen mode

Combined with JDK Mission Control (JMC), JFR gives you deep insight into application behavior with minimal runtime cost (typically under 1%).

Removed and Deprecated Features

Migrating from Java 8? Be aware of these removals:

  • Java EE and CORBA modules (java.xml.ws, java.xml.bind, java.corba, etc.) were removed. Add JAXB and JAX-WS as external dependencies if needed.

Top comments (0)