SlideShare a Scribd company logo
EXCITING FEATURES &
ENHANCEMENTS IN JAVA 23/24
ANA-MARIA MIHALCEANU
Senior developer advocate at Oracle
ammbra1508 ammbra1508.mastodon.social
What Has Been Java Doing?
56
91
12
1…
8 5
16 14 1… 14
9 7 6
15
12 12
0
10
20
30
40
50
60
70
80
90
100
Features
(JEPs)
JDK 8 JDK 9 JDK 10 JDK 11 JDK 12 JDK 13 JDK 14 JDK 15 JDK 16 JDK 17 JDK 18 JDK 19 JDK 20 JDK 21
Mar
2024
Commercial
Support
3 Years 2 Years
JDK 22
Commercial
Support
Sept
2023
Mar
2023
Sept
2022
Mar
2022
Sept
2021
Mar
2021
Sept
2020
Mar
2020
Sept
2019
Mar
2019
Sept
2018
Mar
2018
Sept
2017
Mar
2014
Sept
2024
JDK 23
Commercial
Support
Commercial
Support
Inclusive Development Experience
🔗”Paving the On Ramp
As a result, it is easy to forget about the “small" programs
Java has been historically
successful in “big" systems
And we all start small
But, we want Java
to be successful
for small applications too
• OOP concepts should not overwhelm your first (or any
small) program
• The “on ramp" should lead smoothly onto the highway
”Paving the On Ramp”
A Simplified Beginning
Project Amber
// HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Launch via single file execution (since JDK 11)
java HelloWorld.java
Use jshell for fast prototyping Java code
Towards A Simplified Beginning
Paving The On Ramp (In Preview)
// HelloWorld.java
void main( ) {
println("Hello, World!");
}
public class HelloWorld {
public static String[] args
}
System.out.
JEP 495: Implicitly Declared Classes and Instance Main Methods (Fourth Preview)
Effective Scripting with Java
// HelloWorld.java
void main() {
println("Hello, World!");
}
JEP 495: Simple Source Files and Instance Main Methods (Fourth Preview)
Class declaration no longer required
main is not necessarily public static
String[] args not declared if not used further
Auto-import useful methods for textual input and output
Import All Packages Exported by a Module
import java.io.IOException;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import module java.base;
JEP 494: Module Import Declarations (Second Preview)
Thoughtful Evolution of Java
Language Features
Project Amber
Agenda Prototype
• Add chores to do to.
• Delete a chore when is done.
• A chore can have either an URL or an image attached to it.
• The deadline for chore has to be greater than current date.
• The priority is deduced based on deadline.
Agenda Entity Modeling
Sealed types limit which subtypes can directly
extend/implement them.
public sealed interface Todo
permits TodoItem {}
public non-sealed class TodoItem
implements Todo {}
public final class URLTodoItem
extends TodoItem{}
public final class ImageTodoItem
extends TodoItem{}
Inheritance and Constructor Chaining
public final class URLTodoItem extends TodoItem {
private String url;
public URLTodoItem(String title, String description, String url,
LocalDate createdOn, LocalDate deadline) {
super(title, description, createdOn, validate(createdOn, deadline));
this.url = url;
}
private static LocalDate validate(LocalDate createdOn, LocalDate deadline) {
if (deadline.isBefore(createdOn))
throw new IllegalArgumentException(”Deadline must not be before creation date");
return deadline;
}
}
Constructor chaining is enforced in subclass.
Statements before super(…)
public final class URLTodoItem extends TodoItem {
private String url;
public URLTodoItem(String title, String description, String url,
LocalDate createdOn, LocalDate deadline) {
if (deadline.isBefore(createdOn))
throw new IllegalArgumentException(”Deadline cannot be before creation date");
this.url = url;
super(title, description, createdOn, deadline);
}
}
Validate superclass constructor arguments
Prepare superclass constructor arguments
Share superclass constructor arguments
JEP 492: Flexible Constructor Bodies (Third Preview)
Determine Emergency Based on Priority
private static Highlight findColor(TodoItem item) {
return switch (item.getPriority()) {
case long p when p < 0 -> Highlight.RED;
case 0L -> Highlight.YELLOW;
case 1L -> Highlight.BLUE;
case long _ -> Highlight.WHITE;
};
}
JEP 488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
Primitive Type Patterns in Nested Context
public record Statistic(Highlight highlight, int count) {}
switch (statistic) {
case Statistic(Highlight h, byte b) when h == Highlight.RED && b < -10 -> …;
case Statistic(Highlight h, short s) when h == Highlight.YELLOW -> …;
case Statistic(Highlight h, int i) when h == Highlight.BLUE ->…;
case Statistic(Highlight h, int i) -> …;
}
JEP 488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
So You Want to Know More…
• Java 23: Restoring the Balance with Primitive Patterns - Inside Java Newscast #66
• Clean Application Development with Records, Sealed Classes and Pattern Matching (2022)
• Java Records are "Trusted" and Consequently Faster
• State of Pattern Matching with Brian Goetz (2022)
• Pattern Matching in the Java Object Model
• Patterns: Exhaustiveness, Unconditionality, and Remainder
• Uniform handling of failure in switch
• HAT Example of script in Java
Strengthening Java Platform’s
Trust Model
Protecting Java Code from the JVM Up
• We rely on the integrity of our code, meaning it is correct and complete.
• There are 4 APIs in JDK that can bypass integrity:
• The AccessibleObject::setAccessible(boolean) method in the java.lang.reflect package
• The sun.misc.Unsafe class with methods that can access private methods and fields
• The Java Native Interface (JNI)
• The Instrumentation API allows agents to modify the bytecode of any method in any class.
JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal
Phasing out Integrity Undermining APIs
• Changes in JEP 471 deprecate the memory-access methods in sun.misc.Unsafe for removal.
• Alternative APIs: VarHandle API and Foreign Function and Memory API.
• JDK 24 will issue a warning the first time that any memory-access method is used, directly or
via reflection.
• Tools that help you identify dependencies on Unsafe:
• Look after the compile-time warnings emitted by javac .
• The jdk.DeprecatedInvocation JFR event is recorded whenever the profiled JVM
invokes a terminally deprecated method.
JEP 498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
Warning on Native Loading & Linking Steps
• Calling native code can lead to arbitrary undefined behavior, including JVM crashes.
• JDK 24 aligns the behavior of JNI and Foreign Function & Memory (FFM) API through:
• printing warnings for all restricted operations
• expanding the command-line options --enable-native-access and --illegal-native-
access to govern restricted operations of both APIs.
JEP 472: Prepare to Restrict the Use of JNI
Adjacent Deprecations and Removals
• The Windows 32-bit x86 port was deprecated in JDK 21 and removed in JDK 24 via JEP 479.
• JDK 24 deprecates for removal the Linux 32-bit x86 port, and any remaining downstream 32-bit x86 ports.
• Once removed, the architecture-agnostic Zero port will be the sole option for running Java on 32-bit x86
processors.
JEP 501: Deprecate the 32-bit x86 Port for Removal
Enhanced Java Security
Out of the Box
Security
Support for Extra Security Properties Files
Include additional files in $JAVA_HOME/conf/security/java.security
```properties
# Including files inline in the main security properties file
include /path/to/tls-config.security
# Existing security property
jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA
```
JDK-8319332 Security properties files inclusion
Key Encapsulation Mechanism (KEM) Recap
Introduction of Quantum-Resistant ML-KEM
• Java's security framework takes a leap forward with the implementation of the Module-Lattice-
Based Key-Encapsulation Mechanism (ML-KEM).
• ML-KEM is derived from the Kyber algorithm.
• ML-KEM ensures future-proof encryption with parameter sets ML-KEM-512, ML-KEM-768, and
ML-KEM-1024, now integrated into Java's KeyPairGenerator, KEM, and KeyFactory APIs.
• Future support for TLS and other components will be added as related standards evolve.
JEP 496: Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism
Introduction of ML-DSA in Java
• Integration of the quantum-resistant Module-Lattice-Based Digital Signature Algorithm (ML-DSA).
• ML-DSA strengthens data integrity and signatory authentication by providing robust digital signatures.
• Java’s implementation supports the KeyPairGenerator, Signature, and KeyFactory APIs with
parameter sets ML-DSA-44, ML-DSA-65, and ML-DSA-87.
• While not targeting applications like JAR signing or TLS yet, this addition prepares Java developers for
a secure quantum future.
JEP 497: Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm
The New Key Derivation Function API
• A preview API that enables the use of KDFs in Key Encapsulation Mechanism implementations.
• It empowers you to benefit of KDFs in cryptographic schemes like Hybrid Public Key Encryption (HPKE)
and protocols such as TLS 1.3.
• Offers flexibility for security providers to implement KDF algorithms in Java or native code.
JEP 478: Key Derivation Function API (Preview)
Retiring the Security Manager
• In Java 17, was deprecated for removal under JEP 411.
• Going forward with JDK 24, the Security Manager functionality will be effectively disabled.
• The deprecation of the Security Manager in JDK 17 had little to no impact on most Java
developers.
The JDK offers options to identify and address its usage:
• jdeprscan scans a JAR file for usage of deprecated API elements.
• messages on the console warnings highlight Security Manager usage during runtime.
• locally and in scripts, check if you launch your Java application with the Security Manager
allowed or enabled via command line options, or policy files that require it to be installed
and configured.
JEP 486: Permanently Disable the Security Manager
Improved Java Performance
HotSpot
Accelerating Java Startup
• The ahead-of-time (AOT) cache allows the JVM to preload, parse, and link classes during a training run.
• The AOT cache extends CDS by not only reading and parsing class files but also linking them. This
means classes are preloaded into memory in a fully usable state.
• For instance, a basic program using the Stream API can see its startup time cut from 0.031 seconds to
0.018 seconds—a 42% improvement.
• For more complex applications like Spring PetClinic, the startup time can drop from 4.486 seconds to
2.604 seconds.
JEP 483: Ahead-of-Time Class Loading & Linking
Create and Load the AOT Cache
1. Do a training run: launch the application with the JVM configured to record its class-loading behavior
java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf -cp app.jar org.example.App
2. The recorded data is used to generate the AOT cache file
java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -XX:AOTCache=app.aot -cp app.jar
3. Shifts much of the class-loading work from runtime to an earlier point, significantly reducing startup time.
java -XX:AOTCache=app.aot -cp app.jar org.example.App
Limitations and Workarounds
• User-Defined Class Loaders: classes loaded dynamically by custom loaders are excluded
from the cache.
Future updates might address this gap if they prove significant.
• Consistency Constraints: strict requirements for JDK versions and configurations can
complicate deployment pipelines.
Use tools like Docker to standardize environments can mitigate this issue.
• Exclusion of ZGC: the Z Garbage Collector is not yet supported.
Future updates will likely address this gap.
JEP 483: Ahead-of-Time Class Loading & Linking
Smaller Runtimes For a Leaner Future
• It will be possible for a JDK to be built without JDK’s JMOD files.
$ configure [ ... other options ... ] --enable-linkable-runtime
$ make images
• This feature can reduce JDK size by approximately 25%.
• The default build configuration will remain as of today. It is up to each vendor to enable this feature.
• The JDK impacts how jlink creates custom runtime images (with or without relying on JMOD files).
• Nothing changes for jlink standard options, but a series of restrictions apply to it if part of a JDK
built with --enable-linkable-runtime.
JEP 493: Linking Run-Time Images without JMODs
Better Performance by Shrinking Object Headers
• The HotSpot JVM introduces a feature to reduce object header sizes from 96-128 bits to 64 bits on 64-bit
architectures.
• It aims to reduce memory footprints on real workloads, while maintaining minimal performance overheads.
• As an experiment feature is currently off by default, must be enabled via:
-XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders
JEP 450: Compact Object Headers (Experimental)
Unpinning Syncronized Virtual Threads
• This initiative ensures that virtual threads running synchronized methods or statements no
longer block their platform threads.
• By redesigning the JVM's handling of monitors, virtual threads can now unmount from their
carriers even when blocked.
• This change eliminates the need to avoid synchronized constructs, allowing you to write clearer
concurrent code.
JEP 450: Compact Object Headers (Experimental)
ZGC at a Glance
• Delivered in JDK 15 (September 2020)
• A scalable low-latency garbage collector
• ZGC pauses are O(1)
• Scalable: up to TB heaps
• Auto-tuning: requires minimal configuration
• Can handle heaps ranging from a 8MB to 16TB in size
Benefits of Generational ZGC
• Withstand higher allocation rates
• Lower heap headroom
• Lower CPU usage
• Now enabled by default when using -XX:+UseZGC
• Automatic Tuning -> Only set the max heap size! (-Xmx)
JEP 474: ZGC: Generational Mode by Default
What Changed for ZGC ?
• Did you enable ZGC it with -XX:+UseZGC -XX:+ZGenerational?
• Generational ZGC is used.
An obsolete-option warning is printed.
• What if you try -XX:+UseZGC -XX:-Zgenerational?
• Generational ZGC is used.
Warning that the non-generational mode is obsolete.
JEP 490: ZGC: Remove the Non-Generational Mode
Optimizing G1GC
• To improve Java's scalability, G1GC now expands memory barriers late in the compilation process.
• This enhancement is inspired by the approach used by the ZGC collector.
• Reduces JIT compilation time by up to 20% and ensures the quality of generated code.
• A more responsive Java platform, particularly for cloud-based deployments.
So You Want to Know More…
• Project Leyden: Improving Java’s Startup Time by Per Minborg, Sébastien Deleuze
• Java Performance Update 2024 by Per Minborg
• Project Leyden Update #JVMLS
• Java 24 Stops Pinning Virtual Threads (Almost) - Inside Java Newscast #80
• Overview of ZGC
• Deep-dive of zgc's architecture
• JVMLS - generational ZGC and beyond
• Optimizing memory utilization with automated heap sizing in ZGC
• Z garbage collector: the next generation
• ZGC : java’s highly scalable low-latency garbage collector - stack walker #1
Fundamental Changes to
Achieve Your Application Goals
Core Libraries
A New Form of Documentation Comment
Markdown in Java documentation comments help with having:
• concise syntax for common constructs,
• reduce the dependence on HTML markup and JavaDoc tags,
• while keep enabling the use of specialized tags when not available in Markdown.
JEP 467: Markdown Documentation Comments
Exciting Features and Enhancements in Java 23 and 24
Extra Capabilities
• Define simple GitHub Flavored Markdown pipe tables.
• Process standalone Markdown files from doc-files subdirectories.
• Standalone Markdown files can have JavaDoc tags , but YAML metadata is not supported.
• Enable syntax highlighting with Javascript libraries through javadoc --add-script.
• Render diagrams (like Mermaid).
JEP 467: Markdown Documentation Comments
Unfulfilled Streams Operations
• Streams API has a fixed set of intermediate operations.
List<String> letters = Arrays.asList("A","B","C","D","E","F","G","H");
int size = 3;
// ABC DEF GH
IntStream.range(0, (letters.size() + size - 1) / size)
.mapToObj(i -> String.join("",
letters.subList(i * size, Math.min(size * (i + 1), letters.size()))))
.toList();
Some intermediate operations are missing: sliding windows, take-while-including, fixed grouping,etc.
The Gatherers API
• A generalization for intermediate operations java.util.stream.Gatherer
• A new intermediate stream operation to process elements of a stream: Stream::gather(Gatherer)
• A few implementations, e.g. Gatherers.fold(…), Gatherers.windowFixed(…).
• A way to compose gathererers source.gather(a.andThen(b).andThen(c)).collect(...).
List<String> letters = Arrays.asList("A","B","C","D","E","F","G","H");
int size = 3;
letters.stream()
.gather(Gatherers.windowFixed(3))
.map(window -> String.join("", window))
.toList();
JEP 485: Stream Gatherers
Gatherer Components
Initializer (optional)
• Creates private state object
Integrator (mandatory)
• Accepts (state, element, downstream)
• Integrates element into state
• to update gatherer’s private state object
• to emit 0+ element(s) to downstream
Combiner (optional)
• Can evaluate the gatherer in parallel
Finisher (optional)
• Accepts (state, downstream)
• Invoked when no more elements can be consumed
• Emits element(s) to downstream
Compiling And Launching a Java Program
IDE javac java
.java source
file
bytecode .class
file
Program running
Bytecode Manipulation
Runtime
JVM
Class
loader .class
javac
jdeps
libraires
agents
frameworks
The New Class-file API
• A stable Java API for analyzing and manipulating bytecode.
• An API always-up-to-date with the JDK version.
• Frameworks that use this API can easily update to a newer JDK version.
JEP 484: Class-File API
So You Want to Know More…
• JavaDoc Hits the Markdown on Comments - Inside Java Newscast #68
• A Classfile API for the JDK (JVMLS 2023, Brian Goetz)
• New Class-File API will make Java Updates easier - Inside Java Newscast #56
• Teaching Old Streams New Tricks (Devoxx Belgium 2023, Viktor Klang)
• Better Java Streams with Gatherers - Inside Java Newscast #57
• Better Java Streams with Gatherers - JEP Cafe #23
Broadened Ability to Develop
High-Performance Programs
Project Summary Pain point “Obvious"
Competition
Amber Right-sizing language ceremony
“Java is too verbose"
“Java is hard to teach"
C#, Kotlin
Babylon Foreign programming model interop “Using GPUs is too hard" LinQ, Julia
Leyden Faster startup and warmup “Java starts up too slowly" Go
Loom Lightweight concurrency
“Threads are too expensive, don’t
scale"
Go, Elixir
Panama
Native code and memory interop
SIMD Vector support
“Using native libraries is too hard"
“Numeric loops are too slow"
Python, C
Valhalla Value types and specialized generics
“Cache misses are too expensive"
“Generics and primitives don’t mix"
C, C#
ZGC Sub-millisecond GC pauses “GC pauses are too long" C, Rust
Learn, Share, and Collaborate
Stay Tuned for More
Inside.java
Dev.java youtube.com/java
THANK YOU!
Slides & Code

More Related Content

PDF
Java 23 and Beyond - A Roadmap Of Innovations
PDF
SevillaJUG - Unleash the power of your applications with Micronaut® ,GraalVM...
PDF
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...
PDF
Java 25 and Beyond - A Roadmap of Innovations
PDF
Java 40 versions_sgp
PPTX
Java @ Cloud - Setor Público SP
PDF
GraalVM Overview Compact version
PDF
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
Java 23 and Beyond - A Roadmap Of Innovations
SevillaJUG - Unleash the power of your applications with Micronaut® ,GraalVM...
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...
Java 25 and Beyond - A Roadmap of Innovations
Java 40 versions_sgp
Java @ Cloud - Setor Público SP
GraalVM Overview Compact version
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...

Similar to Exciting Features and Enhancements in Java 23 and 24 (20)

PDF
RohitJindal
PDF
GETTING STARTED WITH DATABASE SECURITY ASSESSMENT TOOL
PDF
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
PPTX
Session 41 - Struts 2 Introduction
ODP
Groovy In the Cloud
PPTX
Intro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry Meetup
PPTX
Java dev mar_2021_keynote
PDF
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
DOCX
Ankit Vakil (2)
PDF
Java modularity: life after Java 9
DOC
KaranDeepSinghCV
PPTX
SUGCON EU 2023 - Secure Composable SaaS.pptx
PPT
Java Training at Gateway Software Solutions,Coimbatore
PPTX
Why jakarta ee matters (ConFoo 2021)
PPSX
Struts 2 - Introduction
DOCX
Ankit Vakil (1)
PPTX
Spring Test Framework
PPTX
Chapter 10:Understanding Java Related Platforms and Integration Technologies
PDF
Red Hat Java Update and Quarkus Introduction
PDF
Understand the Trade-offs Using Compilers for Java Applications
RohitJindal
GETTING STARTED WITH DATABASE SECURITY ASSESSMENT TOOL
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Session 41 - Struts 2 Introduction
Groovy In the Cloud
Intro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry Meetup
Java dev mar_2021_keynote
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
Ankit Vakil (2)
Java modularity: life after Java 9
KaranDeepSinghCV
SUGCON EU 2023 - Secure Composable SaaS.pptx
Java Training at Gateway Software Solutions,Coimbatore
Why jakarta ee matters (ConFoo 2021)
Struts 2 - Introduction
Ankit Vakil (1)
Spring Test Framework
Chapter 10:Understanding Java Related Platforms and Integration Technologies
Red Hat Java Update and Quarkus Introduction
Understand the Trade-offs Using Compilers for Java Applications
Ad

More from Ana-Maria Mihalceanu (20)

PDF
Empower Inclusion Through Accessible Java Applications
PDF
Sécuriser les Applications Java Contre les Menaces Quantiques
PDF
Des joyaux de code natif aux trésors Java avec jextract
PDF
From native code gems to Java treasures with jextract
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
From native code gems to Java treasures with jextract
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
PDF
Java 22 and Beyond- A Roadmap of Innovations
PDF
Surveillance de la sécurité des applications Java avec les outils du JDK e...
PDF
A Glance At The Java Performance Toolbox
PDF
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
Java 21 Language Features and Beyond
PDF
From Java 17 to 21- A Showcase of JDK Security Enhancements
PDF
Java 21 and Beyond- A Roadmap of Innovations
PDF
A Glance At The Java Performance Toolbox
PDF
A Glance At The Java Performance Toolbox.pdf
Empower Inclusion Through Accessible Java Applications
Sécuriser les Applications Java Contre les Menaces Quantiques
Des joyaux de code natif aux trésors Java avec jextract
From native code gems to Java treasures with jextract
Monitoring Java Application Security with JDK Tools and JFR Events
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
From native code gems to Java treasures with jextract
Monitoring Java Application Security with JDK Tools and JFR Events
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Monitoring Java Application Security with JDK Tools and JFR Events
Java 22 and Beyond- A Roadmap of Innovations
Surveillance de la sécurité des applications Java avec les outils du JDK e...
A Glance At The Java Performance Toolbox
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Java 21 Language Features and Beyond
From Java 17 to 21- A Showcase of JDK Security Enhancements
Java 21 and Beyond- A Roadmap of Innovations
A Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox.pdf
Ad

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
cuic standard and advanced reporting.pdf
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Modernizing your data center with Dell and AMD
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
“AI and Expert System Decision Support & Business Intelligence Systems”
Unlocking AI with Model Context Protocol (MCP)
cuic standard and advanced reporting.pdf
Approach and Philosophy of On baking technology
NewMind AI Monthly Chronicles - July 2025
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
20250228 LYD VKU AI Blended-Learning.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Modernizing your data center with Dell and AMD
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MYSQL Presentation for SQL database connectivity
The Rise and Fall of 3GPP – Time for a Sabbatical?
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation_ Review paper, used for researhc scholars
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing

Exciting Features and Enhancements in Java 23 and 24

  • 1. EXCITING FEATURES & ENHANCEMENTS IN JAVA 23/24 ANA-MARIA MIHALCEANU Senior developer advocate at Oracle ammbra1508 ammbra1508.mastodon.social
  • 2. What Has Been Java Doing? 56 91 12 1… 8 5 16 14 1… 14 9 7 6 15 12 12 0 10 20 30 40 50 60 70 80 90 100 Features (JEPs) JDK 8 JDK 9 JDK 10 JDK 11 JDK 12 JDK 13 JDK 14 JDK 15 JDK 16 JDK 17 JDK 18 JDK 19 JDK 20 JDK 21 Mar 2024 Commercial Support 3 Years 2 Years JDK 22 Commercial Support Sept 2023 Mar 2023 Sept 2022 Mar 2022 Sept 2021 Mar 2021 Sept 2020 Mar 2020 Sept 2019 Mar 2019 Sept 2018 Mar 2018 Sept 2017 Mar 2014 Sept 2024 JDK 23 Commercial Support Commercial Support
  • 3. Inclusive Development Experience 🔗”Paving the On Ramp As a result, it is easy to forget about the “small" programs Java has been historically successful in “big" systems And we all start small But, we want Java to be successful for small applications too • OOP concepts should not overwhelm your first (or any small) program • The “on ramp" should lead smoothly onto the highway ”Paving the On Ramp”
  • 5. // HelloWorld.java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } Launch via single file execution (since JDK 11) java HelloWorld.java Use jshell for fast prototyping Java code Towards A Simplified Beginning
  • 6. Paving The On Ramp (In Preview) // HelloWorld.java void main( ) { println("Hello, World!"); } public class HelloWorld { public static String[] args } System.out. JEP 495: Implicitly Declared Classes and Instance Main Methods (Fourth Preview)
  • 7. Effective Scripting with Java // HelloWorld.java void main() { println("Hello, World!"); } JEP 495: Simple Source Files and Instance Main Methods (Fourth Preview) Class declaration no longer required main is not necessarily public static String[] args not declared if not used further Auto-import useful methods for textual input and output
  • 8. Import All Packages Exported by a Module import java.io.IOException; import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; import module java.base; JEP 494: Module Import Declarations (Second Preview)
  • 9. Thoughtful Evolution of Java Language Features Project Amber
  • 10. Agenda Prototype • Add chores to do to. • Delete a chore when is done. • A chore can have either an URL or an image attached to it. • The deadline for chore has to be greater than current date. • The priority is deduced based on deadline.
  • 11. Agenda Entity Modeling Sealed types limit which subtypes can directly extend/implement them. public sealed interface Todo permits TodoItem {} public non-sealed class TodoItem implements Todo {} public final class URLTodoItem extends TodoItem{} public final class ImageTodoItem extends TodoItem{}
  • 12. Inheritance and Constructor Chaining public final class URLTodoItem extends TodoItem { private String url; public URLTodoItem(String title, String description, String url, LocalDate createdOn, LocalDate deadline) { super(title, description, createdOn, validate(createdOn, deadline)); this.url = url; } private static LocalDate validate(LocalDate createdOn, LocalDate deadline) { if (deadline.isBefore(createdOn)) throw new IllegalArgumentException(”Deadline must not be before creation date"); return deadline; } } Constructor chaining is enforced in subclass.
  • 13. Statements before super(…) public final class URLTodoItem extends TodoItem { private String url; public URLTodoItem(String title, String description, String url, LocalDate createdOn, LocalDate deadline) { if (deadline.isBefore(createdOn)) throw new IllegalArgumentException(”Deadline cannot be before creation date"); this.url = url; super(title, description, createdOn, deadline); } } Validate superclass constructor arguments Prepare superclass constructor arguments Share superclass constructor arguments JEP 492: Flexible Constructor Bodies (Third Preview)
  • 14. Determine Emergency Based on Priority private static Highlight findColor(TodoItem item) { return switch (item.getPriority()) { case long p when p < 0 -> Highlight.RED; case 0L -> Highlight.YELLOW; case 1L -> Highlight.BLUE; case long _ -> Highlight.WHITE; }; } JEP 488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
  • 15. Primitive Type Patterns in Nested Context public record Statistic(Highlight highlight, int count) {} switch (statistic) { case Statistic(Highlight h, byte b) when h == Highlight.RED && b < -10 -> …; case Statistic(Highlight h, short s) when h == Highlight.YELLOW -> …; case Statistic(Highlight h, int i) when h == Highlight.BLUE ->…; case Statistic(Highlight h, int i) -> …; } JEP 488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
  • 16. So You Want to Know More… • Java 23: Restoring the Balance with Primitive Patterns - Inside Java Newscast #66 • Clean Application Development with Records, Sealed Classes and Pattern Matching (2022) • Java Records are "Trusted" and Consequently Faster • State of Pattern Matching with Brian Goetz (2022) • Pattern Matching in the Java Object Model • Patterns: Exhaustiveness, Unconditionality, and Remainder • Uniform handling of failure in switch • HAT Example of script in Java
  • 18. Protecting Java Code from the JVM Up • We rely on the integrity of our code, meaning it is correct and complete. • There are 4 APIs in JDK that can bypass integrity: • The AccessibleObject::setAccessible(boolean) method in the java.lang.reflect package • The sun.misc.Unsafe class with methods that can access private methods and fields • The Java Native Interface (JNI) • The Instrumentation API allows agents to modify the bytecode of any method in any class. JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal
  • 19. Phasing out Integrity Undermining APIs • Changes in JEP 471 deprecate the memory-access methods in sun.misc.Unsafe for removal. • Alternative APIs: VarHandle API and Foreign Function and Memory API. • JDK 24 will issue a warning the first time that any memory-access method is used, directly or via reflection. • Tools that help you identify dependencies on Unsafe: • Look after the compile-time warnings emitted by javac . • The jdk.DeprecatedInvocation JFR event is recorded whenever the profiled JVM invokes a terminally deprecated method. JEP 498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
  • 20. Warning on Native Loading & Linking Steps • Calling native code can lead to arbitrary undefined behavior, including JVM crashes. • JDK 24 aligns the behavior of JNI and Foreign Function & Memory (FFM) API through: • printing warnings for all restricted operations • expanding the command-line options --enable-native-access and --illegal-native- access to govern restricted operations of both APIs. JEP 472: Prepare to Restrict the Use of JNI
  • 21. Adjacent Deprecations and Removals • The Windows 32-bit x86 port was deprecated in JDK 21 and removed in JDK 24 via JEP 479. • JDK 24 deprecates for removal the Linux 32-bit x86 port, and any remaining downstream 32-bit x86 ports. • Once removed, the architecture-agnostic Zero port will be the sole option for running Java on 32-bit x86 processors. JEP 501: Deprecate the 32-bit x86 Port for Removal
  • 22. Enhanced Java Security Out of the Box Security
  • 23. Support for Extra Security Properties Files Include additional files in $JAVA_HOME/conf/security/java.security ```properties # Including files inline in the main security properties file include /path/to/tls-config.security # Existing security property jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA ``` JDK-8319332 Security properties files inclusion
  • 25. Introduction of Quantum-Resistant ML-KEM • Java's security framework takes a leap forward with the implementation of the Module-Lattice- Based Key-Encapsulation Mechanism (ML-KEM). • ML-KEM is derived from the Kyber algorithm. • ML-KEM ensures future-proof encryption with parameter sets ML-KEM-512, ML-KEM-768, and ML-KEM-1024, now integrated into Java's KeyPairGenerator, KEM, and KeyFactory APIs. • Future support for TLS and other components will be added as related standards evolve. JEP 496: Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism
  • 26. Introduction of ML-DSA in Java • Integration of the quantum-resistant Module-Lattice-Based Digital Signature Algorithm (ML-DSA). • ML-DSA strengthens data integrity and signatory authentication by providing robust digital signatures. • Java’s implementation supports the KeyPairGenerator, Signature, and KeyFactory APIs with parameter sets ML-DSA-44, ML-DSA-65, and ML-DSA-87. • While not targeting applications like JAR signing or TLS yet, this addition prepares Java developers for a secure quantum future. JEP 497: Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm
  • 27. The New Key Derivation Function API • A preview API that enables the use of KDFs in Key Encapsulation Mechanism implementations. • It empowers you to benefit of KDFs in cryptographic schemes like Hybrid Public Key Encryption (HPKE) and protocols such as TLS 1.3. • Offers flexibility for security providers to implement KDF algorithms in Java or native code. JEP 478: Key Derivation Function API (Preview)
  • 28. Retiring the Security Manager • In Java 17, was deprecated for removal under JEP 411. • Going forward with JDK 24, the Security Manager functionality will be effectively disabled. • The deprecation of the Security Manager in JDK 17 had little to no impact on most Java developers. The JDK offers options to identify and address its usage: • jdeprscan scans a JAR file for usage of deprecated API elements. • messages on the console warnings highlight Security Manager usage during runtime. • locally and in scripts, check if you launch your Java application with the Security Manager allowed or enabled via command line options, or policy files that require it to be installed and configured. JEP 486: Permanently Disable the Security Manager
  • 30. Accelerating Java Startup • The ahead-of-time (AOT) cache allows the JVM to preload, parse, and link classes during a training run. • The AOT cache extends CDS by not only reading and parsing class files but also linking them. This means classes are preloaded into memory in a fully usable state. • For instance, a basic program using the Stream API can see its startup time cut from 0.031 seconds to 0.018 seconds—a 42% improvement. • For more complex applications like Spring PetClinic, the startup time can drop from 4.486 seconds to 2.604 seconds. JEP 483: Ahead-of-Time Class Loading & Linking
  • 31. Create and Load the AOT Cache 1. Do a training run: launch the application with the JVM configured to record its class-loading behavior java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf -cp app.jar org.example.App 2. The recorded data is used to generate the AOT cache file java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -XX:AOTCache=app.aot -cp app.jar 3. Shifts much of the class-loading work from runtime to an earlier point, significantly reducing startup time. java -XX:AOTCache=app.aot -cp app.jar org.example.App
  • 32. Limitations and Workarounds • User-Defined Class Loaders: classes loaded dynamically by custom loaders are excluded from the cache. Future updates might address this gap if they prove significant. • Consistency Constraints: strict requirements for JDK versions and configurations can complicate deployment pipelines. Use tools like Docker to standardize environments can mitigate this issue. • Exclusion of ZGC: the Z Garbage Collector is not yet supported. Future updates will likely address this gap. JEP 483: Ahead-of-Time Class Loading & Linking
  • 33. Smaller Runtimes For a Leaner Future • It will be possible for a JDK to be built without JDK’s JMOD files. $ configure [ ... other options ... ] --enable-linkable-runtime $ make images • This feature can reduce JDK size by approximately 25%. • The default build configuration will remain as of today. It is up to each vendor to enable this feature. • The JDK impacts how jlink creates custom runtime images (with or without relying on JMOD files). • Nothing changes for jlink standard options, but a series of restrictions apply to it if part of a JDK built with --enable-linkable-runtime. JEP 493: Linking Run-Time Images without JMODs
  • 34. Better Performance by Shrinking Object Headers • The HotSpot JVM introduces a feature to reduce object header sizes from 96-128 bits to 64 bits on 64-bit architectures. • It aims to reduce memory footprints on real workloads, while maintaining minimal performance overheads. • As an experiment feature is currently off by default, must be enabled via: -XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders JEP 450: Compact Object Headers (Experimental)
  • 35. Unpinning Syncronized Virtual Threads • This initiative ensures that virtual threads running synchronized methods or statements no longer block their platform threads. • By redesigning the JVM's handling of monitors, virtual threads can now unmount from their carriers even when blocked. • This change eliminates the need to avoid synchronized constructs, allowing you to write clearer concurrent code. JEP 450: Compact Object Headers (Experimental)
  • 36. ZGC at a Glance • Delivered in JDK 15 (September 2020) • A scalable low-latency garbage collector • ZGC pauses are O(1) • Scalable: up to TB heaps • Auto-tuning: requires minimal configuration • Can handle heaps ranging from a 8MB to 16TB in size
  • 37. Benefits of Generational ZGC • Withstand higher allocation rates • Lower heap headroom • Lower CPU usage • Now enabled by default when using -XX:+UseZGC • Automatic Tuning -> Only set the max heap size! (-Xmx) JEP 474: ZGC: Generational Mode by Default
  • 38. What Changed for ZGC ? • Did you enable ZGC it with -XX:+UseZGC -XX:+ZGenerational? • Generational ZGC is used. An obsolete-option warning is printed. • What if you try -XX:+UseZGC -XX:-Zgenerational? • Generational ZGC is used. Warning that the non-generational mode is obsolete. JEP 490: ZGC: Remove the Non-Generational Mode
  • 39. Optimizing G1GC • To improve Java's scalability, G1GC now expands memory barriers late in the compilation process. • This enhancement is inspired by the approach used by the ZGC collector. • Reduces JIT compilation time by up to 20% and ensures the quality of generated code. • A more responsive Java platform, particularly for cloud-based deployments.
  • 40. So You Want to Know More… • Project Leyden: Improving Java’s Startup Time by Per Minborg, Sébastien Deleuze • Java Performance Update 2024 by Per Minborg • Project Leyden Update #JVMLS • Java 24 Stops Pinning Virtual Threads (Almost) - Inside Java Newscast #80 • Overview of ZGC • Deep-dive of zgc's architecture • JVMLS - generational ZGC and beyond • Optimizing memory utilization with automated heap sizing in ZGC • Z garbage collector: the next generation • ZGC : java’s highly scalable low-latency garbage collector - stack walker #1
  • 41. Fundamental Changes to Achieve Your Application Goals Core Libraries
  • 42. A New Form of Documentation Comment Markdown in Java documentation comments help with having: • concise syntax for common constructs, • reduce the dependence on HTML markup and JavaDoc tags, • while keep enabling the use of specialized tags when not available in Markdown. JEP 467: Markdown Documentation Comments
  • 44. Extra Capabilities • Define simple GitHub Flavored Markdown pipe tables. • Process standalone Markdown files from doc-files subdirectories. • Standalone Markdown files can have JavaDoc tags , but YAML metadata is not supported. • Enable syntax highlighting with Javascript libraries through javadoc --add-script. • Render diagrams (like Mermaid). JEP 467: Markdown Documentation Comments
  • 45. Unfulfilled Streams Operations • Streams API has a fixed set of intermediate operations. List<String> letters = Arrays.asList("A","B","C","D","E","F","G","H"); int size = 3; // ABC DEF GH IntStream.range(0, (letters.size() + size - 1) / size) .mapToObj(i -> String.join("", letters.subList(i * size, Math.min(size * (i + 1), letters.size())))) .toList(); Some intermediate operations are missing: sliding windows, take-while-including, fixed grouping,etc.
  • 46. The Gatherers API • A generalization for intermediate operations java.util.stream.Gatherer • A new intermediate stream operation to process elements of a stream: Stream::gather(Gatherer) • A few implementations, e.g. Gatherers.fold(…), Gatherers.windowFixed(…). • A way to compose gathererers source.gather(a.andThen(b).andThen(c)).collect(...). List<String> letters = Arrays.asList("A","B","C","D","E","F","G","H"); int size = 3; letters.stream() .gather(Gatherers.windowFixed(3)) .map(window -> String.join("", window)) .toList(); JEP 485: Stream Gatherers
  • 47. Gatherer Components Initializer (optional) • Creates private state object Integrator (mandatory) • Accepts (state, element, downstream) • Integrates element into state • to update gatherer’s private state object • to emit 0+ element(s) to downstream Combiner (optional) • Can evaluate the gatherer in parallel Finisher (optional) • Accepts (state, downstream) • Invoked when no more elements can be consumed • Emits element(s) to downstream
  • 48. Compiling And Launching a Java Program IDE javac java .java source file bytecode .class file Program running
  • 50. The New Class-file API • A stable Java API for analyzing and manipulating bytecode. • An API always-up-to-date with the JDK version. • Frameworks that use this API can easily update to a newer JDK version. JEP 484: Class-File API
  • 51. So You Want to Know More… • JavaDoc Hits the Markdown on Comments - Inside Java Newscast #68 • A Classfile API for the JDK (JVMLS 2023, Brian Goetz) • New Class-File API will make Java Updates easier - Inside Java Newscast #56 • Teaching Old Streams New Tricks (Devoxx Belgium 2023, Viktor Klang) • Better Java Streams with Gatherers - Inside Java Newscast #57 • Better Java Streams with Gatherers - JEP Cafe #23
  • 52. Broadened Ability to Develop High-Performance Programs
  • 53. Project Summary Pain point “Obvious" Competition Amber Right-sizing language ceremony “Java is too verbose" “Java is hard to teach" C#, Kotlin Babylon Foreign programming model interop “Using GPUs is too hard" LinQ, Julia Leyden Faster startup and warmup “Java starts up too slowly" Go Loom Lightweight concurrency “Threads are too expensive, don’t scale" Go, Elixir Panama Native code and memory interop SIMD Vector support “Using native libraries is too hard" “Numeric loops are too slow" Python, C Valhalla Value types and specialized generics “Cache misses are too expensive" “Generics and primitives don’t mix" C, C# ZGC Sub-millisecond GC pauses “GC pauses are too long" C, Rust
  • 54. Learn, Share, and Collaborate
  • 55. Stay Tuned for More Inside.java Dev.java youtube.com/java