Java 13 New Features

Java SE 13 was released in September 2019.

The full list of new features in JDK 13 can be found here:

In this tutorial, we will look over some of these new features and examine some of them.

1. JEP 350: Dynamic CDS Archives

Application Class Data Sharing was introduced with JEP 310, Java 10. It allows class loaders to load archived classes with a pre-generated class-data archive file and improves the startup performance. 

JEP-350 simplifies the generation of CDS archive files directly from the archive file, instead of providing a list of classes.

Create a CDS archive file of a jar file:

java -XX:ArchiveClassesAtExit=myapp.jsa -cp myapp.jar MyApp

Run a jar file with an existing CDS archive file:

java -XX:SharedArchiveFile=myapp.jsa -cp myapp.jar MyApp

2. JEP 351: ZGC: Uncommit Unused Memory

Performance improvement for the new ZGC collector introduced in Java 11 with JEP 333.

With this JEP, unused heap memory is now being returned to the operating system, by default.

3. JEP 354: Switch Expressions (Preview)

JEP-325 in Java 12 made it possible returning a value from a switch via using break or case L ->.

JEP-354 now replaces break with yield:

String getColor(int num) {
    String result = 
        switch (number) {
            case 1, 2, 3:
                yield "red, green or blue";                
            case 4 -> "yellow";
            case 5, 6 -> {
                String text = " - tested";
                yield "purple" + text;
                yield "black";
    return result;

4. JEP 355: Text Blocks (Preview)

This JEP introduces text blocks, multi-line string literals.

Before Java 13:

String html ="<html>\n" +
              "   <body>\n" +
              "      Hello Javalopment\n" +
              "   </body>\n" +

With Java 13:

String html =  """
                        Hello Javalopment



Java EE Technology Stack

Dependency Injection In Java and CDI

Proxy Server