Java 16

Java 16 – Overview

Java 16 introduced few language specific features under preview mode to Java and multiple JVM enhancements. This is an introductory tutorial that explains the basic-to-advanced features of Java 16 and their usage in a simple and intuitive way.

This tutorial is designed for Java programmers who would like to understand the Java 16 new features and actual usage.

Prerequisites

Before proceeding with this tutorial, you should have a good understanding of Java programming language.

Java 16 is a major feature release and it has brought many JVM specific changes and language specific changes to JAVA. It followed the Java release cadence introduced Java 10 onwards and it was released on Mar 2021, just six months after Java 15 release.

Java 16 is a non-LTS release.

New Features

Following are the major new features which are introduced in Java 16.

  1. JEP 338 – Vector API (Incubator) − New Vector APIs introduced allowing developers to perform the vector operations explicitly.
  2. JEP 347 – Enable C++14 Language Features − C++ 14 features can be used in c++ source code with the JDK 16.
  3. JEP 357, JEP 369 – Migrate from Mercurial to Git/GitHub − OpenJDK source code is moved from mercurial to Git/GitHub
  4. JEP 376 – ZGC – Concurrent Thread-Stack Processing − Z Garbage Collector improved by moving its thread-stack processing from safepoints to concurrent phase.
  5. JEP 380 – Unix-Domain Socket Channels − SocketChannel and ServerSocketChannel now supports Unix Domain sockets.
  6. JEP 386 – Alpine Linux Port − Now JDK is available for Alpine Linux and other Linux distributions which use musl implementation.
  7. JEP 387 – Elastic Metaspace − Metaspace memory management is improved by returning unused HotSpot class-metadata or metaspace memory to the operating system quickly, reduces the metaspace footprint, and simplify the metaspace code.
  8. JEP 388 – Windows/AArch64 Port − Now JDK can run on AArch64, on ARM hardware server or ARM based laptops.
  9. JEP 389 – Foreign Linker API (Incubator) − Java code can be called by C/C++ or vice versa using new API replacing the JNI.
  10. JEP 390 – Warnings for Value-Based Classes − Warnings are raised in case of value-based classes are synchronised using synchronize.
  11. JEP 392 – Packaging Tool − jpackage is now a standard instead of incubator feature.
  12. JEP 393 – Foreign-Memory Access API (Third Incubator) − Minor enhancements to Foreign Memory Access API.
  13. JEP 394 – Pattern Matching for instanceof − Pattern matching for instanceOf is now a standard feature.
  14. JEP 395 – Records − records are now a standard feature.
  15. JEP 396 – Strongly Encapsulate JDK Internals by Default − default mode of –illegal-access option is now deny. Earlier it was permit.
  16. JEP 397 – Sealed Classes (Second Preview) − Minor enhancements to sealed classes.

Java 16 enhanced numerous APIs with new methods and options. We’ll see these changes in next chapters.

About the Author: Elavarasan PK

Technical Specialist, Intersoft Data Labs