Spring Framework 6: Infrastructure Themes

VMware Tanzu
VMware TanzuVMware Tanzu
│©2023 VMware, Inc.
Spring Framework 6:
Infrastructure Themes
Juergen Hoeller
JDK 17+
Jakarta EE 9 / 10 (jakarta namespace)
AOT (Ahead-Of-Time)
Virtual Threads (“Project Loom”)
A new generation of Spring for 2023 and beyond
Java and Jakarta
JDK 17
(LTS)
Spring Framework
6.0 GA
Mar 2023
Mar 2022
JDK 18
Sep 2021
JDK 19
Sep 2022
JDK 20
Sep 2023
JDK 21
(LTS)
Nov 2022
Spring Framework
6.1 GA
Nov 2023
Baseline: JDK 17 LTS
Language: text blocks, switch expressions
Core libraries: collection factory methods, etc
Type system: records, sealed classes
Module system: module introspection, module path scanning
Empowering the framework as well as applications
JDK 17 / 19 / 21
Spring generally embraces the latest JDK/JVM versions
JDK 17 baseline retained for long-term support purposes
E.g. in JDK 19: virtual threads, record patterns (preview)
JDK 21 on the horizon as next long-term support release
Consider upgrading your JDK along with Spring Framework 6.x
Baseline: Jakarta EE 9
Servlet API 5.0 : javax.servlet → jakarta.servlet
JPA 3.0 : javax.persistence → jakarta.persistence
Bean Validation 3.0 : javax.validation → jakarta.validation
Dependency Injection 2.0 : javax.inject → jakarta.inject
All further API evolution to happen in jakarta namespace
Jakarta EE 9 / 10
Tomcat 10.0 / 10.1 – Servlet API 5.0 / 6.0
Jetty 11 / 12 – Servlet API 5.0 / 6.0
Undertow 2.3 – Servlet API 6.0
Hibernate ORM 6.1 – JPA 3.0 / 3.1
Hibernate Validator 7.0 / 8.0 – Bean Validation 3.0
Note: API upgrades not coupled to major provider versions anymore!
Jakarta EE 10 preferred
Spring Framework 6.0 auto-detects EE 10 APIs at runtime
E.g. using EE 10’s WebSocket protocol upgrade API
Spring Boot 3.0 effectively ships EE 10 APIs and providers
One exception: Jetty 11, since Jetty 12 is not final yet
Note: Spring’s Servlet mocks are Servlet 6.0 (EE 10) based
Hibernate, Netty, Jackson
Hibernate ORM: 5.6+, with 6.1 recommended
Note: Hibernate ORM 6.0+ only supported via JPA
Netty: 4.1.x
Early support for Netty 5 (not final yet)
Jackson: 2.14
Ahead-Of-Time
Spring AOT
Reducing startup time and memory footprint in production
Runtime hints for reflection, resources, serialization, proxies
Optional for optimized JVM deployments
Precondition for GraalVM native executables
AOT is a tradeoff: extra build setup and less flexibility at runtime
GraalVM Native Image
GraalVM as the de-facto standard for native executables
Strong closed-world assumption, no runtime adaptations
AOT-processed application as input → native executable
Very long build time for actual native code generation
A different mode of deployment with strong benefits and limitations
Project Leyden
OpenJDK aims to introduce well-defined static images
E.g. custom HotSpot-based runtime images for specific applications
Incremental approach: weaker constraints → more runtime flexibility
Strict closed-world constraint as the end of the spectrum
Spring’s AOT strategy aligning with Leyden’s JVM strategy
Project CRaC
“Coordinated Restore at Checkpoint” (developed by Azul)
Bootstrapping from a warmed-up HotSpot JVM snapshot
With Spring: a checkpoint after application context refresh
Same approach: AWS Lambda SnapStart
A potentially simple solution for improved JVM startup time
Evolving in 2023
GraalVM 23+ aligning its release schedule with OpenJDK
Project Galahad: GraalVM technology merging into OpenJDK
Project Leyden defining a specification for static image variants
Potential CRaC support in standalone JDK offerings
Mainstream adoption of native executables?
Virtual Threads
Project Loom
JDK 19 finally includes Project Loom as a regular preview
Virtual threads as a lightweight threading model within the JVM
A different magnitude of scalability for imperative programming
Implemented as virtual variants of java.lang.Thread
Not blocking an operating system thread on I/O operations
Virtual Threads for Web Applications
Servlet callback methods based on InputStream / OutputStream
As an option: Tomcat / Jetty executor setup for virtual threads
Loom-ready database drivers, scalable connection pool setup
Ideally no changes necessary in the main application codebase
Significant scalability benefits expected for database-driven web apps
Virtual Threads for Messaging / Scheduling
Spring-managed task executors with virtual thread options
E.g. for JMS message listener containers
E.g. for @Scheduled handler methods
Many of those listeners and handlers trigger I/O operations
Note: no benefits to be expected at all for purely CPU-bound handlers
Virtual Threads versus Reactive Programming
Virtual threads provide a different scalability mechanism
Traditional imperative programming style, revisited
Empowering Spring MVC to reach a new level of scalability
Spring WebFlux as an architecture for stream-based processing
Reactive: stream-based style, not primarily for scalability (anymore)
Embracing Virtual Threads
Higher scalability needed for Servlet deployments
Or same concurrency but with a smaller footprint
Best possible use of available CPU resources
Virtual threads supported in GraalVM Native Image as well
High expectations in the community
JDK 17
(LTS)
Spring Framework
6.0 GA
Mar 2023
Mar 2022
JDK 18
Sep 2021
JDK 19
Sep 2022
JDK 20
Sep 2023
JDK 21
(LTS)
Nov 2022
Spring Framework
6.1 GA
Nov 2023
Spring Framework 6.0 – available now
Foundation for Spring Boot 3.0 & 3.1
Production-ready on JDK 17 LTS
Regular stream of 6.0.x releases in 2023
Spring Framework 6.1 – November 2023
Foundation for Spring Boot 3.2 & 3.3
Production-ready on JDK 17 & 21 LTS
Release candidate expected in September 2023
Spring Framework 6 is here!
Enjoy the upgrade
(at your own pace)
1 of 26

