Java SE 14 Release

After six months of development, Oracle has announced released the platform Java SE 14 (Java Platform, Standard Edition 14), which uses the open-source project OpenJDK as its reference implementation. Java SE 14 maintains backward compatibility with previous versions of the Java platform, and all previously written Java projects will work without changes when run on the new version. Installable builds of Java SE 14 (JDK, JRE, and Server JRE) are prepared for Linux (x86_64), Windows, and macOS. The reference implementation developed under the OpenJDK project Java 14 is fully open under the GPLv2 license with exceptions from GNU ClassPath, allowing dynamic linking with commercial products.

Java SE 14 is classified as a release with a normal support period, updates for which will be released until the next release. For long-term support (LTS), Java SE 11 should be used, with updates released until 2026. The previous LTS branch, Java 8, will be supported until December 2020. The next LTS release is scheduled for September 2021. It should be noted that starting from Java 10, the project has switched to a new development process, implying a shorter cycle for new releases. New features are now developed in a continuously updated master branch, which includes ready changes and from which branches for stabilizing new releases are forked every six months.

From new features Java 14 in note:

  • Experimental support has been added for matching with a pattern in the 'instanceof' operator, which allows immediately defining a local variable for referring to the checked value. For example, you can write 'if (obj instanceof String s && s.length() > 5) {.. s.contains(..) ..}' without explicitly defining 'String s = (String) obj'.

    Previously:

    if (obj instanceof Group) {
    Group group = (Group) obj;
    var entries = group.getEntries();
    }

    Now it can be done without defining 'Group group = (Group) obj':

    if (obj instanceof Group group) {
    var entries = group.getEntries();
    }

  • Added experimental support for the new keyword 'record', providing a compact form for defining classes that allows avoiding explicit definitions of various low-level methods, such as equals(), hashCode(), and toString(), when the data is stored only in fields, the behavior of which does not change. When the class uses default implementations of the methods equals(), hashCode(), and toString(), it can do without their explicit definitions:

    public record BankTransaction(LocalDate date,
    double amount,
    String description) {}

    This declaration will lead to the automatic addition of implementations for the methods equals(), hashCode(), and toString(), along with the constructor and methods that manage data changes (getter).

  • Standardized and included by default support for the new form of 'switch' expressions, which does not require specifying the 'break' statement, allowing the merging of duplicate labels and allowing use not only in the form of a statement but also as an expression.

    var log = switch (event) {
    case PLAY -> "User has triggered the play button";
    case STOP, PAUSE -> "User needs a break";
    default -> {
    String message = event.toString();
    LocalDateTime now = LocalDateTime.now();
    yield "Unknown event " + message +
    " logged on " + now;
    }
    };

  • Extended experimental support for text blocks — a new form of string literals that allow you to include multi-line text data in the source code without escaping characters and preserving the original formatting of the text in the block. The block is enclosed in triple double quotes. In Java 14, text blocks implemented support for the escape sequence "\s" to denote a single space and "\" to concatenate with the next line (ignoring the newline when you want to output a very long string). For example, instead of the code

    String html = "" +
    "\n\t" + "" +
    "\n\t\t" + "

    \"Java 14 is here!\"

    " +
    "\n\t" + "" +
    "\n" + "";

    you can specify:

    String html = """
    <HTML>

    "Java 15\

    "Java 14\
    is here!"


    API Legacy DatagramSocket. The old implementations of java.net.DatagramSocket and java.net.MulticastSocket have been replaced with a modern implementation that is easier to debug and maintain, as well as compatible with virtual threads being developed under the Loom project.
    """;

  • Increased diagnostics information when exceptions occur NullPointerException. Previously, the error message only referred to the line number, but now it details which method caused the exception. Enhanced diagnostics can only be enabled when running with the flag "-XX:+ShowCodeDetailsInExceptionMessages". For example, with this flag, an exception on the line

    var name = user.getLocation().getCity().getName();

    will produce the output message

    Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Location.getCity()"
    because the return value of "User.getLocation()" is null
    at NullPointerExample.main(NullPointerExample.java:5):5)

    which helps to understand that the method Location.getCity() was not invoked, but User.getLocation() returned a null value.

  • Implemented A preliminary version of the jpackage utility, allowing the creation of packages for self-contained Java applications. The utility is based on javapackager from JavaFX and enables package formation in formats native to various platforms (msi and exe for Windows, pkg and dmg for macOS, deb and rpm for Linux). Packages include all necessary dependencies.
  • G1 Garbage Collector implemented a new memory management mechanism that takes into account the specifics of operation on large systems using architecture NUMA. The new memory allocator is activated with the flag “+XX:+UseNUMA” and can significantly improve performance on NUMA systems.
  • Added API for on-the-fly monitoring of JFR (JDK Flight Recorder) events, for example, for continuous monitoring.
  • Added jdk.nio.mapmode module, offering new modes (READ_ONLY_SYNC, WRITE_ONLY_SYNC) for creating mapped byte buffers (MappedByteBuffer) that reference non-volatile memory (NVM).
  • Implemented A preliminary version of the Foreign-Memory Access API, enabling Java applications to safely and efficiently access memory areas outside the Java heap by manipulating new abstractions MemorySegment, MemoryAddress, and MemoryLayout.
  • Declared deprecated ports for Solaris OS and SPARC processors (Solaris/SPARC, Solaris/x64, and Linux/SPARC) with the intention to remove these ports in the future. Classifying these ports as deprecated will allow the community to accelerate the development of new features in OpenJDK without spending time on maintaining Solaris and SPARC-specific peculiarities.
  • Removed the CMS (Concurrent Mark Sweep) garbage collector, which was marked as deprecated two years ago and has not been supported since (the G1 garbage collector has long replaced CMS). Additionally, announced the use of the combination of garbage collection algorithms ParallelScavenge and SerialOld (running with the options “-XX:+UseParallelGC -XX:-UseParallelOldGC”) is deprecated.
  • Experimental support for the ZGC (Z Garbage Collector) on macOS and Windows platforms has been provided (previously supported only on Linux). ZGC operates in a passive mode, minimizing pauses due to garbage collection as much as possible (the stop time when using ZGC does not exceed 10 ms) and can work with both small and huge heaps, ranging from several hundred megabytes to many terabytes.
  • The following packages have been removed: tooling and API for compressing JAR files using the Pack200 algorithm.

Source: opennet.ru

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