Skip to content

Commit e7758e4

Browse files
committed
Remove AopProxyUtils#completeJdkProxyInterfaces
Not required anymore since JDK dynamic proxies are inferred. Closes spring-projectsgh-28980
1 parent 501870e commit e7758e4

File tree

2 files changed

+0
-76
lines changed

2 files changed

+0
-76
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -93,46 +93,6 @@ public static Class<?> ultimateTargetClass(Object candidate) {
9393
return result;
9494
}
9595

96-
/**
97-
* Complete the set of interfaces that are typically required in a JDK dynamic
98-
* proxy generated by Spring AOP.
99-
* <p>Specifically, {@link SpringProxy}, {@link Advised}, and {@link DecoratingProxy}
100-
* will be appended to the set of user-specified interfaces.
101-
* <p>This method can be useful when registering
102-
* {@linkplain org.springframework.aot.hint.ProxyHints proxy hints} for Spring's
103-
* AOT support, as demonstrated in the following example which uses this method
104-
* via a {@code static} import.
105-
* <pre class="code">
106-
* RuntimeHints hints = ...
107-
* hints.proxies().registerJdkProxy(completeJdkProxyInterfaces(MyInterface.class));
108-
* </pre>
109-
* @param userInterfaces the set of user-specified interfaces implemented by
110-
* the component to be proxied
111-
* @return the complete set of interfaces that the proxy should implement
112-
* @throws IllegalArgumentException if a supplied {@code Class} is {@code null},
113-
* is not an {@linkplain Class#isInterface() interface}, or is a
114-
* {@linkplain Class#isSealed() sealed} interface
115-
* @since 6.0
116-
* @see SpringProxy
117-
* @see Advised
118-
* @see DecoratingProxy
119-
* @see org.springframework.aot.hint.RuntimeHints#proxies()
120-
* @see org.springframework.aot.hint.ProxyHints#registerJdkProxy(Class...)
121-
*/
122-
public static Class<?>[] completeJdkProxyInterfaces(Class<?>... userInterfaces) {
123-
List<Class<?>> completedInterfaces = new ArrayList<>(userInterfaces.length + 3);
124-
for (Class<?> ifc : userInterfaces) {
125-
Assert.notNull(ifc, "'userInterfaces' must not contain null values");
126-
Assert.isTrue(ifc.isInterface() && !ifc.isSealed(),
127-
() -> ifc.getName() + " must be a non-sealed interface");
128-
completedInterfaces.add(ifc);
129-
}
130-
completedInterfaces.add(SpringProxy.class);
131-
completedInterfaces.add(Advised.class);
132-
completedInterfaces.add(DecoratingProxy.class);
133-
return completedInterfaces.toArray(Class<?>[]::new);
134-
}
135-
13696
/**
13797
* Determine the complete set of interfaces to proxy for the given AOP configuration.
13898
* <p>This will always add the {@link Advised} interface unless the AdvisedSupport's

spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.aop.SpringProxy;
2424
import org.springframework.beans.testfixture.beans.ITestBean;
2525
import org.springframework.beans.testfixture.beans.TestBean;
26-
import org.springframework.core.DecoratingProxy;
2726

2827
import static org.assertj.core.api.Assertions.assertThat;
2928
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -109,41 +108,6 @@ void proxiedUserInterfacesWithNoInterface() {
109108
assertThatIllegalArgumentException().isThrownBy(() -> AopProxyUtils.proxiedUserInterfaces(proxy));
110109
}
111110

112-
@Test
113-
void completeJdkProxyInterfacesFromNullInterface() {
114-
assertThatIllegalArgumentException()
115-
.isThrownBy(() -> AopProxyUtils.completeJdkProxyInterfaces(ITestBean.class, null, Comparable.class))
116-
.withMessage("'userInterfaces' must not contain null values");
117-
}
118-
119-
@Test
120-
void completeJdkProxyInterfacesFromClassThatIsNotAnInterface() {
121-
assertThatIllegalArgumentException()
122-
.isThrownBy(() -> AopProxyUtils.completeJdkProxyInterfaces(TestBean.class))
123-
.withMessage(TestBean.class.getName() + " must be a non-sealed interface");
124-
}
125-
126-
@Test
127-
void completeJdkProxyInterfacesFromSealedInterface() {
128-
assertThatIllegalArgumentException()
129-
.isThrownBy(() -> AopProxyUtils.completeJdkProxyInterfaces(SealedInterface.class))
130-
.withMessage(SealedInterface.class.getName() + " must be a non-sealed interface");
131-
}
132-
133-
@Test
134-
void completeJdkProxyInterfacesFromSingleClass() {
135-
Class<?>[] jdkProxyInterfaces = AopProxyUtils.completeJdkProxyInterfaces(ITestBean.class);
136-
assertThat(jdkProxyInterfaces).containsExactly(
137-
ITestBean.class, SpringProxy.class, Advised.class, DecoratingProxy.class);
138-
}
139-
140-
@Test
141-
void completeJdkProxyInterfacesFromMultipleClasses() {
142-
Class<?>[] jdkProxyInterfaces = AopProxyUtils.completeJdkProxyInterfaces(ITestBean.class, Comparable.class);
143-
assertThat(jdkProxyInterfaces).containsExactly(
144-
ITestBean.class, Comparable.class, SpringProxy.class, Advised.class, DecoratingProxy.class);
145-
}
146-
147111

148112
sealed interface SealedInterface {
149113
}

0 commit comments

Comments
 (0)