Detailed Overview of JDK 13 New Features
This article provides a comprehensive English summary of JDK 13's new features—including switch expression enhancements, text‑block syntax, dynamic CDS archives, ZGC memory reclamation, revamped socket APIs, new FileSystems methods, updated NIO ByteBuffer operations, the Reiwa era in java.time, Unicode 12.1 support, GC improvements, security updates, and removed legacy functionalities—accompanied by original Java code examples.
1. Introduction
Historically, Oracle released new JDK versions while many developers continued using older releases; after moving from JDK 7 to JDK 8, newer versions (9‑13) were released roughly every six months. A 2018 JVM ecosystem survey showed that 70% of users still used Oracle JDK, 21% used OpenJDK, and 79% of all users were on Java 8, indicating that many projects still rely on older versions despite newer releases.
2. JDK 13 New Features
2.1 Switch Expression Optimizations
Prior to JDK 11, a traditional switch statement required explicit case labels and break statements. JDK 12 introduced a compact form using the arrow ( ->) syntax, allowing multiple case labels to share a single statement. JDK 13 further refines this with a static void howMany(int k) method that demonstrates the new switch expression returning values:
static void howMany(int k) {
System.out.println(
switch (k) {
case 1 -> "one";
case 2 -> "two";
default -> "many";
}
);
}2.2 Text Block Upgrade
Before JDK 13, constructing multi‑line strings required concatenation and escaped line breaks. JDK 13 introduces text blocks delimited by triple quotes ( """), preserving formatting and eliminating the need for explicit newline characters.
String html = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";2.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 creates a shared archive that works with both built‑in and user‑defined class loaders.
2.4 ZGC Memory Release
ZGC is enhanced to return unused heap memory to the operating system, addressing scenarios where applications remain idle for long periods (e.g., containerized workloads). This aligns ZGC with other collectors like G1 and Shenandoah that already support memory release.
For example, the heap required during startup may be larger than the steady‑state heap; returning unused memory improves resource efficiency.
2.5 Reimplementation of Legacy Socket API
The old java.net.Socket and java.net.ServerSocket implementations, dating back to JDK 1.0, are replaced with a simpler, modern design that is easier to maintain and better suited for Project Loom’s virtual threads.
2.6 New FileSystems Methods
Three overloads of FileSystems.newFileSystem are added:
newFileSystem(Path) newFileSystem(Path, Map<String, ?>) newFileSystem(Path, Map<String, ?>, ClassLoader)These methods simplify creating file‑system providers that treat file contents as a file system. Example usage:
FileSystem fs = FileSystems.newFileSystem(path, null);2.7 NIO ByteBuffer Bulk Operations
New bulk get and put methods are introduced for java.nio.ByteBuffer and other buffer types, allowing transfer of consecutive bytes without affecting the buffer’s position.
2.8 java.time – New Japanese Era
JDK 13 adds support for the Reiwa era, the current Japanese era starting May 1 2019. It can be obtained via JapaneseEra.of(3) or JapaneseEra.valueOf("Reiwa"). The placeholder era "NewEra" is removed.
2.9 Internationalization (I18N) – Unicode 12.1
Java now supports Unicode 12.1, adding 554 characters, four new scripts, 150 scripts total, and 61 new emoji. Classes such as java.lang.Character, java.text.Bidi, java.text.Normalizer, and the regex package are updated accordingly.
2.10 HotSpot GC Enhancements
JEP 351: ZGC now releases unused memory.
Added -XX:SoftMaxHeapSize flag.
ZGC maximum heap size increased from 4 TB to 16 TB.
2.11 Security Library Updates
System property com.sun.security.crl.readtimeout now defaults to 15 seconds.
New keytool -showinfo -tls command displays TLS configuration.
SunMSCAPI provider now supports CNG‑format private keys for RSA and EC.
2.12 Removed Features
Several legacy APIs have been removed, including pre‑JDK 1.4 SocketImpl implementations, deprecated runtime tracing methods, and other obsolete components.
(End of article)
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.
Architect's Tech Stack
Java backend, microservices, distributed systems, containerized programming, and more.
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.
