From 1ef701378d32a4c303dbca1037fbe05f7bbbc118 Mon Sep 17 00:00:00 2001 From: Silvan Heller Date: Tue, 26 Jul 2022 10:13:34 +0200 Subject: [PATCH] explicitly specifying type as Map for constructors --- .../org/vitrivr/cineast/core/util/ReflectionHelper.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/util/ReflectionHelper.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/util/ReflectionHelper.java index f26c93d08..053e385e0 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/util/ReflectionHelper.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/util/ReflectionHelper.java @@ -2,6 +2,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -282,6 +283,13 @@ public static T instantiate(Class cl, Object... args) { */ public static T instantiate(Class cl, Class[] types, Object... args) { try { + // for constructors expecting maps. + for (int i = 0, typesLength = types.length; i < typesLength; i++) { + if (Arrays.stream(types[0].getInterfaces()).anyMatch(c -> c == Map.class)) { + types[i] = Map.class; + } + } + Constructor con = cl.getConstructor(types); return con.newInstance(args); } catch (InvocationTargetException e) {