Enforce early initialization of CGLIB method proxies (for AOT processing)

For non-required method proxies, prefer regular reflective invocation instead.

See gh-29107
This commit is contained in:
Juergen Hoeller 2022-10-03 13:22:49 +02:00
parent 332961f833
commit d873f60fef
2 changed files with 8 additions and 1 deletions

View File

@ -541,7 +541,7 @@ class ConfigurationClassEnhancer {
if (method.getName().equals("getObject") && args.length == 0) {
return beanFactory.getBean(beanName);
}
return proxy.invoke(factoryBean, args);
return method.invoke(factoryBean, args);
});
return fbProxy;

View File

@ -55,6 +55,13 @@ public class MethodProxy {
proxy.sig1 = new Signature(name1, desc);
proxy.sig2 = new Signature(name2, desc);
proxy.createInfo = new CreateInfo(c1, c2);
// SPRING PATCH BEGIN: early initialization for overridden methods on subclasses
if (!c1.isInterface()) {
proxy.init();
}
// SPRING PATCH END
return proxy;
}