Java 20 (JDK) released and here is what is new and deprecated and deleted


Java JDK 20 Released

Oracle just released Java JDK 20 (not an LTS version) on 21 March 2023 which is the 11th release as a part of a six-month release cadence.

JDK 20 is now available for all developers, end-users, and enterprises and can be downloaded for Windows, Linux, and macOS from the official Oracle Java Download page

https://www.oracle.com/java/technologies/downloads/
Linux:
Arm 64 Compressed Archive: https://download.oracle.com/java/20/latest/jdk-20_linux-aarch64_bin.tar.gz
Arm 64 RPM Package: https://download.oracle.com/java/20/latest/jdk-20_linux-aarch64_bin.rpm
x64 Compressed Archive: https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar.gz
x64 Debian Package: https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.deb
x64 RPM Package: https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.rpm

macOS:
Arm 64 Compressed Archive: https://download.oracle.com/java/20/latest/jdk-20_macos-aarch64_bin.tar.gz
Arm 64 DMG Installer: https://download.oracle.com/java/20/latest/jdk-20_macos-aarch64_bin.dmg
x64 Compressed Archive: https://download.oracle.com/java/20/latest/jdk-20_macos-x64_bin.tar.gz
x64 DMG Installer: https://download.oracle.com/java/20/latest/jdk-20_macos-x64_bin.dmg

Windows:
x64 Compressed Archive: https://download.oracle.com/java/20/latest/jdk-20_windows-x64_bin.zip
x64 Installer: https://download.oracle.com/java/20/latest/jdk-20_windows-x64_bin.exe
x64 MSI Installer: https://download.oracle.com/java/20/latest/jdk-20_windows-x64_bin.msi

The Arrival of Java 20

As other non-LTS releases JDK 20 includes over 1,595 contributions (tickets) by Oracle and other companies and individuals. Major contributors other than Oracle include Red Hat, SAP, Google, ARM, Amazon, Intel, IBM, Alibaba, BellSoft, Loongson, Azul, and Tencent.

✏️ New features released

(D)TLS Key Exchange Named Groups

    In the package javax.net.ssl new methods getNamedGroups() and setNamedGroups() are been introduced that will allow having custom name groups of key exchanges algorithms used in individual TLS or DTLS connections. |

    By using the setNamedGroups() one can set a prioritized array of key exchange named groups names that can be used over the SSL/TLS/DTLS protocols.

    public String[] getNamedGroups()
    public void setNamedGroups(String[] namedGroups)

    The list of these key exchanges can be found at https://docs.oracle.com/en/java/javase/18/docs/specs/security/standard-names.html

    This new method is supported by JDK SunJSSE provider.


1. Support Unicode 15.0

    Package: java.lang

    Class: Character

    Unicode 15.0 was released in September 2022 with includes an updated version Unicode Character Database and 31 new emojis and is now supported by JDK 20.

    The class to look for here is Character under java.lang package.

    1.	Arabic Extended-C
    2.	Devanagari Extended-An
    3.	Kawi
    4.	Kaktovik Numerals
    5.	Cyrillic Extended-D
    6.	Nag Mundari
    7.	CJK Unified Ideographs Extension H

2. New GarbageCollectorMXBean G1 Concurrent GC

    Java 20 has introduced a new GarbageCollectorMXBean called "G1 Concurrent GC" to the collection of G1 garbage collector.

    This new GarbageCollectorMXBean provides information on the duration and frequency of the garbage collection pauses for the Remark and Cleanup phases.


3. New JFR Event: jdk.SecurityProviderService

    Packages: jdk.internal.event

    Class: SecurityProviderServiceEvent

    public final class SecurityProviderServiceEvent extends Event

    This is a new Java Flight Recorder (JFR) event introduced to record details of java.security.Provider.getService(String type, String algorithm) calls.

    Note: SecurityProviderServiceEvent event is disabled by default, you can enable it in JFR configuration files or standard JFR options.


4. New command line option --compress for jmod

    This new --compress command line option has been added to the jmod tool used to create, extract, and list the contents of JMOD files that was introduced in Java 9. The compress option will be used to denote the compression level when creating the JMOD archive.

    The accepted values are zip-[0-9], where zip-0 provides no compression, and zip-9 provides the best compression. Default value is zip-6.


5. Javac Warns about Type Casts in Compound Assignments with Possible Lossy Conversions

    The Java compiler, javac, now includes a new lint option called "lossy-conversions" which can be used to detect type casts in compound assignments that could result in data loss.

    This warning can be supressed using @SuppressWarnings("lossy-conversions") annotation.



✏️ Features and options are deprecated in Java 20

You will see an annotation @Deprecated(since = "20") on the below classes or methods that have been deprecated since Java 20

1. java.net.URL Constructors

    URL(String, String, int, String)
    URL(String, String, String)
    URL(String, String, int, String, URLStreamHandler)
    URL(String} m a URL(URL, String)
    URL(URL, String, URLStreamHandler)

    All the constructors from java.net.URL have been deprecated and developers as encouraged to make use of the java.net.URI


2. JMX Management Applets is deprecated and set for Removal

    Package: javax.management.loading
    MLet.class
    MLetContent.class
    MLetMBean.class
    MLetObjectInputStream.class
    MLetParser.class



✏️ Features and options that have been removed


1. Thread.suspend()/resume() changed to Throw UnsupportedOperationException

    From JDK 20 onwards you cannot suspend or resume a thread with the help of Thread.suspend() and Thread.resume() methods as they have been removed in this release these methods have been changed to UnsupportedOperationException since Java JDK 19.


2. Thread.stop() changed to Throw UnsupportedOperationException

    The stop method has been deprecated since JDK 1.2. You cannot stop a thread Thread.stop() as this method has been removed in JDK 20. Instead make use of throw UnsupportedOperationException which was added in Java JDK 19.



✏️ New Features JEPs

  • JEP 429: Scoped Values (Incubator)
  • JEP 432: Record Patterns (Second Preview)
  • JEP 433: Pattern Matching for switch (Fourth Preview)
  • JEP 434: Foreign Function & Memory API (Second Preview)
  • JEP 436: Virtual Threads (Second Preview)
  • JEP 437: Structured Concurrency (Second Incubator)
  • JEP 438: Vector API (Fifth Incubator)

Read more: https://openjdk.org/projects/jdk/20/

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap