Skip to content

Commit

Permalink
HBASE-26638 Cherry-pick the ReflectionUtils improvements in HBASE-21515
Browse files Browse the repository at this point in the history
… to branch-2 (#3993)

Signed-off-by: Yulin Niu <niuyulin@apache.org>
  • Loading branch information
Apache9 authored Jan 2, 2022
1 parent a67fb0a commit cd87e10
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ public static <T> Constructor<T> findConstructor(Class<T> type, Object... paramT

boolean match = true;
for (int i = 0; i < ctorParamTypes.length && match; ++i) {
Class<?> paramType = paramTypes[i].getClass();
match = (!ctorParamTypes[i].isPrimitive()) ? ctorParamTypes[i].isAssignableFrom(paramType) :
((int.class.equals(ctorParamTypes[i]) && Integer.class.equals(paramType)) ||
(long.class.equals(ctorParamTypes[i]) && Long.class.equals(paramType)) ||
(double.class.equals(ctorParamTypes[i]) && Double.class.equals(paramType)) ||
(char.class.equals(ctorParamTypes[i]) && Character.class.equals(paramType)) ||
(short.class.equals(ctorParamTypes[i]) && Short.class.equals(paramType)) ||
(boolean.class.equals(ctorParamTypes[i]) && Boolean.class.equals(paramType)) ||
(byte.class.equals(ctorParamTypes[i]) && Byte.class.equals(paramType)));
if (paramTypes[i] == null) {
match = !ctorParamTypes[i].isPrimitive();
} else {
Class<?> paramType = paramTypes[i].getClass();
match = (!ctorParamTypes[i].isPrimitive()) ? ctorParamTypes[i].isAssignableFrom(paramType)
: ((int.class.equals(ctorParamTypes[i]) && Integer.class.equals(paramType)) ||
(long.class.equals(ctorParamTypes[i]) && Long.class.equals(paramType)) ||
(double.class.equals(ctorParamTypes[i]) && Double.class.equals(paramType)) ||
(char.class.equals(ctorParamTypes[i]) && Character.class.equals(paramType)) ||
(short.class.equals(ctorParamTypes[i]) && Short.class.equals(paramType)) ||
(boolean.class.equals(ctorParamTypes[i]) && Boolean.class.equals(paramType)) ||
(byte.class.equals(ctorParamTypes[i]) && Byte.class.equals(paramType)));
}
}

if (match) {
Expand Down

0 comments on commit cd87e10

Please sign in to comment.