Skip to content

Support Spring Framework 5.3 through 7.0 - #679

Merged
skybber merged 1 commit into
HotswapProjects:masterfrom
wyhasany:spring-multi-version-support
Aug 12, 2026
Merged

Support Spring Framework 5.3 through 7.0#679
skybber merged 1 commit into
HotswapProjects:masterfrom
wyhasany:spring-multi-version-support

Conversation

@wyhasany

Copy link
Copy Markdown
Contributor

Summary

  • Recognize Spring 6+'s renamed CGLIB proxy classes ($$SpringCGLIB$$ instead of $$EnhancerBySpringCGLIB$$) so HotswapAgent's own wrapper proxy still gets built, which is what lets existing bean references survive a hot reload
  • Fall back to DefaultNamingPolicy when Spring 6 makes SpringNamingPolicy impossible to subclass, and reuse an already-defined helper class instead of crashing on a duplicate class definition after a partial failure
  • Support the javax.* / jakarta.* package split introduced in Spring 6 in the test suite: dual-annotate a few test beans, keep both dependency sets on the classpath, and add a spring5 (default) / spring6 Maven profile to pick the matching servlet API
  • Compile with -parameters, since Spring 6.1+ no longer reliably recovers constructor/@Bean parameter names from plain debug info, which broke a couple of name-based wiring tests
  • Add an opt-in, per-invocation JVM flag (extraTestJvmArgs) used only for Spring 7.0.8 to dodge an intermittent JVM crash caused by a JBR bug where the background JIT compiler races with HotswapAgent's live class redefinition
  • Refresh both run-tests.sh scripts (spring-plugin and spring-boot-plugin) to also exercise newer Spring/Spring Boot versions

Test plan

  • plugin/hotswap-agent-spring-plugin/run-tests.sh passes against Spring 5.3.37 (default profile)
  • Passes against Spring 6.0.10, 6.1.21 (-Pspring6)
  • Passes against Spring 7.0.8 (-Pspring6, with the extraTestJvmArgs JVM crash workaround)

The Spring plugin's tests previously only worked reliably against
Spring 6.0.x. This change fixes what breaks on 5.3, 6.1, and 7.0 too,
and documents why each fix is needed.

Recognize Spring 6+'s renamed proxy classes: HotswapAgent wraps every
Spring-proxied bean in its own extra proxy so old references keep
working after a class reload. It only did this for the old proxy
class name pattern (Foo$$EnhancerBySpringCGLIB$$...). Spring 6
renamed that pattern to Foo$$SpringCGLIB$$..., so the extra wrapper
silently stopped being created, breaking reload for any bean Spring
itself proxies (aspects, @transactional, etc). Now both patterns are
recognized.

Build that wrapper safely on Spring 6+: building the wrapper needs a
small helper class that extends Spring's own SpringNamingPolicy.
Spring 6 made that class impossible to subclass the normal way. We
now fall back to a different base class when that happens, and if a
partial failure already defined the helper class once, we reuse it
instead of crashing with "duplicate class definition".

Support old (javax.*) and new (jakarta.*) packages together: Spring 6
renamed several core annotation packages (javax.inject.Inject became
jakarta.inject.Inject, and the same for @PostConstruct). Test beans
now carry both, and both dependencies are on the classpath, so the
same source compiles and passes on either side of that rename. A new
Maven profile picks the matching servlet API: spring5 (javax, the
default) or spring6 (jakarta).

Turn on "-parameters" during compilation: Spring resolves some
constructor and @bean arguments by name at runtime. Spring 6.1
stopped reliably reading parameter names from plain debug info, so
two tests that rely on name-based wiring started failing. Compiling
with -parameters keeps real parameter names in the bytecode, which
fixes both.

Add an opt-in JVM flag for one JVM bug: Spring 7.0.8 occasionally
crashes the JVM during tests due to a bug in how the JVM's background
compiler interacts with HotswapAgent's live class redefinition. The
fix is a JVM flag that avoids the buggy code path, but it is only
applied to the Spring 7.0.8 test run so every other Spring version
keeps its normal performance.

Also refreshed both run-tests.sh scripts to point at newer
Spring/Spring Boot versions to test against.
@skybber

skybber commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Reviewed, seems OK. THANK you for contribution!

@skybber
skybber merged commit 383acdf into HotswapProjects:master Aug 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants