‹#› ☕️ JDK 23 📋 12 JEPs included 🧪 9 - Preview or Incubator ✅ 3 - Finial and delivered ⚠️ 1 - Withdrawn
JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) Language Features ‹#›
⚡️ Primitive usage limitations instanceof is limited to reference types switch statements were limited in the types they could handle long, float, double, and boolean are not supported Need to do manual casting (e.g. fit int into byte ) ‹#› 🙄
⚡️ Switch over primitives: before ‹#›
⚡️ Primitive Type Patterns in switch ‹#› ⤵
⚡️ Primitive Type Guarded Patterns in switch ‹#› ⤵
⚡️ Unsafe primitive checking & casting ‹#›
⚡️ Primitive Pattern Matching for instanceof and safe cast 1. 2 . ‹#› ⤵ No explicit cast needed
⚡️ Labels dominance byte and int Label is dominated by a preceding case label 'long l' 💪 ‹#›
⚡️ Enhanced Support for Primitive Types in Record Patterns ‹#› 1. 2 .
JEP 482 : Flexible Constructor Bodies (Second Preview) Language Features ‹#›
⚡️ Constructor limitations ⚠️ i nflexibility of Java constructors requires that an explicit constructor invocation ( super() or this() ) be the first statement in the constructor body ‹#›
⚡️ Before: Flexible Constructor Bodies ‹#›
⚡️ After: Flexible Constructor Bodies ‹#›
⚡️ Sub-class fields Initialization issues ⤵ Will be null ‹#›
⚡️ Flexible Constructor Bodies (2nd Preview) Direct Validation and Preparation Initialize Fields Early Enhanced Readability & M aintainability ‹#›
JEP 476 : Module Import Declarations (Preview) Language Features ‹#›
⚡️ Regular imports ‹#› ⤵
⚡️ Module Import Declarations (Preview) ‹#› ⤵
⚡️ Module Import Declarations conflicts java: reference to Date is ambiguous both class java.sql.Date in java.sql and class java.util.Date in java.util match ‹#›
JEP 477 : Implicitly Declared Classes and Instance Main Methods (Third Preview) Language Features ‹#›
⚡️ Regular Java App with learning overhead ‹#›
⚡️ Instance Main Method ‹#›
⚡️ Implicitly Declared Class ‹#› ⤵ Package declaration should be unnamed as well
⚡️ Instance Main Method ⤵ ‹#›
⚡️ More simplification Simplified I/O operations. New class java.io.IO Automatically imports java.base module ‹#› No explicit imports
JEP 466 : Class-File API (Second Preview) API Enhancements ‹#›
⚡️ Byte code manipulation purposes Runtime Code Generation Implementation of cross-cutting concerns Code Analysis and Metrics Performance Optimization … and more … ‹#› ASM
⚡️ Class-File API (2nd Preview) Standard API for parsing , generating , and transforming Java class files Aim is to replace the bytecode manipulation framework ASM API that evolve together with the class-file format ‹#›
⚡️ Class-File API (2nd Preview) ‹#›
JEP 473 : Stream Gatherers (Second Preview) API Enhancements ‹#›
⚡️ Stream operations Intermediate operations E.g. map(...) , filter(...) , limit(...) and more collect(Collectors.toMap(...)) count(), anyMatch(...) and more You could implement own terminal operation using Collector interface Custom intermediate operations ??? ‹#› Terminal operations
⚡️ Stream Gatherers (2nd Preview) Gatherer< T , A , R > T - the type of input elements A - the potentially mutable state type of the gatherer operation R - the type of output elements Supplier< A > initializer(); creation of a new, potentially mutable, state Integrator< A , T , R > integrator(); integrating a new input element to downstream BinaryOperator< A > combiner(); can be parallelized, merge partial result into one BiConsumer< A , Downstream<? super R >> finisher(); performing an optional final operation, when there are not more elements ‹#›
⚡️ Built-in gatherers (java.util.stream.Gatherers) fold() mapConcurrent() scan() windowFixed() windowSliding() ‹#› And you could implement many-many more custom ones 🙂
⚡️ Example: custom distinctBy() gatherer ‹#›
JEP 480 : Structured Concurrency (Third Preview) API Enhancements ‹#›
⚡️ Concurrency ⚠️ Writing concurrent programs is notoriously difficult due to the complexities of managing multiple threads and tasks. ‹#›
JEP 481 : Scoped Values (Third Preview) API Enhancements ‹#›
⚡️ Scoped Values (3rd Preview) Goal is to enable the efficient sharing of immutable data within and across threads ‹#›
⚡️ Scoped Values : example ‹#›
⚡️ Scoped Values : example ‹#›
⚡️ Scoped Values : key benefits preferred to ThreadLocal for virtual threads immutable data sharing bounded lifetime smaller footprint and complexity ‹#›
⚡️ Scoped Values : more 1. Bind multiple Scoped Values 2 . Inheritance of Scoped Values ‹#›
⚡️ Scoped Values : callable action ‹#› 1. 2 .
JEP 469 : Vector API (Eighth Incubator) API Enhancements ‹#›
⚡️ Vector API (Eighth Incubator) ⚠️ The Vector API will incubate until necessary features of Project Valhalla become available as preview features. Provide a clear and concise API Platform Agnostic Performance Reliability ‹#›
JEP 474: ZGC: Generational Mode by Default JVM Enhancements ‹#›
⚡️ ZGC: Generational Mode by Default ZGC - scalable, low-latency garbage collector $ java -XX:+UseZGC -XX:+ZGenerational A warning that the ZGenerational option is deprecated is issued. $ java -XX:+UseZGC -XX:-ZGenerational Non-generational mode is deprecated. The ZGenerational option is deprecated. $ java -XX:+UseZGC ‹#›
JEP 467 : Markdown Documentation Comments Tools ‹#›
⚡️ Documentation ? ‹#›
⚡️ Html Documentation Comments ⚠️ Traditional Javadoc comments require the use of HTML and custom Javadoc tags, which can be verbose and cumbersome. 😃 Utilize Markdown, a popular and widely-understood markup language among developers ‹#›
⚡️ Ok let’s write documentation ‹#›
⚡️ Html Documentation Comments ‹#›
⚡️ Markdown Documentation Comments Neat 😎👍 ‹#›
JEP 471 : Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal Deprecations ‹#›
⚡️ Memory-Access Methods in sun.misc.Unsafe ⚠️ All uses of memory-access methods in sun.misc.Unsafe will generate compile-time deprecation warnings in JDK 23. Use safer and standard APIs introduced earlier java.lang.invoke.VarHandle , introduced in JDK 9 java.lang.foreign.MemorySegment , introduced in JDK 22 in Foreign Function and Memory API ‹#›
🥲 Withdrawn : String Templates ‹#›
⚡️ String Templates: was preview in JDK 21-22 ⚠️ It was planned to be more powerful than just regular interpolation ‹#›
⚡️ GraalVM for JDK 23 📣 Graal JIT is now included among the JITs available as part of the Oracle JDK. $ java -XX:+UnlockExperimentalVMOptions -XX:+UseGraalJIT -jar YourApplication.jar Offers advanced optimizations, but performance improvements depend on use-cases ‹#›