More Related Content

More from VMware Tanzu(20)

tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
VMware Tanzu153 views
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - French
VMware Tanzu13 views

Recently uploaded(20)

Spring Framework 6: Infrastructure Themes

  • 1. │©2023 VMware, Inc. Spring Framework 6: Infrastructure Themes Juergen Hoeller
  • 2. JDK 17+ Jakarta EE 9 / 10 (jakarta namespace) AOT (Ahead-Of-Time) Virtual Threads (“Project Loom”) A new generation of Spring for 2023 and beyond
  • 3. Java and Jakarta
  • 4. JDK 17 (LTS) Spring Framework 6.0 GA Mar 2023 Mar 2022 JDK 18 Sep 2021 JDK 19 Sep 2022 JDK 20 Sep 2023 JDK 21 (LTS) Nov 2022 Spring Framework 6.1 GA Nov 2023
  • 5. Baseline: JDK 17 LTS Language: text blocks, switch expressions Core libraries: collection factory methods, etc Type system: records, sealed classes Module system: module introspection, module path scanning Empowering the framework as well as applications
  • 6. JDK 17 / 19 / 21 Spring generally embraces the latest JDK/JVM versions JDK 17 baseline retained for long-term support purposes E.g. in JDK 19: virtual threads, record patterns (preview) JDK 21 on the horizon as next long-term support release Consider upgrading your JDK along with Spring Framework 6.x
  • 7. Baseline: Jakarta EE 9 Servlet API 5.0 : javax.servlet → jakarta.servlet JPA 3.0 : javax.persistence → jakarta.persistence Bean Validation 3.0 : javax.validation → jakarta.validation Dependency Injection 2.0 : javax.inject → jakarta.inject All further API evolution to happen in jakarta namespace
  • 8. Jakarta EE 9 / 10 Tomcat 10.0 / 10.1 – Servlet API 5.0 / 6.0 Jetty 11 / 12 – Servlet API 5.0 / 6.0 Undertow 2.3 – Servlet API 6.0 Hibernate ORM 6.1 – JPA 3.0 / 3.1 Hibernate Validator 7.0 / 8.0 – Bean Validation 3.0 Note: API upgrades not coupled to major provider versions anymore!
  • 9. Jakarta EE 10 preferred Spring Framework 6.0 auto-detects EE 10 APIs at runtime E.g. using EE 10’s WebSocket protocol upgrade API Spring Boot 3.0 effectively ships EE 10 APIs and providers One exception: Jetty 11, since Jetty 12 is not final yet Note: Spring’s Servlet mocks are Servlet 6.0 (EE 10) based
  • 10. Hibernate, Netty, Jackson Hibernate ORM: 5.6+, with 6.1 recommended Note: Hibernate ORM 6.0+ only supported via JPA Netty: 4.1.x Early support for Netty 5 (not final yet) Jackson: 2.14
  • 11. Ahead-Of-Time
  • 12. Spring AOT Reducing startup time and memory footprint in production Runtime hints for reflection, resources, serialization, proxies Optional for optimized JVM deployments Precondition for GraalVM native executables AOT is a tradeoff: extra build setup and less flexibility at runtime
  • 13. GraalVM Native Image GraalVM as the de-facto standard for native executables Strong closed-world assumption, no runtime adaptations AOT-processed application as input → native executable Very long build time for actual native code generation A different mode of deployment with strong benefits and limitations
  • 14. Project Leyden OpenJDK aims to introduce well-defined static images E.g. custom HotSpot-based runtime images for specific applications Incremental approach: weaker constraints → more runtime flexibility Strict closed-world constraint as the end of the spectrum Spring’s AOT strategy aligning with Leyden’s JVM strategy
  • 15. Project CRaC “Coordinated Restore at Checkpoint” (developed by Azul) Bootstrapping from a warmed-up HotSpot JVM snapshot With Spring: a checkpoint after application context refresh Same approach: AWS Lambda SnapStart A potentially simple solution for improved JVM startup time
  • 16. Evolving in 2023 GraalVM 23+ aligning its release schedule with OpenJDK Project Galahad: GraalVM technology merging into OpenJDK Project Leyden defining a specification for static image variants Potential CRaC support in standalone JDK offerings Mainstream adoption of native executables?
  • 17. Virtual Threads
  • 18. Project Loom JDK 19 finally includes Project Loom as a regular preview Virtual threads as a lightweight threading model within the JVM A different magnitude of scalability for imperative programming Implemented as virtual variants of java.lang.Thread Not blocking an operating system thread on I/O operations
  • 19. Virtual Threads for Web Applications Servlet callback methods based on InputStream / OutputStream As an option: Tomcat / Jetty executor setup for virtual threads Loom-ready database drivers, scalable connection pool setup Ideally no changes necessary in the main application codebase Significant scalability benefits expected for database-driven web apps
  • 20. Virtual Threads for Messaging / Scheduling Spring-managed task executors with virtual thread options E.g. for JMS message listener containers E.g. for @Scheduled handler methods Many of those listeners and handlers trigger I/O operations Note: no benefits to be expected at all for purely CPU-bound handlers
  • 21. Virtual Threads versus Reactive Programming Virtual threads provide a different scalability mechanism Traditional imperative programming style, revisited Empowering Spring MVC to reach a new level of scalability Spring WebFlux as an architecture for stream-based processing Reactive: stream-based style, not primarily for scalability (anymore)
  • 22. Embracing Virtual Threads Higher scalability needed for Servlet deployments Or same concurrency but with a smaller footprint Best possible use of available CPU resources Virtual threads supported in GraalVM Native Image as well High expectations in the community
  • 23. JDK 17 (LTS) Spring Framework 6.0 GA Mar 2023 Mar 2022 JDK 18 Sep 2021 JDK 19 Sep 2022 JDK 20 Sep 2023 JDK 21 (LTS) Nov 2022 Spring Framework 6.1 GA Nov 2023
  • 24. Spring Framework 6.0 – available now Foundation for Spring Boot 3.0 & 3.1 Production-ready on JDK 17 LTS Regular stream of 6.0.x releases in 2023
  • 25. Spring Framework 6.1 – November 2023 Foundation for Spring Boot 3.2 & 3.3 Production-ready on JDK 17 & 21 LTS Release candidate expected in September 2023
  • 26. Spring Framework 6 is here! Enjoy the upgrade (at your own pace)