[LANG-1350] ConstructorUtils.invokeConstructor(Class, Object...)
regression
This commit is contained in:
parent
05d9518038
commit
cc94767e7e
|
@ -47,6 +47,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
|
||||
<release version="3.7" date="tba" description="tba">
|
||||
<action issue="LANG-1346" type="update" dev="pschumacher">Remove deprecation from RandomStringUtils</action>
|
||||
<action issue="LANG-1350" type="update" dev="ggregory" due-to="Brett Kail">ConstructorUtils.invokeConstructor(Class, Object...) regression</action>
|
||||
</release>
|
||||
|
||||
<release version="3.6" date="2017-06-08" description="New features and bug fixes. Requires Java 7.">
|
||||
|
|
|
@ -255,6 +255,10 @@ abstract class MemberUtils {
|
|||
|
||||
private static boolean isMatchingExecutable(final Executable method, final Class<?>[] parameterTypes) {
|
||||
final Class<?>[] methodParameterTypes = method.getParameterTypes();
|
||||
if (ClassUtils.isAssignable(parameterTypes, methodParameterTypes, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (method.isVarArgs()) {
|
||||
int i;
|
||||
for (i = 0; i < methodParameterTypes.length - 1 && i < parameterTypes.length; i++) {
|
||||
|
@ -270,7 +274,8 @@ abstract class MemberUtils {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
return ClassUtils.isAssignable(parameterTypes, methodParameterTypes, true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,6 +77,11 @@ public class ConstructorUtilsTest {
|
|||
varArgs = s;
|
||||
}
|
||||
|
||||
public TestBean(final BaseClass bc, String... s) {
|
||||
toString = "(BaseClass, String...)";
|
||||
varArgs = s;
|
||||
}
|
||||
|
||||
public TestBean(final Integer i, final String... s) {
|
||||
toString = "(Integer, String...)";
|
||||
varArgs = s;
|
||||
|
@ -101,6 +106,10 @@ public class ConstructorUtilsTest {
|
|||
}
|
||||
}
|
||||
|
||||
private static class BaseClass {}
|
||||
|
||||
private static class SubClass extends BaseClass {}
|
||||
|
||||
static class PrivateClass {
|
||||
@SuppressWarnings("unused")
|
||||
public PrivateClass() {
|
||||
|
@ -157,6 +166,8 @@ public class ConstructorUtilsTest {
|
|||
.verify("(String...)", new String[]{"a", "b"});
|
||||
ConstructorUtils.invokeConstructor(TestBean.class, NumberUtils.INTEGER_ONE, "a", "b")
|
||||
.verify("(Integer, String...)", new String[]{"a", "b"});
|
||||
ConstructorUtils.invokeConstructor(TestBean.class, new SubClass(), new String[]{"a", "b"})
|
||||
.verify("(BaseClass, String...)", new String[]{"a", "b"});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -252,6 +263,9 @@ public class ConstructorUtilsTest {
|
|||
singletonArray(Double.class), singletonArray(Double.TYPE));
|
||||
expectMatchingAccessibleConstructorParameterTypes(TestBean.class,
|
||||
singletonArray(Double.TYPE), singletonArray(Double.TYPE));
|
||||
expectMatchingAccessibleConstructorParameterTypes(TestBean.class,
|
||||
new Class<?>[]{SubClass.class, String[].class},
|
||||
new Class<?>[]{BaseClass.class, String[].class});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue