Skip to content

Exclude sealed interfaces from auto-proxying (for JDK 17 compatibility) #27027

Closed
@dreis2211

Description

@dreis2211

Hi,

I recently opened an issue to track the needed stuff for Spring-Boot in order to support Java 17. spring-projects/spring-boot#26767. I think it makes sense to have the same for Spring Framework.

Known issues:

  1. Sealed interfaces need to be handled e.g. when creating proxies.
@Bean
@Scope(proxyMode = ScopedProxyMode.INTERFACES)
String alpha() {
	return "alpha";
}

Essentially, under the hood it retrieves all interfaces of String here which also includes ConstantDesc which is a sealed interface and cannot be used when creating a proxy. See ScopedProxyFactoryBean.setBeanFactory:

if (!isProxyTargetClass() || beanType.isInterface() || Modifier.isPrivate(beanType.getModifiers())) {
        // This should filter sealed interfaces I guess
	pf.setInterfaces(ClassUtils.getAllInterfacesForClass(beanType, cbf.getBeanClassLoader()));
}

After a first look this probably needs to be handled more centrally and more places are potentially affected by sealed interfaces.

There is likely more to do for Java 17 support, but I wanted to kick this off. Feel free to add to this issue or repurpose it to only handle the specific issue.

Let me know if I can help.

Cheers,
Christoph

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions