diff --git a/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java b/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java index 4d2c5c443da..d71a1cf22d0 100644 --- a/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java +++ b/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java @@ -123,7 +123,6 @@ public class TestContextAotGenerator { mergedConfigMappings.add(mergedConfig, testClass); this.testRuntimeHintsRegistrars.forEach(registrar -> registrar.registerHints(this.runtimeHints, testClass, classLoader)); - this.mergedConfigRuntimeHints.registerHints(this.runtimeHints, mergedConfig, classLoader); }); MultiValueMap> initializerClassMappings = processAheadOfTime(mergedConfigMappings); @@ -141,10 +140,12 @@ public class TestContextAotGenerator { } private MultiValueMap> processAheadOfTime(MultiValueMap> mergedConfigMappings) { + ClassLoader classLoader = getClass().getClassLoader(); MultiValueMap> initializerClassMappings = new LinkedMultiValueMap<>(); mergedConfigMappings.forEach((mergedConfig, testClasses) -> { logger.debug(LogMessage.format("Generating AOT artifacts for test classes %s", testClasses.stream().map(Class::getName).toList())); + this.mergedConfigRuntimeHints.registerHints(this.runtimeHints, mergedConfig, classLoader); try { // Use first test class discovered for a given unique MergedContextConfiguration. Class testClass = testClasses.get(0);