From: Tuukka Lehtonen Date: Mon, 25 Feb 2019 12:20:49 +0000 (+0000) Subject: Merge "Search deeply for generic superclass in ReflectionUtils" into release/1.35.1 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=682e6248064374437364c3f209699321f466ce3e;hp=8907f08d951e5f266b2d9a105f35ed622e72ae17;p=simantics%2Fplatform.git Merge "Search deeply for generic superclass in ReflectionUtils" into release/1.35.1 --- diff --git a/bundles/org.simantics.utils/src/org/simantics/utils/ReflectionUtils.java b/bundles/org.simantics.utils/src/org/simantics/utils/ReflectionUtils.java index b9d794e40..7f0f6c589 100644 --- a/bundles/org.simantics.utils/src/org/simantics/utils/ReflectionUtils.java +++ b/bundles/org.simantics.utils/src/org/simantics/utils/ReflectionUtils.java @@ -58,6 +58,14 @@ public class ReflectionUtils { public static Class getSingleParameterTypeExtending(Class clazz) { Type t = clazz.getGenericSuperclass(); + while (t instanceof Class) { + Class cl = (Class) t; + t = cl.getGenericSuperclass(); + if (t == null) { + // according to javadoc, we have reached java.lang.Object so no can do + break; + } + } if(t instanceof Class) { throw new UnsupportedOperationException("Missing parameter type for input class '" + clazz.getCanonicalName() + "'"); } else if (t instanceof ParameterizedType) {