Why Upgrade to Java 11? Key Features, Performance Boosts, and Migration Tips
This article explains Java 8's commercial licensing, highlights Java 11's performance gains, outlines major language and API enhancements from Java 8 to 11, provides code examples, discusses HTTP client usage, removed components, container support, and recommends Amazon Corretto as a free JDK alternative.
Java8 Commercial Licensing
Since January 2019 Oracle JDK requires a commercial license for Java SE 8 updates after 8u201/202 for commercial use; the latest free version for commercial use is 8u201/202, while personal developers can use any Oracle JDK version for free.
Java11 Performance Improvement
Switching to Java 11 can yield a 16% performance improvement, partly due to JEP 307: Parallel Full GC for G1 introduced in Java 10.
Overview of Changes from Java 8 to Java 11
Note: This article lists only the most relevant changes for developers.
Compact Strings
Starting with Java 9, strings are stored as byte[] instead of char[], saving up to 50% memory for Latin‑1 characters.
Enhanced APIs
1. String enhancements (since 11)
<code>// Check if a string is blank
" ".isBlank(); // true
// Trim leading and trailing whitespace
" Hello Java11 ".strip(); // "Hello Java11"
// Trim trailing whitespace only
" Hello Java11 ".stripTrailing(); // " Hello Java11"
// Trim leading whitespace only
" Hello Java11 ".stripLeading(); // "Hello Java11 "
// Repeat a string
"Java11".repeat(3); // "Java11Java11Java11"
// Count lines in a string
"A\nB\nC".lines().count(); // 3</code>2. Collection enhancements
Since Java 9, the JDK provides
ofand
copyOfmethods for immutable collections.
of() @since 9
copyOf() @since 10
Example 1:
<code>var list = List.of("Java", "Python", "C"); // immutable list
var copy = List.copyOf(list); // returns the same immutable list
System.out.println(list == copy); // true
var list2 = new ArrayList<String>(); // mutable list
var copy2 = List.copyOf(list2); // creates an immutable copy
System.out.println(list2 == copy2); // false</code>Example 2:
<code>var set = Set.of("Java", "Python", "C");
var copy = Set.copyOf(set);
System.out.println(set == copy); // true
var set1 = new HashSet<String>();
var copy1 = Set.copyOf(set1);
System.out.println(set1 == copy1); // false</code>Example 3:
<code>var map = Map.of("Java", 1, "Python", 2, "C", 3);
var copy = Map.copyOf(map);
System.out.println(map == copy); // true
var map1 = new HashMap<String, Integer>();
var copy1 = Map.copyOf(map1);
System.out.println(map1 == copy1); // false</code>Note: Collections created with
ofor
copyOfare immutable; attempts to modify them throw
java.lang.UnsupportedOperationException. Duplicates are not allowed for
Set.ofand duplicate keys for
Map.ofcause
IllegalArgumentException.
3. Stream enhancements (since 9)
Java 9 added four new Stream methods:
ofNullable(T t)– creates an empty stream when the argument is null.
takeWhile(Predicate<? super T> predicate)– consumes elements while the predicate is true, then stops.
dropWhile(Predicate<? super T> predicate)– drops elements while the predicate is true, then returns the rest.
iterateoverload with a predicate to limit the stream without
limit.
4. Optional enhancements (since 9)
stream()– returns a stream containing the value or an empty stream.
ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction)– executes
actionif a value is present, otherwise runs
emptyAction.
or(Supplier<? extends Optional<? extends T>> supplier)– returns the original optional if present, otherwise the supplied optional.
5. InputStream enhancements (since 9)
<code>String text = "java";
try (var in = new ByteArrayInputStream(text.getBytes());
var out = new ByteArrayOutputStream()) {
in.transferTo(out);
System.out.println(out); // java
}</code>HTTP Client API
The new HTTP client supports synchronous and asynchronous requests.
<code>var request = HttpRequest.newBuilder()
.uri(URI.create("https://www.baidu.com/"))
.build();
var client = HttpClient.newHttpClient();
// Synchronous
HttpResponse<String> resp = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());
// Asynchronous
CompletableFuture<HttpResponse<String>> async = client.sendAsync(request, HttpResponse.BodyHandlers.ofString());
HttpResponse<String> resp2 = async.get();
System.out.println(resp2.body());</code>Removed Content in Java 11
com.sun.awt.AWTUtilities
sun.misc.Unsafe.defineClass (use java.lang.invoke.MethodHandles.Lookup.defineClass)
Thread.destroy() and Thread.stop(Throwable)
sun.nio.ch.disableSystemWideOverlappingFileLockCheck
sun.locale.formatasdefault
jdk.snmp module
JavaFX (removed from OpenJDK 11, still present in Oracle JDK 10)
Java Mission Control (requires separate download)
Root Certificates: Baltimore Cybertrust Code Signing CA, SECOM, AOL, Swisscom
Java EE and CORBA modules deprecated in Java 9 are removed in Java 11
Full Linux Container (Docker) Support
Java applications running in Docker containers can now respect memory and CPU limits set by cgroups, preventing performance degradation that occurred before Java 10.
Honors container memory limits
Honors container CPU availability
Honors container CPU constraints
JDK Recommendation
Since Java 11, Oracle provides only paid commercial support. Amazon Corretto, released under the GPL, is recommended as a free, long‑term support (LTS) alternative.
Corretto LTS includes performance and security updates for Corretto 8 (free until June 2023) and quarterly updates for Corretto 11 (until at least August 2024).
Download links: Corretto 8 , Corretto 11
Disclaimer
This series is compiled by the author of the microservice core component Mica, Rú Mèng Technology . Please retain the original author and cite the source when referencing or republishing.
Column Index
"Time to Upgrade to Java 11" – JDK 11 advantages and selection
"Time to Upgrade to Java 11" – Migration pitfalls
"Time to Upgrade to Java 11" – JVM parameter tuning
"Time to Upgrade to Java 11" – HTTP/2 clear text (h2c) in microservices
"Time to Upgrade to Java 11" – Solving h2c communication issues
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
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.