Skip to content

Fall back from cglib to JDK proxies when possible #31634

Open
@chrylis

Description

@chrylis

I am using Spring Boot 2.7, which defaults to cglib proxies. I have a JavaConfig bean definition:

interface ServiceInterface {
  @Async void log()
}

@Bean
ServiceInterface myBean() {
  new Impl()
}

If the Impl class is not subclassable by cglib (in this case, it uses a static factory method and has a private constructor), context startup fails with a "cglib can't subclass" error. However, if the declared bean type is an interface, in my view the ProxyFactory ought to use a JDK proxy instead (in the first place, but certainly if cglib fails).

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions