-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged or decided on
label
Oct 12, 2022
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
|
jhoeller
changed the title
CGLib proxy creation during AOT needs to register reflective proxy hints
Lazy resolution proxies and other on-demand CGLIB proxies are missing reflective proxy hints
Nov 26, 2022
jhoeller
added
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
and removed
status: waiting-for-triage
An issue we've not yet triaged or decided on
labels
Nov 26, 2022
jhoeller
changed the title
Lazy resolution proxies and other on-demand CGLIB proxies are missing reflective proxy hints
Custom on-demand CGLIB proxies are missing reflective proxy hints
Nov 26, 2022
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: