|
17 | 17 | package org.springframework.aop.support;
|
18 | 18 |
|
19 | 19 | import java.lang.reflect.Method;
|
| 20 | +import java.util.List; |
20 | 21 |
|
21 | 22 | import org.junit.jupiter.api.Test;
|
22 | 23 |
|
23 | 24 | import org.springframework.aop.ClassFilter;
|
24 | 25 | import org.springframework.aop.MethodMatcher;
|
25 | 26 | import org.springframework.aop.Pointcut;
|
| 27 | +import org.springframework.aop.framework.ProxyFactory; |
26 | 28 | import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
27 | 29 | import org.springframework.aop.target.EmptyTargetSource;
|
28 | 30 | import org.springframework.aop.testfixture.interceptor.NopInterceptor;
|
29 | 31 | import org.springframework.beans.testfixture.beans.TestBean;
|
| 32 | +import org.springframework.core.ResolvableType; |
30 | 33 | import org.springframework.core.testfixture.io.SerializationTestUtils;
|
31 | 34 | import org.springframework.lang.Nullable;
|
32 | 35 | import org.springframework.util.ReflectionUtils;
|
|
37 | 40 | * @author Rod Johnson
|
38 | 41 | * @author Chris Beams
|
39 | 42 | * @author Sebastien Deleuze
|
| 43 | + * @author Juergen Hoeller |
40 | 44 | */
|
41 | 45 | class AopUtilsTests {
|
42 | 46 |
|
@@ -99,4 +103,36 @@ void testInvokeJoinpointUsingReflection() throws Throwable {
|
99 | 103 | assertThat(result).isEqualTo(name);
|
100 | 104 | }
|
101 | 105 |
|
| 106 | + @Test // gh-32365 |
| 107 | + void mostSpecificMethodBetweenJdkProxyAndTarget() throws Exception { |
| 108 | + Class<?> proxyClass = new ProxyFactory(new WithInterface()).getProxyClass(getClass().getClassLoader()); |
| 109 | + Method specificMethod = AopUtils.getMostSpecificMethod(proxyClass.getMethod("handle", List.class), WithInterface.class); |
| 110 | + assertThat(ResolvableType.forMethodParameter(specificMethod, 0).getGeneric().toClass()).isEqualTo(String.class); |
| 111 | + } |
| 112 | + |
| 113 | + @Test // gh-32365 |
| 114 | + void mostSpecificMethodBetweenCglibProxyAndTarget() throws Exception { |
| 115 | + Class<?> proxyClass = new ProxyFactory(new WithoutInterface()).getProxyClass(getClass().getClassLoader()); |
| 116 | + Method specificMethod = AopUtils.getMostSpecificMethod(proxyClass.getMethod("handle", List.class), WithoutInterface.class); |
| 117 | + assertThat(ResolvableType.forMethodParameter(specificMethod, 0).getGeneric().toClass()).isEqualTo(String.class); |
| 118 | + } |
| 119 | + |
| 120 | + |
| 121 | + interface ProxyInterface { |
| 122 | + |
| 123 | + void handle(List<String> list); |
| 124 | + } |
| 125 | + |
| 126 | + static class WithInterface implements ProxyInterface { |
| 127 | + |
| 128 | + public void handle(List<String> list) { |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + static class WithoutInterface { |
| 133 | + |
| 134 | + public void handle(List<String> list) { |
| 135 | + } |
| 136 | + } |
| 137 | + |
102 | 138 | }
|
0 commit comments