Latest in branch Java SE 13
13.0.2
Released 14 Jan 2020
(6 years ago)
SoftwareJava/Java SE
VersionJava SE 13
Status
End of life
Class file version57.0
Initial release13
17 Sep 2019
(6 years ago)
Latest release13.0.2
14 Jan 2020
(6 years ago)
End of
premier support
Mar 2020
(Ended 6 years, 2 months ago)
End of
extended support
Unavailable
Release noteshttps://www.oracle.com/java/technologies/javase/13-0-2-relnotes.html
Documentationhttps://docs.oracle.com/javase/13
Downloadhttps://www.oracle.com/java/technologies/javase/jdk13-archive-downloads.html
Java/Java SE Java SE 13 ReleasesView full list

What Is New in Java 13

Java 13 delivers incremental improvements with two preview features and several production-ready enhancements. It focuses on developer productivity and laying groundwork for future capabilities.

Category Key Changes
New Features (Preview) Text Blocks, Switch Expressions
Improvements Reimplement the Legacy Socket API, ZGC Uncommit Unused Memory
APIs & Deprecation Dynamic CDS Archive, Deprecation of RMI Activation
Bug Fixes Various fixes in core libraries and HotSpot VM

What are the new preview features in Java 13?

Java 13 introduced two preview features that allow developers to test new functionality and provide feedback. These features require the --enable-preview flag to use.

Text Blocks

Text Blocks simplify writing multi-line strings, eliminating the need for most escape sequences. They use triple-quote (""") delimiters and automatically format the string in a predictable way.

String html = """
    <html>
        <body>
            <p>Hello, World</p>
        <body>
    </html>
    """;

In practice, this makes working with HTML, JSON, or SQL templates much cleaner and less error-prone.

Switch Expressions

Switch Expressions (previewed in Java 12 and updated in 13) allow the entire switch statement to be used as an expression. They can return a value and use a new yield statement instead of break.

int dayNum = switch (day) {
    case MON, FRI, SUN -> 6;
    case TUE                -> 7;
    case THU, SAT         -> 8;
    case WED              -> 9;
    default -> {
        yield getDefaultValue();
    }
};

This syntax reduces boilerplate and makes the intent of the code clearer by treating switches as expressions that produce a result.

How did Java 13 improve performance and garbage collection?

The main performance enhancements target more efficient memory management and a foundational networking API overhaul.

ZGC: Uncommit Unused Memory

The Z Garbage Collector now returns unused heap memory to the operating system. This is a significant improvement for environments where resource efficiency is critical, as it reduces the memory footprint of idle applications.

Reimplement the Legacy Socket API

Java 13 replaces the underlying implementation of the java.net.Socket and java.net.ServerSocket APIs. The new implementation is simpler to maintain and debug, paving the way for future features like user-mode threads (Project Loom). It uses java.util.concurrent locks instead of synchronized methods.

What API updates and deprecations should developers know about?

This release includes a useful feature for application startup and begins the process of removing an obsolete technology.

Dynamic CDS Archives

Application Class-Data Sharing (CDS) has been extended to allow dynamic archiving. You can create a shared archive at the end of an application's execution, capturing classes used during that run. This can improve startup time for subsequent runs.

Deprecation of RMI Activation

The RMI Activation mechanism has been deprecated for removal in a future release. This is a legacy part of Java's distributed computing system that is no longer relevant for modern applications.

FAQ

Are Text Blocks just a syntax sugar for multi-line strings?
No, they are more powerful. They handle incidental white space intelligently, avoid the need for most escape sequences, and can even interpret escape sequences like \n and \t without requiring an extra layer of processing.

What's the difference between 'yield' and 'return' in switch expressions?
yield is used specifically within a switch expression to return a value from a case block. A return statement would return from the entire enclosing method, not just the switch expression.

Is the old Socket API being removed in Java 13?
No, only the underlying implementation is being replaced. The public API remains exactly the same, so existing code will continue to compile and run without changes.

How do I use the new Dynamic CDS feature?
You create a base archive as usual. Then, to create a dynamic archive for your app, you run: java -XX:ArchiveClassesAtExit=app.jsa -cp app.jar AppMain. To use it, run: java -XX:SharedArchiveFile=app.jsa -cp app.jar AppMain.

Why is RMI Activation being removed?
It's a complex and obsolete part of the RMI system that is no longer widely used. Modern distributed systems typically use other technologies like web services, REST APIs, or more contemporary RPC frameworks.

Releases In Branch Java SE 13

VersionRelease date
13.0.214 Jan 2020
(6 years ago)
13.0.115 Oct 2019
(6 years ago)
1317 Sep 2019
(6 years ago)