Enforce publicly accessible method for externalClassLoader(ClassLoader)

Closes gh-36012
This commit is contained in:
Juergen Hoeller
2025-12-14 14:48:33 +01:00
parent ed451c107f
commit d99ace81c1
@@ -53,6 +53,7 @@ import org.springframework.context.MessageSource;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ReflectionUtils;
@@ -264,6 +265,7 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
if (this.applicationContext != null) {
try {
Method eclMethod = configuration.getClass().getMethod("externalClassLoader", ClassLoader.class);
eclMethod = ClassUtils.getPubliclyAccessibleMethodIfPossible(eclMethod, configuration.getClass());
ReflectionUtils.invokeMethod(eclMethod, configuration, this.applicationContext.getClassLoader());
}
catch (NoSuchMethodException ignored) {