From 31cd74b74d3a09bd2d4b4ac580bae4b272828e4c Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 5 Dec 2018 11:18:47 +0200 Subject: [PATCH] Search deeply for generic superclass in ReflectionUtils gitlab #224 Needed for district. Change-Id: I3f3decead033c62726c5919b2b3f36b786de5135 (cherry picked from commit 8905e67e82991121305889e6474a124d6ec79bf8) --- .../src/org/simantics/utils/ReflectionUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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) { -- 2.47.1