|  | 
| 22 | 22 | import java.io.InputStreamReader; | 
| 23 | 23 | import java.io.StringWriter; | 
| 24 | 24 | import java.lang.reflect.Method; | 
|  | 25 | +import java.util.ArrayList; | 
|  | 26 | +import java.util.Arrays; | 
|  | 27 | +import java.util.Collections; | 
|  | 28 | +import java.util.List; | 
| 25 | 29 | import java.util.Map; | 
| 26 | 30 | import java.util.concurrent.atomic.AtomicInteger; | 
|  | 31 | +import java.util.stream.Collectors; | 
| 27 | 32 | 
 | 
| 28 | 33 | import org.apache.commons.logging.LogFactory; | 
| 29 | 34 | import org.junit.jupiter.api.Test; | 
|  | 
| 56 | 61 | import org.springframework.beans.testfixture.beans.IndexedTestBean; | 
| 57 | 62 | import org.springframework.beans.testfixture.beans.TestBean; | 
| 58 | 63 | import org.springframework.beans.testfixture.beans.factory.DummyFactory; | 
|  | 64 | +import org.springframework.context.ConfigurableApplicationContext; | 
|  | 65 | +import org.springframework.context.support.ClassPathXmlApplicationContext; | 
| 59 | 66 | import org.springframework.core.io.ClassPathResource; | 
| 60 | 67 | import org.springframework.core.io.FileSystemResource; | 
| 61 | 68 | import org.springframework.core.io.UrlResource; | 
| @@ -1336,6 +1343,15 @@ void replaceMethodOverrideWithSetterInjection() { | 
| 1336 | 1343 | 		assertThat(dos.lastArg).isEqualTo(s2); | 
| 1337 | 1344 | 	} | 
| 1338 | 1345 | 
 | 
|  | 1346 | +	@Test  // gh-31826 | 
|  | 1347 | +	void replaceNonOverloadedInterfaceMethodWithoutSpecifyingExplicitArgTypes() { | 
|  | 1348 | +		try (ConfigurableApplicationContext context = | 
|  | 1349 | +				new ClassPathXmlApplicationContext(DELEGATION_OVERRIDES_CONTEXT.getPath())) { | 
|  | 1350 | +			EchoService echoService = context.getBean(EchoService.class); | 
|  | 1351 | +			assertThat(echoService.echo("foo", "bar")).containsExactly("bar", "foo"); | 
|  | 1352 | +		} | 
|  | 1353 | +	} | 
|  | 1354 | + | 
| 1339 | 1355 | 	@Test | 
| 1340 | 1356 | 	void lookupOverrideOneMethodWithConstructorInjection() { | 
| 1341 | 1357 | 		DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); | 
| @@ -1891,3 +1907,20 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw | 
| 1891 | 1907 | 	} | 
| 1892 | 1908 | 
 | 
| 1893 | 1909 | } | 
|  | 1910 | + | 
|  | 1911 | +interface EchoService { | 
|  | 1912 | + | 
|  | 1913 | +	String[] echo(Object... objects); | 
|  | 1914 | +} | 
|  | 1915 | + | 
|  | 1916 | +class ReverseArrayMethodReplacer implements MethodReplacer { | 
|  | 1917 | + | 
|  | 1918 | +	@Override | 
|  | 1919 | +	public Object reimplement(Object obj, Method method, Object[] args) { | 
|  | 1920 | +		List<String> list = Arrays.stream((Object[]) args[0]) | 
|  | 1921 | +				.map(Object::toString) | 
|  | 1922 | +				.collect(Collectors.toCollection(ArrayList::new)); | 
|  | 1923 | +		Collections.reverse(list); | 
|  | 1924 | +		return list.toArray(String[]::new); | 
|  | 1925 | +	} | 
|  | 1926 | +} | 
0 commit comments