Support Spring Framework 5.3 through 7.0 - #679
Merged
skybber merged 1 commit intoAug 12, 2026
Merged
Conversation
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.
Contributor
|
Reviewed, seems OK. THANK you for contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
$$SpringCGLIB$$instead of$$EnhancerBySpringCGLIB$$) so HotswapAgent's own wrapper proxy still gets built, which is what lets existing bean references survive a hot reloadDefaultNamingPolicywhen Spring 6 makesSpringNamingPolicyimpossible to subclass, and reuse an already-defined helper class instead of crashing on a duplicate class definition after a partial failurejavax.*/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 aspring5(default) /spring6Maven profile to pick the matching servlet API-parameters, since Spring 6.1+ no longer reliably recovers constructor/@Beanparameter names from plain debug info, which broke a couple of name-based wiring testsextraTestJvmArgs) 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 redefinitionrun-tests.shscripts (spring-plugin and spring-boot-plugin) to also exercise newer Spring/Spring Boot versionsTest plan
plugin/hotswap-agent-spring-plugin/run-tests.shpasses against Spring 5.3.37 (default profile)-Pspring6)-Pspring6, with theextraTestJvmArgsJVM crash workaround)