What’s new in Java 15
JDK 15 is the open-source reference implementation of version 15 of the Java SE Platform, as specified by JSR 390 in the Java Community Process.

JDK 15 reached General Availability on 15 September 2020. Production-ready binaries under the GPL are available from Oracle; binaries from other vendors will follow shortly.

The features and schedule of this release were proposed and tracked via the JEP Process, as amended by the JEP 2.0 proposal. The release was produced using the JDK Release Process (JEP 3).

Removals

Solaris and SPARC Ports

The source code and build support for the Solaris/SPARC, Solaris/x64, and Linux/SPARC ports were removed. These ports were deprecated for removal in JDK 14 with the express intent to remove them in a future release.

Nashorn Javascript Engine

The Nashorn JavaScript script engine and APIs, and the jjs tool were removed. The engine, the APIs, and the tool were deprecated for removal in Java 11 with the express intent to remove them in a future release.

Deprecations

RMI Activation

RMI Activation mechanism is deprecated. RMI Activation is an obsolete part of RMI that has been optional since Java 8. No other part of RMI will be deprecated.

What's new

Helpful NullPointerExceptions

Usability of NullPointerException has been improved. Messages generated by the JVM are describing precisely which variable was null .

Before Java 15

In Java 15

Text Blocks

A text block is a multi-line string literal that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over the format when desired.

Before Java 15

In Java 15

JVM Improvements

ZGC Garbage Collector

The Z Garbage Collector (ZGC) is a scalable low latency garbage collector. ZGC performs all expensive work concurrently, without stopping the execution of application threads for more than 10ms, which makes it suitable for applications that require low latency and/or use a very large heap (multi-terabytes).

At a glance, ZGC is:

Concurrent

Region-based

Compacting

NUMA-aware

Using colored pointers

Using load barriers

At its core, ZGC is a concurrent garbage collector, meaning all heavy lifting work is done while Java threads continue to execute. This greatly limits the impact garbage collection will have on your application’s response time.

Beginning from a Java 15 it is a production-ready GC.

Hidden Classes

Classes that cannot be used directly by the bytecode of other classes. Hidden classes are intended for use by frameworks that generate classes at run time and use them indirectly, via reflection. A hidden class may be defined as a member of an access control nest and may be unloaded independently of other classes.

EdDSA

EdDSA is a modern elliptic curve signature scheme that has several advantages over the existing signature schemes in the JDK.

DatagramSocket API

Replacement for the underlying implementations of the java.net.DatagramSocket and java.net.MulticastSocket APIs with simpler and more modern implementations that are easy to maintain and debug. The new implementations are easy to adapt to work with virtual threads, currently being explored in Project Loom.

Preview Features

A preview feature is a new feature whose design, specification, and implementation are complete, but which is not permanent, which means that the feature may exist in a different form or not at all in future JDK releases.

Pattern Matching

Pattern matching involves testing whether an object has a particular structure, then extracting data from that object if there’s a match. You can already do this with Java; however, pattern matching introduces new language enhancements that enable you to conditionally extract data from objects with code that’s more concise and robust.

More specifically, JDK 15 extends the instanceof operator: you can specify a binding variable; if the result of the instanceof operator is true , then the object being tested is assigned to the binding variable.

Records

Introduced as a preview feature in Java SE 14, record classes help to model plain data aggregates with less ceremony than normal classes. Java SE 15 extends the preview feature with additional capabilities such as local record classes.

A record class declares a sequence of fields, and then the appropriate accessors, constructors, equals , hashCode , and toString methods are created automatically. The fields are final because the class is intended to serve as a simple "data carrier". It means that records are Immutable.

Sealed Classes

Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them.

One of the primary purposes of inheritance is code reuse: When you want to create a new class and there is already a class that includes some of the code that you want, you can derive your new class from the existing class. In doing this, you can reuse the fields and methods of the existing class without having to write (and debug) them yourself.

Before Sealed Classes

With Sealed Classes

Conclusion

In this article, we have checked what was added and removed in Java 15. And how all the changes that were delivered with a Java 15 can improve your existing projects.
['Dmytro Timchenko']
['Technology', 'Software Engineering', 'Programming', 'Software Development', 'Java']