Skip to content
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

Configure interface-based proxies in native images #31659

Closed
sdeleuze opened this issue Jul 8, 2022 · 6 comments
Closed

Configure interface-based proxies in native images #31659

sdeleuze opened this issue Jul 8, 2022 · 6 comments
Assignees
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@sdeleuze
Copy link
Contributor

sdeleuze commented Jul 8, 2022

Now that spring-projects/spring-framework#28717 is fixed, every Spring Boot application using Spring AOP requires to configure spring.aop.proxy-target-class=false in order to get it working on native since spring-projects/spring-framework#28115 is not going to be fixed in time for Spring Boot 3.0.0-M4.

If not set, the following fatal error is thrown at startup (on purpose): org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'runner': Subclass-based proxies are not support yet in native images.

In order to allow a reasonable developer experience, could Spring Boot 3 automatically configure spring.aop.proxy-target-class=false when NativeDetector#inNativeImage returns true?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 8, 2022
@mhalbritter mhalbritter added type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 8, 2022
@mhalbritter mhalbritter added this to the 3.0.x milestone Jul 8, 2022
@mhalbritter mhalbritter self-assigned this Jul 8, 2022
@wilkinsona
Copy link
Member

I wonder if we should use AotDetector#useGeneratedArtifacts rather than NativeDetector#inNativeImage? Doing so would reduce the chances of things working on the JVM with AOT and then failing in the native image.

@sdeleuze
Copy link
Contributor Author

sdeleuze commented Jul 8, 2022

Yeah that's another option if we consider JVM + AOT mainly from the perspective of testing native behavior on the JVM.

@philwebb
Copy link
Member

If we do change this setting for M4 we should open another issue to revert it in M5 or whenever cglib is supported. I think it's best long-term to keep JVM and Native aligned as much as possible.

@snicoll
Copy link
Member

snicoll commented Jul 10, 2022

FWIW I am not sure we should be doing this. Yes, the exception is very strange and hard to diagnose but working around that by changing the default with AOT sounds a bit odd to me.

I'd rather add something to the release notes.

@mhalbritter mhalbritter added the for: team-meeting An issue we'd like to discuss as a team to make progress label Jul 11, 2022
@mhalbritter
Copy link
Contributor

mhalbritter commented Jul 11, 2022

Let's discuss this in the team meeting.

Note to myself: The code which does this is in Spring native is the org.springframework.nativex.NativeListener.

@mhalbritter
Copy link
Contributor

mhalbritter commented Jul 11, 2022

We talked about it in our meeting and decided to close the issue without enabling JDK proxies. It's quite confusing to automatically switch all AOT users to JDK proxies as they have downsides. We'd rather wait for spring-projects/spring-framework#28115 to be completed. If it's not completed when we write end-user facing documentation on AOT, we'll add a bit in the documentation that users have to set spring.aop.proxy-target-class=false in their configuration (with all the downsides) until the class-based proxy issue is resolved.

@mhalbritter mhalbritter added status: declined A suggestion or change that we don't feel we should currently apply and removed type: enhancement A general enhancement for: team-meeting An issue we'd like to discuss as a team to make progress theme: aot An issue related to Ahead-of-time processing labels Jul 11, 2022
@mhalbritter mhalbritter removed this from the 3.0.x milestone Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

6 participants