HBASE-26638 Cherry-pick the ReflectionUtils improvements in HBASE-21515 to branch-2 (#3993)
Signed-off-by: Yulin Niu <niuyulin@apache.org>
This commit is contained in:
parent
efeec919de
commit
4d5fe404f4
|
@ -83,9 +83,12 @@ public class ReflectionUtils {
|
||||||
|
|
||||||
boolean match = true;
|
boolean match = true;
|
||||||
for (int i = 0; i < ctorParamTypes.length && match; ++i) {
|
for (int i = 0; i < ctorParamTypes.length && match; ++i) {
|
||||||
|
if (paramTypes[i] == null) {
|
||||||
|
match = !ctorParamTypes[i].isPrimitive();
|
||||||
|
} else {
|
||||||
Class<?> paramType = paramTypes[i].getClass();
|
Class<?> paramType = paramTypes[i].getClass();
|
||||||
match = (!ctorParamTypes[i].isPrimitive()) ? ctorParamTypes[i].isAssignableFrom(paramType) :
|
match = (!ctorParamTypes[i].isPrimitive()) ? ctorParamTypes[i].isAssignableFrom(paramType)
|
||||||
((int.class.equals(ctorParamTypes[i]) && Integer.class.equals(paramType)) ||
|
: ((int.class.equals(ctorParamTypes[i]) && Integer.class.equals(paramType)) ||
|
||||||
(long.class.equals(ctorParamTypes[i]) && Long.class.equals(paramType)) ||
|
(long.class.equals(ctorParamTypes[i]) && Long.class.equals(paramType)) ||
|
||||||
(double.class.equals(ctorParamTypes[i]) && Double.class.equals(paramType)) ||
|
(double.class.equals(ctorParamTypes[i]) && Double.class.equals(paramType)) ||
|
||||||
(char.class.equals(ctorParamTypes[i]) && Character.class.equals(paramType)) ||
|
(char.class.equals(ctorParamTypes[i]) && Character.class.equals(paramType)) ||
|
||||||
|
@ -93,6 +96,7 @@ public class ReflectionUtils {
|
||||||
(boolean.class.equals(ctorParamTypes[i]) && Boolean.class.equals(paramType)) ||
|
(boolean.class.equals(ctorParamTypes[i]) && Boolean.class.equals(paramType)) ||
|
||||||
(byte.class.equals(ctorParamTypes[i]) && Byte.class.equals(paramType)));
|
(byte.class.equals(ctorParamTypes[i]) && Byte.class.equals(paramType)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
return ctor;
|
return ctor;
|
||||||
|
|
Loading…
Reference in New Issue