Recent Posts
Archives

Posts Tagged ‘Java25’

PostHeaderIcon [VoxxedDaysTicino2026] Get The Most Out of Virtual Threads in Java 25: A Deep Dive

Lecturer

Christian Wörz is a freelance fullstack developer and Microsoft MVP, with over 14 years crafting code in Java, Kotlin, TypeScript, and JavaScript. He conducts trainings on AI, Java, and web technologies, speaking at conferences on concurrency and modern features.

Abstract

This article appraises Christian Wörz’s live coding session harnessing Java 25’s virtual threads, structured concurrency, and scoped values for concurrent web applications. It scrutinizes enhancements from Java 21, custom task scopes, and thread-local alternatives. Analyzing performance gains, synchronization fixes, and practical integrations, it contemplates scalability in real-world scenarios.

Evolutions in Virtual Threads

Christian elucidates virtual threads’ maturation: Unlike platform threads (1-2MB OS overhead), virtual threads reside in JVM, enabling millions affordably sans pools. Java 25 ameliorates synchronization: Pre-25, synchronized pinned virtual threads to carriers, blocking. Now, uncontended synchronized avoids pinning; contended allows temporary pinning sans full blockage. Contexts: Addresses scalability in I/O-bound apps. Implications: Boosts throughput, reduces latency.

Leveraging Structured Concurrency

StructuredTaskScope (preview) orchestrates subtasks hierarchically, ensuring completion or cancellation together. Christian live-codes a web app: Sequential fetches evolve to concurrent via scopes. Custom joiners (Java 25): Implement Joiner interface for tailored handling—e.g., first successful response. Code:

try (var scope = new StructuredTaskScope<>()) {
    var future1 = scope.fork(() -> fetch("url1"));
    var future2 = scope.fork(() -> fetch("url2"));
    scope.join();
    // Process results
}

Implications: Simplifies error propagation, enhances readability.

Scoped Values Over Thread Locals

Scoped values (stable Java 25) supplant thread locals in virtual threads/struct scopes, avoiding inheritance issues. Christian demonstrates: Bind values in runnables, accessible sans inheritance. Code:

private static final ScopedValue<String> USER = ScopedValue.newInstance();

ScopedValue.runWhere(USER, "user1", () -> {
    // Access USER.get()
});

Contexts: Mitigates data leakage in concurrent environs. Implications: Promotes immutability, safer sharing.

Practical Applications and Performance

Live iteration builds concurrent server: Virtual threads handle requests, scopes parallelize fetches, scoped values manage contexts. Java 25 fixes ensure efficiency. Implications: Ideal for high-concurrency without reactive complexity. In conclusion, Christian’s techniques optimize Java for modern workloads.

Links:

PostHeaderIcon [DevoxxGR2026] Bootiful Spring Boot 4: Exploring the Latest Advancements with Java 25

Lecturer
Josh Long is a Spring Developer Advocate at VMware, widely recognized as one of the most prominent voices in the Spring ecosystem. Known affectionately as “Mr. Spring,” he is the author of numerous books and a prolific speaker who travels the globe sharing insights on modern Java development. Long co-hosts the “Coffee with a Java Champion” YouTube channel and continues to champion practical, production-ready Spring applications.

Abstract
In this engaging session at Devoxx Greece 2026, Josh Long showcases the transformative capabilities of Spring Boot 4 alongside Java 25. Through live coding of a dog adoption service, he demonstrates powerful new features including virtual threads, API versioning, modular architecture with Spring Modulith, resilient patterns, and seamless integration with AI capabilities. The presentation highlights how the Spring ecosystem empowers developers to build scalable, observable, secure, and intelligent applications with remarkable efficiency.

Java 25 and the Evolution of Spring Boot 4

Spring Boot 4 represents a significant generational leap, aligned with Spring Framework 7. Long emphasizes the decomposition of auto-configuration, resulting in leaner classpaths and faster startup times. Java 25 introduces compelling enhancements, most notably the ability to run simple applications with a single void main() method, effectively delivering the first truly elegant Java scripting experience.

These advancements set the stage for building modern, efficient services that leverage the full power of the JVM while maintaining developer productivity.

Building a Modular Dog Adoption Service

Long begins with a practical example: a service to help adopt dogs. Using Spring Initializr, he configures a project with PostgreSQL, Spring Data JDBC, web support, security, observability through OpenTelemetry and Actuator, and development tools.

The application employs a clean, feature-oriented package structure rather than traditional layered architecture. Records simplify domain modeling, while Spring Data repositories provide type-safe data access with compile-time query generation via AOT processing—beneficial for both JVM and native image deployments.

API Versioning and Resilience Features

To handle evolving requirements, Long demonstrates Spring’s new API versioning capabilities. Multiple endpoint versions coexist, with sensible defaults and header-based selection, ensuring backward compatibility.

Resilience4j integration showcases retryable methods and circuit breakers. Long simulates downstream failures to illustrate automatic recovery, highlighting how declarative resilience patterns simplify robust service design.

Modular Architecture with Spring Modulith

A standout demonstration involves refactoring into feature modules—dogs, cats, and veterinary services—using Spring Modulith. This enforces architectural boundaries at compile time while supporting event-driven communication between modules through ApplicationModuleListener and the outbox pattern for reliable, eventually consistent inter-module interactions.

The framework automatically generates documentation, C4 architecture diagrams, and verifies module dependencies, bridging the gap between intended design and runtime reality.

Security and Production Readiness

Security configuration leverages Spring Security 7’s additive customizers, preserving sensible defaults while enabling features like one-time token login and password migration. Passkeys (WebAuthn) integration provides passwordless authentication using biometrics, representing a significant usability and security improvement.

Observability is built-in through Actuator and OpenTelemetry, with production considerations like resource limits addressed from the start.

Integrating AI Capabilities

Long concludes by incorporating Spring AI 2.0, demonstrating how to augment the application with intelligent assistants. Using skills and tool calling, the service can answer domain-specific questions about dogs and cats, showcasing the natural convergence of Spring Boot with modern AI workflows.

The Bright Future of Java and Spring Development

Throughout the session, Long reinforces that the combination of Java’s efficiency, Spring’s comprehensive ecosystem, and new generative AI tools positions developers exceptionally well. Despite industry hype cycles, the fundamentals of solid engineering—modularity, resilience, observability, and security—remain paramount.

Spring Boot 4 and Java 25 deliver the tools necessary to build systems that are faster, more scalable, more maintainable, and more intelligent than ever before.

Links: