Search

Suggested keywords:
  • Java
  • Docker
  • Git
  • React
  • NextJs
  • Spring boot
  • Laravel

JDK 23 is now Generally Available with improvements in Documentation, ZGC, Stream, Vector API

  • Share this:

post-title

JDK 23 is now generally available and released with below feature set.

    JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview)
    JEP 466: Class-File API (Second Preview)
    JEP 467: Markdown Documentation Comments
    JEP 469: Vector API (Eighth Incubator)
    JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal
    JEP 473: Stream Gatherers (Second Preview)
    JEP 474: ZGC: Generational Mode by Default
    JEP 476: Module Import Declarations (Preview)
    JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview)
    JEP 480: Structured Concurrency (Third Preview)
    JEP 481: Scoped Values (Third Preview)
    JEP 482: Flexible Constructor Bodies (Second Preview)
    
    
Markdown Documentation Comments

In order to generate Javadocs, in the Java code, we can write documentation using HTML tags. This feature provides support to write JavaDoc documentation comments to be written in Markdown rather than a mixture of HTML and JavaDoc @-tags. Markdown is a popular markup language for simple documents that is easy to read, easy to write, and easily transformed into HTML.

 

Primitive Types in Patterns, instanceof, and switch

Enhance pattern matching by allowing primitive type patterns in all pattern contexts, and extend instanceof and switch to work with all primitive types. 

 

Class-File API

Provide an API for processing class files that tracks the class file format defined by the Java Virtual Machine Specification. The Java ecosystem has many libraries for parsing and generating class files, each with different design goals. This feature provides support to have a standard API to process class files.

 

Vector API

Vector operations express a degree of parallelism that enables more work to be performed in a single CPU cycle and thus can result in significant performance gains. The Vector API aims to improve the situation by providing a way to write complex vector algorithms in Java.

 

Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal

The sun.misc.Unsafe class was introduced in 2002 as a way for Java classes in the JDK to perform low-level operations. Most of its methods are for accessing memory, either in the JVM's garbage-collected heap or in off-heap memory, which is not controlled by the JVM. They are unsafe and lead to undefined behavior. 

 

Stream Gatherers 

Enhance the Stream API to support custom intermediate operations. This will allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations. Stream::gather(Gatherer) is a new intermediate stream operation that processes the elements of a stream by applying a user-defined entity called a gatherer. 

 

ZGC: Generational Mode by Default

Make Generational ZGC the default mode of ZGC by changing the default value of the ZGenerational option from false to true. Deprecate the non-generational mode by deprecating the ZGenerational option.

 

Module Import Declarations (Preview)

Classes and interfaces in the java.lang package, such as Object, String, and Comparable, are essential to every Java program. Java compiler automatically imports, on demand, all the classes and interfaces in the java.lang package. As the Java Platform has evolved, classes and interfaces such as List, Map, Stream, and Path have become almost as essential. However, none of these are in java.lang, so they are not automatically imported; rather, developers have to keep the compiler happy by writing a plethora of import declarations at the beginning of every source file. 

 

Implicitly Declared Classes and Instance Main Methods (Third Preview)

Evolve the Java programming language so that beginners can write their first programs without needing to understand language features designed for large programs. 

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

 

class HelloWorld {
    void main() {
        System.out.println("Hello, World!");
    }
}

 

Structured Concurrency (Third Preview)

Simplify concurrent programming by introducing an API for structured concurrency. Structured concurrency treats groups of related tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability.

 

Scoped Values (Third Preview)

Introduce scoped values, which enable a method to share immutable data both with its callees within a thread, and with child threads. Scoped values are easier to reason about than thread-local variables.

 

Flexible Constructor Bodies (Second Preview)

Constructors basically allow statements to appear before an explicit constructor invocation, i.e., super(..) or this(..). The statements cannot reference the instance under construction, but they can initialize its fields. Initializing fields before invoking another constructor makes a class more reliable when methods are overridden.

Allow a constructor body to initialize fields in the same class before explicitly invoking a constructor. This enables a constructor in a subclass to ensure that a constructor in a superclass never executes code which sees the default value of a field in the subclass (e.g., 0, false, or null). This can occur when, due to overriding, the superclass constructor invokes a method in the subclass that uses the field.

 

Editorial Team

About author
This article is published by our editorial team.