From: Irtimaled Date: Thu, 4 Jun 2020 22:24:08 +0000 (-0700) Subject: Fix bug in ReflectionHelper X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=62c62c1bbf4bb15433afde9bf57157574ac778f7;p=BoundingBoxOutlineReloaded.git Fix bug in ReflectionHelper --- 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; + } }