Auto-adapt reflective arguments in case of vararg array type mismatch

Issue: SPR-13328
This commit is contained in:
Juergen Hoeller
2015-10-26 22:43:37 +01:00
parent 1c382be00e
commit 8c4b8d253a
8 changed files with 136 additions and 29 deletions

View File

@@ -21,7 +21,6 @@ import java.io.Serializable;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import test.mixin.LockMixinAdvisor;
import org.springframework.aop.ClassFilter;
@@ -395,7 +394,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
public void testVarargsWithEnumArray() throws Exception {
ProxyFactory proxyFactory = new ProxyFactory(new MyBean());
MyBean proxy = (MyBean) proxyFactory.getProxy();
assertTrue(proxy.doWithVarargs(MyEnum.A, MyEnum.B));
assertTrue(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C));
}
@@ -432,6 +431,12 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
}
public enum MyOtherEnum implements MyInterface {
C, D;
}
public static class ExceptionThrower {
private boolean catchInvoked;

View File

@@ -138,6 +138,13 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
assertEquals("hashCode()", proxy.hashCode(), named.hashCode());
}
@Test // SPR-13328
public void testVarargsWithEnumArray() throws Exception {
ProxyFactory proxyFactory = new ProxyFactory(new VarargTestBean());
VarargTestInterface proxy = (VarargTestInterface) proxyFactory.getProxy();
assertTrue(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C));
}
public interface Foo {
@@ -201,4 +208,36 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
}
}
public interface VarargTestInterface {
<V extends MyInterface> boolean doWithVarargs(V... args);
}
public static class VarargTestBean implements VarargTestInterface {
@SuppressWarnings("unchecked")
@Override
public <V extends MyInterface> boolean doWithVarargs(V... args) {
return true;
}
}
public interface MyInterface {
}
public enum MyEnum implements MyInterface {
A, B;
}
public enum MyOtherEnum implements MyInterface {
C, D;
}
}