Java 14 – Oracle trying to Revive Java with Astounding Features

Java has been one of the most popular programming languages in the world and has been consistently ranked at first position in the TIOBE index. Java always comes up with its special and exciting features with its new release.

Java has been already very popular language but the Oracle community never gives up on working on it to make it more popular and efficient so that users may not encounter any performance bugs or issues. So to make it more efficient and powerful, the Oracle has come up with Java 14 with more advanced features.

Java has celebrated its 24th anniversary in 2020 and till date there are 13 versions launched. And, the latest version Java 14 has been launched by Oracle Community on March 17, 2020. Oracle now offers every Java developer and enterprises to download it from its official website.

Being a Java lover, you must be excited to know about  the features of Java 14. Java 14 has been released with many significant Java Enhancement Proposals (JEPs). In this article, we have come up with an article to acquaint you with its latest features of Java 14.

Java 14 is supported by three main integrated development environments, including JetBrains IDEA, Apache NetBeans, and Eclipse IDE.

The 16 JEPs in JDK 14 include:

  1. Pattern Matching for instanceof (Preview)
  2. Packaging Tool (Incubator)
  3. NUMA-Aware Memory Allocation for G1
  4. JFR Event Streaming
  5. Non-Volatile Mapped Byte Buffers
  6. Helpful NullPointerExceptions
  7. Records (Preview)
  8. Switch Expressions (Standard)
  9. Deprecate the Solaris and SPARC Ports
  10. Remove the Concurrent Mark Sweep (CMS) Garbage Collector
  11. ZGC on macOS
  12. ZGC on Windows
  13. Deprecate the ParallelScavenge + SerialOld GC Combination
  14. Remove the Pack200 Tools and API
  15. Text Blocks (Second Preview)
  16. Foreign-Memory Access API (Incubator)

Keeping you updated with latest technology trends, Join DataFlair on Telegram

Features of Java 14

Java 14 Features

Now we will discuss each of the feature in detail –

1. Pattern Matching for instanceof

We already know the use of instanceof operator which is used to check whether the given object matches the reference type or not. Pattern matching for instanceof operator allows for its efficient use and  decreases the necessity of type conversions in Java applications.

Enhance your knowledge by exploring Applications of Java in detail with Dataflair.

2. Helpful NullPointerExceptions

With Java 14 release, there are some improvements in NullPointer Exceptions in Java. The necessary information will be shown to the user by the JVM. For example, if there occurs an error which generates a null value, so the JVM should display the variable that results in zero value. This helps in easy catching and recovering the error.

3. Switch Expressions

Java 14 comes with an extended version of switch statement. If there are multiple cases that results to the same output then we write each case with a comma-separated values followed by a -> arrow to return a value.

Example:

switch(month)

case January, February, -> System.out.println(“Winter”);

case March, April, May, June ->  System.out.println(“Summer”);

case June, July, August ->  System.out.println(“Rainy”);

4. Packaging Tools

The Packaging tool feature of Java 14 provides a way to ease the process of application installation.The jpackage tool is used to bundle a Java application into a platform-specific package. Java 14 supports following platform-specific formats:

For Linux: deb and rpm

For MacOS: pkg and dmg

For Windows: msi and exe

Do you know – How Packaging helps in Java?

5. Records

Java 14 release came up with the  records as a preview feature. We can now compact the class declaration syntax with records. Users face a problem to write the repetitive codes; to remove this problem Java 14 has introduced the feature of records. For example:

Without records:

class Rectangle

{
    public final int length;
    public final int breadth;
    public Rectangle(int length, int breadth)
    {
        this.length = length;
        this.breadth=breadth;


    }
}

With Records:

record Rectangle(int length, int breadth)

 6. NUMA-Aware Memory Allocation for G1

Numa (Non-Uniform Memory Access) is an architecture of sharing memory locally which eventually increases the performance of the system. But in NUMA memory architecture there is a small amount of memory stored in a processor. Java 14 proves to be a boon to us that provides an advanced feature to improve the performance of G1 Garbage collector on the large machines.

