Overview of New Features in Java 13
Introduction
Java 13 was released on 17th September 2019. With five JDK Enhancement Proposals (JEPs), it was one of the smallest releases since Java moved to a six-month release cadence - a good example of the new model, in which a release simply ships whatever is ready. Its most visible changes are previews of two language features which later became standard. This article gives an overview of the new features in Java 13, with links to detailed tutorials.
Language features (previews)
JVM and library features
Smaller library changes
- Text Blocks (Preview) - JEP 355 - multi-line string literals delimited by three double quotes (
"""), which make embedded JSON, SQL and HTML readable, with no\nescapes or+concatenation. Text blocks replaced the withdrawn raw string literals of Java 12, were previewed again in Java 14, and became standard in Java 15. Read the tutorial on text blocksClick to read tutorial: Java Text Blocks: Multi-line Strings with Examples. - Switch Expressions (Second Preview) - JEP 354 - the switch expressions previewed in Java 12, with one change based on feedback: a value is returned from a block in a switch expression with the new
yieldstatement instead ofbreak value;. They became standard in Java 14. Read the tutorial on switch expressions and yieldClick to read tutorial: Java Switch Expressions: Arrow Labels and yield.
- Dynamic CDS Archives - JEP 350 - creating an application class-data sharing archive used to take two extra steps: dumping a list of the loaded classes, and then building the archive. Now, running the application once with
-XX:ArchiveClassesAtExit=app.jsacreates the archive automatically when the application exits, and later runs use it with-XX:SharedArchiveFile=app.jsafor a faster startup. See the AppCDS tutorialClick to read: AppCDS tutorial for the background. - ZGC: Uncommit Unused Memory - JEP 351 - the ZGC garbage collector can now return unused heap memory to the operating system, as G1 started doing in Java 12. ZGC itself became production-ready in Java 15 - read about ZGC and ShenandoahClick to read tutorial: ZGC and Shenandoah: Low-Pause GCs in Java 15.
- Reimplement the Legacy Socket API - JEP 353 - the code behind
java.net.SocketandServerSocket, which dated back to JDK 1.0 and mixed Java and C, was replaced by a simpler, modern implementation (NioSocketImpl). Application code does not change; the new implementation was also prepared to work with the virtual threads which came later in Java 21Click to read: Java 21. TheDatagramSocketAPI followed in Java 15.
FileSystems.newFileSystem(Path)- opening a ZIP or JAR file as a file system no longer needs a class loader argument.ByteBuffergot absolute bulkgetandputmethods, which read or write a range of bytes at a given index without changing the buffer's position, and aslice(index, length)method.- The XML
DocumentBuilderFactoryandSAXParserFactorygotnewDefaultNSInstance()methods, which create namespace-aware parsers directly. - Unicode support was upgraded to Unicode 12.1.
yield statement. On the JVM side, dynamic CDS archives made faster startup a one-flag affair, ZGC learned to give memory back to the operating system, and the old socket implementation was rewritten. Lastly, we listed the smaller library changes. Next, read the overview of new features in Java 14Click to read tutorial: Overview of New Features in Java 14.Continue Reading Java 12 to 17 Tutorials
Overview of New Features in Java 14Click to read tutorial: Overview of New Features in Java 14 Java 12 API Additions: String.indent, teeing, mismatchClick to read tutorial: Java 12 API Additions: String.indent, teeing, mismatch Overview of New Features in Java 12Click to read tutorial: Overview of New Features in Java 12 Overview of New Features in Java 15Click to read tutorial: Overview of New Features in Java 15 Overview of New Features in Java 16Click to read tutorial: Overview of New Features in Java 16 Overview of New Features in Java 17Click to read tutorial: Overview of New Features in Java 17 Java Switch Expressions: Arrow Labels and yieldClick to read tutorial: Java Switch Expressions: Arrow Labels and yield Java 14 Helpful NullPointerExceptions ExplainedClick to read tutorial: Java 14 Helpful NullPointerExceptions Explained Java 14 JFR Event Streaming Tutorial with ExamplesClick to read tutorial: Java 14 JFR Event Streaming Tutorial with Examples
Overview of New Features in Java 14Click to read tutorial: Overview of New Features in Java 14 Java 12 API Additions: String.indent, teeing, mismatchClick to read tutorial: Java 12 API Additions: String.indent, teeing, mismatch Overview of New Features in Java 12Click to read tutorial: Overview of New Features in Java 12 Overview of New Features in Java 15Click to read tutorial: Overview of New Features in Java 15 Overview of New Features in Java 16Click to read tutorial: Overview of New Features in Java 16 Overview of New Features in Java 17Click to read tutorial: Overview of New Features in Java 17 Java Switch Expressions: Arrow Labels and yieldClick to read tutorial: Java Switch Expressions: Arrow Labels and yield Java 14 Helpful NullPointerExceptions ExplainedClick to read tutorial: Java 14 Helpful NullPointerExceptions Explained Java 14 JFR Event Streaming Tutorial with ExamplesClick to read tutorial: Java 14 JFR Event Streaming Tutorial with Examples