Auto-adapt reflective arguments in case of vararg array type mismatch
Issue: SPR-13328
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user