From 62c62c1bbf4bb15433afde9bf57157574ac778f7 Mon Sep 17 00:00:00 2001 From: Irtimaled Date: Thu, 4 Jun 2020 15:24:08 -0700 Subject: [PATCH] Fix bug in ReflectionHelper --- .../irtimaled/bbor/common/ReflectionHelper.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/irtimaled/bbor/common/ReflectionHelper.java b/src/main/java/com/irtimaled/bbor/common/ReflectionHelper.java index 4ade3c2..2911751 100644 --- a/src/main/java/com/irtimaled/bbor/common/ReflectionHelper.java +++ b/src/main/java/com/irtimaled/bbor/common/ReflectionHelper.java @@ -33,14 +33,21 @@ public class ReflectionHelper { if (rawType != fieldType) continue; Type[] actualTypeArguments = genericType.getActualTypeArguments(); - if (actualTypeArguments.length != genericTypeArguments.length) continue; - - for (int typeIndex = 0; typeIndex < actualTypeArguments.length; typeIndex++) { - if (actualTypeArguments[typeIndex] != genericTypeArguments[typeIndex]) return null; - } + if (!typesMatch(genericTypeArguments, actualTypeArguments)) continue; return field; } return null; } + + private static boolean typesMatch(Type[] left, Type[] right) { + if (left.length != right.length) return false; + + for (int index = 0; index < right.length; index++) { + if (right[index] != left[index]) { + return false; + } + } + return true; + } } -- 2.44.0