Java Version 23 Released
Written by Nikos Vaggalis   
Monday, 30 September 2024

It was in April 2024 that we had Java 22. Now after just 6 months there's version 23, which is a STS release with lots of features in preview status.

This release includes twelve JEPs:

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


It is mainly comprised of previews, with just two features being completed; Markdown Documentation Comments and
the switch to ZGC: Generational Mode by default. Let's take a look at the most eye catching changes, commencing with the features in status of completion.

Markdown Documentation Comments
Pretty straightforward this one. It allows using Markdown in writing Javadoc comments to make the documentation easier to read.

ZGC: Generational Mode by default
Switched the default mode of the Z Garbage Collector (ZGC) to the generational mode, since it was deemed that maintaining non-generational ZGC slows down the development of new features.

Now to the rest.

JEP 455: Primitive Types in Patterns, instanceof, and switch
Pattern matching although already implemented had limited support in using primitive types. So JEP 455 proposes pattern matching to be extended to include primitive types too, meaning that instanceof and switch would be allowed to work with such data types even inside nested contexts.

Another feature of significant nature is JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe.
While Java is memory safe, there's many occasions that developers require direct low level access, and for that they are using sun.misc.Unsafe, which usage is problematic at least. This is because it can turn a safe language into a hotbed of memory leaks and other bugs. Now 471 marks the interface as deprecated to be removed. But replaced with what? With the Foreign Function & Memory API available since version 22.

473: Stream Gatherers (Second Preview)
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. With the gather operation we can build efficient, parallel-ready streams that implement almost any intermediate operation. Stream::gather(Gatherer) is to intermediate operations what Stream::collect(Collector) is to terminal operations.

This second preview enhances 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.

And finally, JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview)

This is the third preview of the feature that was introduced back in JDK 21 with JEP 445: Unnamed Classes and Instance Main Methods which we examined in "An Attempt To Make Java Easier To Learn" where we found that it's no secret that Java is not the favorite language of Coding Bootcamps.

Therefore that OpenJDK proposal tries to change that by reforming the language's syntax itself, so that
a simple "Hello World" example would become as simple as

void main() {
System. out. println("Hello World");
}

This third preview suggests two additions:

  • Implicitly declared classes automatically import three static methods for simple textual I/O with the console. These methods are declared in the new top-level class java.io.IO.

  • Implicitly declared classes automatically import, on demand, all of the public top-level classes and interfaces of the packages exported by the java.base module.


Now the question is, who will tweak their products to accommodate this new version.

The first one to jump on the bandwagon is Jetbrains by adding Java 23 support in IntelliJ IDEA 2024.2. The next immediate candidate looks like that it's the Trino query engine according to this announcement. Who will follow next?

 

More Information

Java 23 / JDK 23: General Availability

Related Articles

Java Version 22 Released

The I Programmer Java 2023 Recap

 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


GitHub Launches Enterprise Data Residency
30/09/2024

GitHub has announced an option offering tighter control over where data is stored to meet regional requirements. The GitHub Enterprise Cloud data residency feature will launch on October 29 for the Eu [ ... ]



Microsoft Releases Azure AI Inference SDK For .NET
26/09/2024

Microsoft has introduced an Azure AI Inference SDK for .NET. The SDK can be used to access and use AI models from the Azure AI Model Catalog for inference tasks like chat in .NET applications.


More News

kotlin book

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 30 September 2024 )