What’s new in Java 17?

Let us review latest features in Java 17

Backend developer
Geek Culture

--

Photo by Nathan Dumlao on Unsplash

Oracle released its new Long Term Support (LTS) release of java : Release 17 on September 13th 2021. With this new release, Oracle introduced a new licensing terms and conditions as well under the so called “Oracle — No Fee Terms and Conditions (NFTC)”.

Java 17 is an LTS version. Other LTS JDKs are Java 8 and Java 11. LTS JDKs are released every three years where as non-LTS are released every six months. In comparison, LTS versions’ support lasts for several years, whereas the non-LTS JDKs’ support lasts only six months, ending when the next non-LTS is released.

Although Java 17 is a LTS version, there are no major updates. JEP 406 and JEP 409 are very useful and important for any java developer.

JEP 406 : Pattern Matching for Switch (Preview)

  • Expand the expressiveness and applicability of switch expressions by allowing patterns to appear in case labels.
  • Allow the historical null-hostility of switch to be relaxed when desired.
  • Introduced two new patterns : guarded and parenthesized patterns.

Before Java 17 :

Now after Java 17 enhancements, we can refactor the above code like this :

Guarded Pattern : Uses pattern && boolean expression for further refinement of the pattern.

JEP 409 : Sealed Classes

Enhance the java programming with sealed classes and interfaces. Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them.

  • Uses sealed modifier in declaration and the permits clause to specify classes that are allowed to extend sealed class.
  • The sub-class must be final, seal or non-sealed.

JEP 306 : Restore Always-Strict Floating Point Semantics

Make floating-point operations consistently strict

JEP 356 : Enhanced Pseudo-Random Number Generators

Provide new interface types and implementations for pseudo-random number generators(PRNGs) to make it easier to use various PRNG algorithms and to better support stream-based operations.

JEP 403 : Strongly Encapsulate JDK Internals

Strongly encapsulate all non-critical internal elements of the JDK.

JEP 412 : Foreign Function & Memory API (Incubator)

Introduce an API by which java programmers can interoperate with code and data outside of the java runtime.

JEP 414 : Vector API (Second Incubator)

Introduce an API to express vector computations that reliably compile at runtime to optimal vector instructions.

JEP 415 : Context-Specific Deserialization Filters

Allow applications to configure context-specific and dynamically-selected de-serialization filters.

JEP 382 : New macOS Rendering Pipeline

Changed java 2D macOS rendering pipeline (which is used in Swing for example) for macOS to use the Apple Metal API instead of the deprecated Apple OpenGL API.

JEP 398 : Deprecate the Applet API for Removal

Applet API will be removed. It was deprecated since JDK 9. Most browsers don’t support it anymore.

JEP 407 : Remove RMI Activation

Although RMI is still used, RMI activation mechanism is obsolete with the web technology of the latest decade.

JEP 410 : Remove the Experimental AOT and JIT Compiler

Remove the experimental java-based ahead-of-time (AOT) and just-in-time (JIT) compiler.

JEP 411 : Deprecate the Security Manager for Removal

Deprecate the Security Manager for removal in the future release. The Security Manager dates from java 1.0. It has not been the primary means of securing client-side of java code for many years.

Reference :

--

--