-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Introduce AOT generated class proxies #28115
Comments
Just a bit more context. I could have built my own proxy generation but it would have taken a while and I wasn't in a position to easily test it rigorously for all spring use cases. So I leveraged #1283 which replaced CGLIB with byte buddy because I knew that was passing the tests, and it would give me an easier route to pushing proxy generation to being something I could drive at build time rather than runtime. It had mechanisms for easily grabbing the bytecode for the proxy, and total control over the proxy naming (because when looking them up at runtime it had to exactly match what was created earlier). Importantly it was also generating a more optimal proxy that was using less of the generated support classes for invoking some methods. For 'well known' interfaces that the proxy was implementing it was directly wiring up the invocations. Whereas CGLIB was using a general approach for all methods, leading to lots of new classes. (However, hand crafting could have also performed these optimizations, obviously). The current version was definitely constructed as a building block. Ideally the necessary proxies could be more inferred rather than the user trying to work out what set of 'bits' they need to supply for proxy hints, or discovering it by trial and error when running the system is printing out the required hints. |
The commit encompassing all these changes in spring-native is spring-attic/spring-native@af0e804 |
Related topic : Spring Native we currently relies on Hibernate Build-time enhancement to perform Hibernate bytecode manipulation at build time. I mention that because:
Maybe a point to discuss with @mp911de, @schauder and @christophstrobl. |
This commit introduces a TransactionBeanRegistrationAotProcessor in charge of creating the required proxy and reflection hints when @transactional is detected on beans. It also refines DefaultAopProxyFactory to throw an exception when a subclass-based proxy is created in native images since that's unsupported for now (see spring-projectsgh-28115 related issue). Closes spring-projectsgh-28717
This commit introduces a TransactionBeanRegistrationAotProcessor in charge of creating the required proxy and reflection hints when @transactional is detected on beans. It also refines DefaultAopProxyFactory to throw an exception when a subclass-based proxy is created in native images since that's unsupported for now (see spring-projectsgh-28115 related issue). Closes spring-projectsgh-28717
There is an initial commit coming to main now: This includes runtime storing of generated classes to a directory specified by the "cglib.generatedClasses" system property, to be picked up by the build process for further inclusion in a jar file (and ultimately in a native image). We also avoid lazy CGLIB fast-class generation now and replace the generated Enhancer and MethodWrapper key classes with equivalent record types. Last but not least, this introduces support for early type determination in InstantiationStrategy, AopProxy and SmartInstantiationAwareBeanPostProcessor - in order to trigger CGLIB class generation in refreshForAotProcessing (through early determineBeanType calls for bean definitions). |
This test started failing after an upstream change in Spring Framework, see spring-projects/spring-framework#28115
GraalVM
native-image
only supports JDK dynamic proxies when configured explicitly on interfaces.For proxies on classes, typically created at runtime with CGLIB on the JVM, there is a need to create such proxies Ahead-Of-Time. That's what @aclement did in Spring Native:
Spring Framework 6 should provide similar support for AOT generated class proxies, potentially by:
DefaultAopProxyFactory
and/or other relevant classesThe text was updated successfully, but these errors were encountered: