Java 23 major language and API improvements
Java ㉓ has been released in September 2024.
The following content is summarizing the most important changes to the Java API, the Java language, and the JVM introduced with Java ㉓.
For a more complete overview, follow the links in the following sections referring to the official Oracle release documents.
Java 23 Language improvements
The following describes selected improvements of the Java language. See the Java 23 release notes. See Java Language Updates for Java SE 23.
Java 23 is introducing the following language enhancements as developer preview.
JEP 455 is starting with Primitive Types in Patterns, instanceof, and switch (Preview) as developer preview. Enhance pattern matching by allowing primitive type patterns in all pattern contexts, and extend instanceof and switch to work with all primitive types.
JEP 476 is starting with Module Import Declarations as developer preview. Enhance the Java programming language with the ability to succinctly import all of the packages exported by a module. This simplifies the reuse of modular libraries, but does not require the importing code to be in a module itself.
JEP 482 is continuing with Flexible Constructor Bodies as developer preview. In constructors in the Java programming language, allow statements that do not reference the instance being created to appear before an explicit constructor invocation.
JEP 477 is continuing with Implicitly Declared Classes and Instance Main Methods.
Java is dropping the String Templates as developer preview.
We are not diving into the details of these preview features and defer that until they are moving from preview for general availability.
Java 23 API improvements
The following describes selected improvements of the Java API. See the Java 23 release notes.
Java 23 is introducing the following API enhancements as developer preview or Incubator.
JEP 466 is continuing with Class-File API, standard API for parsing, generating, and transforming Java class files
JEP 473 is continuing with Stream Gatherers. This will allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations
JEP 480 is continuing with simplifying multithreaded programming by introducing an API for structured concurrency. Structured concurrency treats multiple tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability..
JEP 481 is continuing with scoped values, which enable the sharing of immutable data within and across threads. They are preferred to thread-local variables, especially when using large numbers of virtual threads
JEP 469 is continuing with Vector API, introduces an API to express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.
We are not diving into the details of these preview features and defer that until they are moving from preview for general availability.
Java 23 Tooling improvements
The following describes selected improvements of the Java tooling. See the Java 23 release notes.
Java 23 is introducing the following tooling enhancements.
JEP 467 is adding the Markdown Documentation Comments. This enables JavaDoc documentation comments to be written in Markdown rather than solely in a mixture of HTML and JavaDoc @-tags.
Markdown Documentation Comments
Before Java 23 HTML JavaDoc syntax is verbose and hard to read in source code.
/**
* Calculates the <strong>factorial</strong> of a number.
* <p>
* The factorial of n is defined as:
* <pre><code>
* n! = n × (n-1) × (n-2) × ... × 1
* </code></pre>
*/
/**
* Calculates the **factorial** of a number.
*
* The factorial of n is defined as:
* ```
* n! = n × (n-1) × (n-2) × ... × 1
* ```
*/
Java 23 Markdown JavaDoc is clean and intuitive to write.
Before Java 23 HTML lists require verbose markup.
/**
* <strong>Examples:</strong>
* <ul>
* <li>factorial(0) = 1</li>
* <li>factorial(5) = 120</li>
* <li>factorial(10) = 3628800</li>
* </ul>
*/
/**
* **Examples:**
* - factorial(0) = 1
* - factorial(5) = 120
* - factorial(10) = 3628800
*/
Markdown lists are simple and natural to write.
HTML tables require complex markup with many tags.
/**
* <table border="1">
* <tr><th>Input</th><th>Result</th></tr>
* <tr><td>5</td><td>120</td></tr>
* <tr><td>10</td><td>3628800</td></tr>
* </table>
*/
/**
* | Input | Result |
* |-------|---------|
* | 5 | 120 |
* | 10 | 3628800 |
*/
Markdown tables use simple pipe syntax.
HTML code blocks require pre and code tags.
/**
* <strong>Example Usage:</strong>
* <pre><code>
* MathUtils utils = new MathUtils();
* long result = utils.factorial(5);
* </code></pre>
*/
/**
* ### Example Usage
*
* ```java
* MathUtils utils = new MathUtils();
* long result = utils.factorial(5);
* ```
*/
Markdown code blocks use triple backticks with optional syntax highlighting.
HTML links use verbose anchor tags.
/**
* @see <a href="https://en.wikipedia.org/wiki/Factorial">Factorial on Wikipedia</a>
*/
/**
* @see [Factorial on Wikipedia](https://en.wikipedia.org/wiki/Factorial)
*/
Markdown links use clean bracket syntax.