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?

Comment From: wilkinsona

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.

Comment From: sdeleuze

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

Comment From: philwebb

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.

Comment From: snicoll

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.

Comment From: mhalbritter

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.

Comment From: mhalbritter

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 https://github.com/spring-projects/spring-framework/issues/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.