After six months of development, Oracle has released the Java SE 17 platform (Java Platform, Standard Edition 17), with the OpenJDK project serving as its reference implementation. Aside from the removal of some deprecated features, Java SE 17 maintains backward compatibility with previous Java platform releases — most existing Java projects will run without modifications on the new version. Installable builds of Java SE 17 (JDK, JRE, and Server JRE) are available for Linux (x86_64, AArch64), Windows (x86_64), and macOS (x86_64, AArch64). The reference implementation of Java 17 developed under OpenJDK is fully open source under the GPLv2 license with exceptions from GNU ClassPath, allowing dynamic linking with commercial products.
Java SE 17 is classified as a long-term support (LTS) release, with updates scheduled until 2029. Updates for the previous interim release, Java 16, have been discontinued. The previous LTS branch, Java 11, will be supported until 2026. The next LTS release is planned for September 2024. It is important to note that starting from Java 10, the project transitioned to a new development process that features a shorter cycle for creating new releases. New functionality is now developed in a continuously updated master branch, which includes completed changes and branches off every six months for stabilization of new releases.
New features in Java 17 include:
- An experimental implementation of pattern matching in switch expressions allows the use of flexible patterns in case labels instead of exact values, which previously required cumbersome if...else chains. Additionally, NULL value handling is included within switch. Object o = 123L; String formatted = switch (o) { case Integer i -> String.format("int %d", i); case Long l -> String.format("long %d", l); case Double d -> String.format("double %f", d); case String s -> String.format("String %s", s); default -> o.toString(); };
- Support for sealed classes and interfaces has been stabilized. These cannot be used by other classes and interfaces for inheritance, extension, or overriding implementations. Sealed classes also provide a more declarative way to restrict the use of a superclass than access modifiers, based on explicitly listing subclasses allowed for extension. package com.example.geometry; public sealed class Shape permits com.example.polar.Circle, com.example.quad.Rectangle, com.example.quad.simple.Square {…}
- A second preview implementation of the Vector API has been proposed, providing functionalities for vector computations that are performed using x86_64 and AArch64 processor vector instructions, allowing operations to be applied simultaneously to multiple values (SIMD). Unlike the autovectorization capabilities for scalar operations provided by the HotSpot JIT compiler, the new API gives explicit control over vectorization for parallel data processing.
- A preview implementation of the Foreign Function & Memory API has been added, allowing applications to interact with code and data outside of the Java runtime. The new API enables efficient calls to functions not executed in the JVM and access to memory not managed by the JVM. For instance, it is possible to call functions from external shared libraries and access process data without using JNI.
- The rendering engine for macOS, which supports the Java 2D API that is utilized in the Swing API, has been adapted for the Metal graphics API. By default, OpenGL is still used on the macOS platform, and enabling Metal support requires setting the parameter “-Dsun.java2d.metal=true” and having at least macOS release 10.14.x.
- A port for the macOS/AArch64 platform (Apple computers based on the new Apple M1 chips) has been added. A feature of the port is support for the W^X (Write XOR Execute) memory protection mechanism, whereby memory pages cannot be simultaneously accessible for writing and executing. (Code can only be executed after write access is restricted, and writing to a memory page is only possible after execution access is restricted.)
- Strict floating-point semantics for floating-point expressions has been reinstated. The support for the 'default' semantics, which included simplifications for operation on very old x87 floating-point coprocessors, was discontinued starting with the release of Java 1.2 (the need for additional semantics has vanished since the introduction of SSE2 instructions).
- New types of interfaces to pseudorandom number generators have been implemented, along with additional algorithms for better random number generation. Applications are now able to select the algorithm for pseudorandom number generation. Support for generating streams of random objects has been improved.
- Mandatory strict encapsulation of all internal JDK elements has been implemented, except for critical APIs like sun.misc.Unsafe. Strict encapsulation blocks attempts to access internal classes, methods, and fields from code. Previously, strict encapsulation could be disabled with the option '--illegal-access=permit', but this is now deprecated. Applications requiring access to internal classes, methods, and fields must explicitly define them using the '--add-opens' option or the Add-Opens attribute in the manifest file.
- Applications are provided with the capability to define filters for data deserialization, which can depend on context and be chosen dynamically in relation to specific deserialization operations. The specified filters apply across the entire virtual machine (JVM-wide), meaning they cover not only the application itself but also third-party libraries used within the application.
- In Swing, the method javax.swing.filechooser.FileSystemView.getSystemIcon has been added for loading large-sized icons, enhancing interface rendering on high pixel density (HighDPI) screens.
- The API java.net.DatagramSocket has been enhanced to support connections to multicast groups without the need for a separate API java.net.MulticastSocket.
- The IGV (Ideal Graph Visualizer) utility has been upgraded, providing interactive visualization of the intermediate representation of code in the HotSpot VM C2 JIT compiler.
- In JavaDoc, similar to the javac compiler, when an error is reported, the problematic line number in the source file and the location of the error are now indicated.
- The property native.encoding has been added, reflecting the name of the system character encoding (UTF-8, koi8-r, cp1251, etc.).
- The interface java.time.InstantSource has been introduced, allowing manipulation of time without being tied to a time zone.
- The API java.util.HexFormat has been added for converting to and from hexadecimal representation.
- A blackhole mode has been added to the compiler, disabling dead-code elimination, which can be used for performance testing.
- An option '-Xlog:async' has been added to the Runtime for recording logs in asynchronous mode.
- TLS 1.3 is now enabled by default for establishing secure connections (previously TLS 1.2 was used).
- The previously declared deprecated API Applet (java.applet.Applet*, javax.swing.JApplet), which was used to run Java applications in browsers, has been moved to the category of planned removals (no longer relevant after the discontinuation of Java plugin support for browsers).
- The Security Manager, which has long been outdated and became unnecessary after browser plugin support was discontinued, has been moved to the category of planned removals.
- The RMI Activation mechanism, which has been obsolete and was relegated to an option since Java 8, has been removed as it is rarely used in modern practice.
- The experimental compiler in the SDK that supported JIT (just-in-time) for dynamic Java code compilation for the HotSpot JVM, as well as AOT (ahead-of-time) compilation of classes to machine code before the virtual machine start, has been removed. The compiler was written in Java and based on the Graal project efforts. It has been noted that maintaining the compiler requires significant labor costs that do not justify themselves due to lack of interest from developers.
Source: opennet.ru
