3. Features / What’s New ?
338: Vector API (Incubator)
347: Enable C++14 Language Features
357: Migrate from Mercurial to Git
369: Migrate to GitHub
376: ZGC: Concurrent Thread-Stack Processing
380: Unix-Domain Socket Channels
386: Alpine Linux Port
387: Elastic Metaspace
388: Windows/AArch64 Port
389: Foreign Linker API (Incubator)
390: Warnings for Value-Based Classes
392: Packaging Tool
393: Foreign-Memory Access API (Third Incubator)
394: Pattern Matching for instanceof
395: Records
396: Strongly Encapsulate JDK Internals by Default
397: Sealed Classes (Second Preview)
Download:
- Open JDK
- Oracle JDK
4. Language Features
• JEP 394 Pattern Matching for instanceof : Pattern Matching enhances
the Java programming language with pattern matching for
the instanceof operator. It allows conditional extraction of
components from objects, to be expressed more concisely and safely.
if (obj instanceof String) {
String s = (String) obj; // no need to cast
}
5. Language Features
• JEP 395 Records : Records provide a compact syntax for declaring classes
which are transparent holders for shallowly immutable data. This will
significantly reduce the verbosity of these classes and improve code
readability and maintainability.
public record Vehicle(String brand, String licensePlate) {
public Vehicle(String brand) {
this(brand, null);
}
}
6. JVM /improvements
• JEP 376 ZGC Concurrent Thread Processing : Moves ZGC thread-stack
processing from safepoints to a concurrent phase, allows sub-millisecond
pauses inside GC safepoints, even on large heaps. Removing the final
source of latency in the ZGC garbage collector will greatly improve
performance and efficiency of applications in this and subsquent releases.
• JEP 387 Elastic Metaspace : The new scheme allocates metaspace memory
in smaller chunks, reduces class-loader overhead and fragmentation. It
improves elasticity by returning unused metaspace memory to the
operating system, which leads to greater application performance and
decreases memory utilization.
7. New tools & libraries
• JEP 380 Unix-Domain Socket Channels : This feature adds Unix-domain (AF_UNIX) socket
support to the socket channel and server-socket channel APIs in the java.nio.channels
package. It extends the inherited channel mechanism to support Unix-domain socket
channels and server socket channels. Unix-domain sockets are used for inter-process
communication (IPC) on the same host. They are similar to TCP/IP sockets in most
respects, except that they are addressed by filesystem path names rather than Internet
Protocol (IP) addresses and port numbers. For local, inter-process communication, Unix-
domain sockets are both more secure and more efficient than TCP/IP loopback
connections.
• JEP 392 Packaging Tool jdk.jpackage : This feature was first introduced as an incubator
module in Java 14. This tool allows for packaging self-contained Java
applications. It supports native packaging formats to give end users a natural installation
experience. These formats include msi and exe on Windows, pkg and dmg on macOS,
and deb and rpm on Linux. It also allows launch-time parameters to be specified at
packaging time and can be invoked directly, from the command line, or
programmatically, via the ToolProvider API. This will improve the end-user experience
when installing applications and simplify deployments using the “app store” model.
8. Futureproofing Your Work
• JEP 390 Warning for Value-Based Classes @ValueBased : This feature designates the
primitive wrapper classes (java.lang.Integer, java.lang.Double, etc) as value-based (similar
to java.util.Optional and java.time.LocalDateTime) and add forRemoval to their
constructors, which are deprecated since JDK 9, prompting new warnings. It provides
warnings about improper attempts to synchronize on instances of any value-based
classes in the Java Platform.
• JEP 396 Strongly Encapsulate JDK Internals by default: This feature strongly
encapsulates all internal elements of the JDK by default, except for critical internal APIs
such as sun.misc.Unsafe. Code successfully compiled with earlier releases that accesses
internal APIs of the JDK may no longer work by default. This change aims to encourage
developers to migrate from using internal elements to using standard APIs, so that both
they and their users can upgrade without fuss to future Java releases. Strong
encapsulation is controlled by the launcher option -–illegal-access, for JDK 9 until JDK 15
defaults to warning, and starting with JDK 16 defaults to deny. It is still possible (for now)
to relax encapsulation of all packages with a single command-line option, in the future
only opening specific packages with –add-opens will work.
9. Incubator and Preview Features
• JEP 338 Vector API (Incubator) : This incubator API provides an initial iteration of an API
to express vector computations that reliably compile at runtime to optimal vector
hardware instructions on supported CPU architectures and thus achieve superior
performance to equivalent scalar computations. It allows taking advantage of the Single
Instruction Multiple Data (SIMD) instructions available on most modern CPUs. Although
HotSpot supports auto-vectorization, the set of transformable scalar operations is limited
and fragile to changes in the code. This API will allow developers to easily write portable
and performant vector algorithms in Java.
• JEP 389 Foreign Linker API (Incubator) : This incubator API offers statically-typed, pure-
Java access to native code. This API will considerably simplify the otherwise convoluted
and error-prone process of binding to a native library. Java has supported native method
calls via the Java Native Interface (JNI) since Java 1.1 but it is hard and brittle. Java
developers should be able to (mostly) just use any native library that is deemed useful
for a particular task. It also provides foreign-function support without the need for any
intervening JNI glue code.
10. Incubator and Preview Features
• JEP 393 Foreign Memory Access API (3rd Incubator) : First introduced as an
incubator API in Java 14 and again in Java 15, this API allows Java programs to
safely and efficiently operate on various kinds of foreign memory (e.g., native
memory, persistent memory, managed heap memory, etc.). It also provides the
foundation for the Foreign Linker API.
• JEP 397 Sealed Classes (2nd Preview) : This preview feature restricts which other
classes or interfaces may extend or implement them. It allows the author of a
class or interface to control which code is responsible for implementing it. Also, It
provides a more declarative way than access modifiers to restrict the use of a
superclass. And it supports future directions in pattern matching by underpinning
the exhaustive analysis of patterns.
public sealed class Vehicle permits Car, Truck, Motorcycle {...}
11. Improvements for OpenJDK Contributors
• JEP 347: Enable C++14 Language Features (in the JDK source code) – Allows the use of C++14
language features in JDK C++ source code, and gives specific guidance about which of those
features may be used in HotSpot code.
• JEP 357: Migrate from Mercurial to Git – Migrates the OpenJDK Community’s source code
repositories from Mercurial (hg) to Git.
• JEP 369: Migrate to GitHub – Hosts the OpenJDK Community’s Git repositories on GitHub.
https://github.com/openjdk
• JEP 386: Alpine Linux Port – Ports the JDK to Alpine Linux, and to other Linux distributions that
use musl as their primary C library, on both the x64 and AArch64 architectures.
• JEP 388: Windows/Aarch64 Port – Ports the JDK to Windows/AArch64.