-
Notifications
You must be signed in to change notification settings - Fork 37.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom on-demand CGLIB proxies are missing reflective proxy hints #29309
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
theme: aot
An issue related to Ahead-of-time processing
type: enhancement
A general enhancement
Milestone
Comments
Ran into the same issue with data-mongodb lazy loading proxies. I also had to add access to declared fields and ended up with this Class<?> proxyClass = LazyLoadingProxyFactory.resolveProxyType(field.getType(),() -> LazyLoadingInterceptor.none());
generationContext.getRuntimeHints().reflection().registerType(proxyClass,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS); to avoid
|
This was referenced Jan 4, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
theme: aot
An issue related to Ahead-of-time processing
type: enhancement
A general enhancement
When you generate CGLib proxy classes during the AOT phase by using the
ProxyFactory
, those classes will be picked up at runtime, but also need to be made available for reflection, asEnhancerFactoryData
's constructor will still try to lookup CGLib generated methods at runtime via reflection, and also actually try to call those during instance creation (EnhancerFactoryData.newInstance(…)
).This can be currently worked around by also explicitly registering reflection hints for the types that proxies have been created for.
It also looks like multiple invocations of same the
ProxyFactory
setup would create multiple CGLib proxy classes. So if application code accidently invokes a similar arrangement e.g. during the initialization of a static field (use case here: defining a static typed, Spring DataSort
instance viaSort.sort(MyType.class).by(MyType::getName)
and the initial step requiring the creation of a proxy instance), the reflection information will be registered for the other proxy class and the arrangement will still fail at runtime, as the hints have not been registered for the type created by the statically initialized field.The text was updated successfully, but these errors were encountered: