JDK 11‑13 Enhancements: Switch Expressions, Text Blocks, Dynamic CDS, ZGC Improvements, Socket API Rewrite, New FileSystem Methods, NIO Updates, Time API, I18N, and Feature Removals
This article summarizes the major JDK 11‑13 updates, including switch expression simplifications, multi‑line text block literals, dynamic AppCDS archives, ZGC memory‑release enhancements, a modernized socket API, new FileSystems methods, bulk NIO ByteBuffer operations, the Reiwa era in java.time, Unicode 12.1 support, and several deprecated features that have been removed.
1. Switch Optimization Updates
JDK 11 and earlier required verbose switch statements with repeated case labels and break. JDK 12 introduced pattern‑matching style case groups using the -> arrow, and JDK 13 added expression‑based switches that return a value.
switch (day) {
case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
case TUESDAY -> System.out.println(7);
case THURSDAY, SATURDAY -> System.out.println(8);
case WEDNESDAY -> System.out.println(9);
}JDK 13 also allows a switch expression that yields a result:
static void howMany(int k) {
System.out.println(
switch (k) {
case 1 -> "one";
case 2 -> "two";
default -> "many";
}
);
}2. Text Block Upgrade
Prior to JDK 13, multi‑line strings were built with concatenation and escaped new‑line characters. JDK 13 introduces text blocks delimited by triple quotes, preserving line breaks and indentation.
String html = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";Text blocks are equivalent to a single string literal with explicit \n characters.
3. Dynamic CDS Archives
The goal is to improve the usability of Application Class‑Data Sharing (AppCDS) by removing the need for a separate trial run to generate a class list. The -Xshare:dump option now creates a dynamic archive that works with both built‑in and user‑defined class loaders.
4. Unused Memory Release for ZGC
ZGC is enhanced to return unused heap memory to the operating system, addressing scenarios where applications remain idle for long periods (e.g., containerized services). This aligns ZGC with the behavior of G1 and Shenandoah.
5. Reimplementation of Legacy Socket API
The old java.net.Socket and java.net.ServerSocket implementations, which date back to JDK 1.0 and mix Java with native C code, are replaced by a cleaner, more maintainable design that is compatible with Project Loom’s virtual threads.
6. New FileSystems Methods
Three overloads of FileSystems.newFileSystem have been added to simplify creating file‑system providers from a Path and optional configuration map:
FileSystem fs = FileSystems.newFileSystem(path, map);
FileSystem fs = FileSystems.newFileSystem(path, map, classLoader);These overloads avoid ambiguous method calls that previously required explicit casts.
7. NIO Bulk Get/Put Methods
New absolute bulk get and put operations for java.nio.ByteBuffer and other buffer types transfer a sequence of bytes without affecting the buffer’s position.
8. Core Library – java.time
The Japanese era name “Reiwa” is now represented as a public enum constant. It can be obtained via JapaneseEra.of(3) or JapaneseEra.valueOf("Reiwa") in JDK 13 and later.
9. Core Library – java.util I18N
Unicode support is upgraded to version 12.1, adding new scripts, emojis, and the character U+32FF (SQUARE ERA NAME REIWA). Classes such as java.lang.Character, java.text.Bidi, and java.util.regex reflect these updates.
10. HotSpot GC Enhancements
JEP 351 adds the ability for ZGC to release unused memory, introduces the -XX:SoftMaxHeapSize flag, and raises the maximum heap size supported by ZGC from 4 TB to 16 TB.
11. Security Library – java.security
System property com.sun.security.crl.readtimeout now defaults to 15 seconds, keytool -showinfo -tls displays TLS configuration, and the SunMSCAPI provider gains support for CNG‑format RSA and EC private keys.
12. Feature Removals
Deprecated APIs have been removed, including the pre‑JDK 1.4 SocketImpl implementation, and the runtime tracing methods traceInstructions(boolean) and traceMethodCalls(boolean) from java.lang.Runtime.
(End of summary)
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.
Java Captain
Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.
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.