7. Non-Volatile Mapped Byte Buffers

We know that a Non-volatile memory is a memory area where there would not be any loss of data even after the power goes off. We also call such memory as persistent memory.

With the release of Java 14, there is an enhancement in MappedByteBuffer class that comes with an increased ability to gain access to non-volatile storage in the computer memory.

8. JFR Event Streaming

Java 14 now provides an API through which the data in the JFR ( Java Flight Recorder ) can continuously monitor the in-process and out-process applications. JFR is now available freely and has become the part of OpenJDK. is now part of the OpenJDK and therefore freely available.

The module jdk.jfr present in the package jdk.jfr.consumer enhances the ability to asynchronously subscribe to the events.

9. ZGC on macOS

ZGC (Z Garbage Collector) gets introduced with the Java 14 release that becomes an option for macOS users. Java 14 also provides the facility in which the Garbage collector releases the unused memory from the system.

10. ZGC on Windows

This feature is the same feature as the ZGC (Z Garbage Collector) for macOS, the only difference being that it provides the ZGC for Windows users. The goal is to use the feature of ZGC being platform-independent so that it can be used on any platform. But, there are some restrictions to use it with the older versions of Windows.

11. Deprecate the Solaris and SPARC Ports

According to this update, the Oracle Community wishes to get rid of the ports of outdated Operating systems like Solaris, Sparc etc. Java 14 has marked them deprecated so that they can be completely removed in the further updates of Java. Deprecating these ports, there will be a clear way to develop the new features to move the platform in the forward direction.

12. Remove the Concurrent Mark Sweep (CMS) Garbage Collector

As proposed by Thomas Schatzl, Java 14 aims to remove the CMS (Concurrent Mark Sweep) Garbage Collector from Java. This garbage collector was already marked as deprecated with Java 9. And, in Java 14, it has been completely removed. However, the update does not aim to remove the  CMS Garbage collector from the Java versions that completely rely on it.

13. Remove the Pack200 Tools and API

Java 14 officially proposes the Pack200 tools and API present in the java.util.jar package to be removed from Java. The Pack200 is a tool to compress the JAR (Java Archives) files. This API was already marked as obsolete from Java 11.

HOLD ON! It’s the right time to take a quick sneak peak of Java JAR Files with Dataflair.

14. Text Blocks (Second Preview)

Java 14 introduces the second preview for the text blocks. The first preview came since Java 13. Text blocks are introduced so as to allow the programmers to easily create multi-line strings.

With the second preview of text blocks, there is an introduction to  2 new escape sequences which are: \<line-terminator> and \s. These escape sequences allow a fine-grained control over the processing of whitespaces and newlines.

15. Deprecate the ParallelScavenge + SerialOld GC Combination

With Java 14 there is a proposal to deprecate the combination of two garbage collectors :ParallelScavenge GC and SerialOld GC. This proposal is because there are a very few Java users who use this combination of Garbage Collectors. Moreover, this combination requires a considerable effort and cost to keep it updated and its of no use if they are not used by the majority of users. Therefore they have been marked as deprecated since Java14.

16. Foreign-Memory Access API (Incubator)

There are many libraries and applications  like Nettys ByteBuf API, mamchaced, mapDB, Ignite, etc that access the foriegn memory. There is no such API in Java to provide access to the foriegn memory. Therefore, with Java 14 there is a proposal to implement a suitable Java API that can help Java applications to easily access the foriegn memory.

Summary

In this article, we got familiar with the release of Java 14. It was released on March 17,2020 and came up with a number of updates and enhancements to ease the effort and performance of the Java applications and also deprecates many outdated features and plans to remove them with the further releases.

There is an introduction to many new things while there are some interesting changes and enhancements in the existing features of Java.  This article will surely help you to get friendly with the release and features of Java 14.

Thank you for reading our article. Do  share our article on Social Media.

Keep Learning 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.