Release of Java SE 20

After six months of development, Oracle has released the Java SE 20 platform (Java Platform, Standard Edition 20), with the open-source project OpenJDK serving as its reference implementation. Except for the removal of some deprecated features, Java SE 20 maintains backward compatibility with previous versions of the Java platform — most previously written Java projects will run without modifications on the new version. Installable builds of Java SE 20 (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 20, developed as part of the OpenJDK project, is fully open under the GPLv2 license with GNU ClassPath exceptions that permit dynamic linking with commercial products.

Java SE 20 is classified as a regular support release, with updates to be issued until the next release. For long-term support (LTS), Java SE 17 should be used, with updates provided until 2029. It’s worth noting that starting from Java 10, the project transitioned to a new development process featuring a shorter release cycle. New functionality is now developed in a continuously updated master branch, which incorporates ready changes and from which branches for stabilizing new releases are created every six months.

Notable new features in Java 20 include:

  • Proposed preliminary support for Scoped Values, allowing immutable data to be shared across threads and efficiently exchanged between child threads (values are inherited). Scoped Values are evolving to replace thread-local variables and are more efficient when using a very large number of virtual threads (thousands or millions of threads). The main difference between Scoped Values and thread-local variables is that the former are written once, cannot be changed afterwards, and remain accessible only during the execution of the thread. class Server { final static ScopedValue CURRENT_USER = new ScopedValue(); void serve(Request request, Response response) { var level = (request.isAuthorized() ? ADMIN : GUEST); var user = new User(level); ScopedValue.where(CURRENT_USER, user) .run(() -> Application.handle(request, response)); } } class DatabaseManager { DBConnection open() { var user = Server.CURRENT_USER.get(); if (!user.canOpen()) throw new InvalidUserException(); return new DBConnection(…); } }
  • The second preliminary implementation of record patterns has been added, extending the pattern matching capabilities introduced in Java 16 for parsing values of record-type classes. For example: record Point(int x, int y) {} static void printSum(Object obj) { if (obj instanceof Point p) { int x = p.x(); int y = p.y(); System.out.println(x + y); } }
  • The fourth preliminary implementation of pattern matching in switch expressions has been added, allowing case labels to use not just exact values but flexible patterns covering a series of values, which previously required cumbersome if...else chains. static String formatterPatternSwitch(Object obj) { return switch (obj) { 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(); }; }
  • The second preliminary implementation of the Foreign Function & Memory (FFM) API has been added, allowing Java programs to interact with external code and data through calls to functions from external libraries and access to memory outside of the JVM.
  • The second preliminary implementation of virtual threads has been added, representing lightweight threads that significantly simplify the writing and maintenance of high-performance multithreaded applications.
  • The second version of the experimental API for structured concurrency has been added, simplifying the development of multithreaded applications by handling multiple tasks running in different threads as a single block.
  • The fifth preliminary implementation of the Vector API has been added, providing features for vector computations that are executed using vector instructions of x86_64 and AArch64 processors, 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 allows for explicit control over vectorization for parallel data processing.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster