funkyfrogstock - Fotolia
Oracle's latest release of the Java language and platform, Java 14 -- also known as Oracle JDK14 -- brings a series of features focused on helping developers code faster and more efficiently.
The latest Java Development Kit (JDK) provides new developer-focused features including Java language support for switch expressions, new APIs for continuous monitoring of JDK Flight Recorder data, and extended availability of the low-latency Z Garbage Collector to macOS and Windows.
In addition, Java 14 includes three preview features that come out of the JDK Enhancement Proposals (JEP) process. These are Pattern Matching, or JEP 305; Records, or JEP 359; and Text Blocks, also known as JEP 368.
Java 12 introduced switch expressions in preview, and it is now standard in Java 14. This feature extends the Java switch statement so it can be used as either a statement or an expression. "Basically, we converted the switch statement into an expression and made it much simpler and more concise," said Aurelio Garcia-Ribeyro, Oracle's Sr. Director of Product Management, Java Platform.
Oracle will give developers a way to spot errors by continuously monitoring the JDK Flight Recorder, a tool integrated into the Java Virtual Machine for collecting diagnostic and profiling data about a running Java application.
Finally, the z Garbage Collector, also known as ZGC, is a scalable, low-latency garbage collector. Garbage collection is a form of automatic memory management that frees up memory that is no longer in use or needed by the application. Prior to the Windows and MacOS support introduced with Java 14, the z Garbage collector was available only on Linux/x64 platforms.
As for the preview features, Oracle has developed pattern matching for the Java "instanceof" operator. The instanceof operator is used to test if an object is of a given type. In turn, the introduction of Java Records cuts down on the verbosity of Java and provides a compact syntax for declaring classes.
"Records will eliminate a lot of the boilerplate that has historically been needed to create a class," Garcia-Ribeyro said.
Text Blocks, initially introduced in Java 13 as a preview, returns as an enhanced preview in Java 14. Text Blocks make it easy to express strings that span several lines of source code. It enhances the readability of strings in Java programs that denote code written in non-Java languages, Garcia-Ribeyro said.
Oracle needs to give Java developers the types of tools they need to evolve with the marketplace, said Bradley Shimmin, an analyst at Omdia in Longmeadow, Mass.
"When I look at what they're doing with Java 14, they're adding features that make the language more resilient, more performant and that make developers more productive in using the language," he said.
Oracle takes iterative approach to Java updates
Java 14 also includes a new Packaging Tool, introduced as an incubator feature, that provides a way for developers to package Java applications for distribution in platform-specific formats. This tool is introduced as an incubator module to get developer feedback as the tool nears finalization.
Among the more obscure features in this release are Non-Volatile Mapped Byte Buffers, which add a file mapping mode for the JDK when using non-volatile memory. Also, Helpful NullPointerExceptions improves the usability of NullPointerExceptions by describing precisely which variable was null. NullPointerExceptions are exceptions that occur when you try to use a reference that points to no location in memory as though it were referencing an object. And the Foreign-Memory Access API allows Java programs to safely access foreign memory outside of the Java heap. The Java heap is the amount of memory allocated to applications running in the JVM.
Java 14 is another new release of the language under the six-month cadence Oracle instituted more than two years ago. The purpose of the quicker cadence of releases is to get "more bite-size pieces that are easier to deploy and manage and that get the features to app developers in the enterprise to benefit from these new capabilities," said Manish Gupta, Oracle's Vice President of Marketing for Java and GraalVM.
Overall, Oracle wants to advance the Java language and platform to make it work well for new cloud computing applications as well as platforms such as mobile and IoT. In 2017, Oracle spun out enterprise Java, known as Java Enterprise Edition or JavaEE, to the Eclipse Foundation. Eclipse has since created a new enterprise Java specification called Jakarta EE.
"When I think about Java 14, what I'm seeing is that Oracle is not only staying true to what they promised back when they acquired Sun Microsystems, which was to do no harm to Java, but that they are trying to now evolve Java in such a way that it can remain relevant into the future," Shimmin said.