From cd26ee071b3853e21afe1732244d666e231f21ed Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 24 Feb 2019 10:46:45 +0100 Subject: [PATCH] serial: fix constructor bug --- src/be/nikiroo/utils/serial/SerialUtils.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/be/nikiroo/utils/serial/SerialUtils.java b/src/be/nikiroo/utils/serial/SerialUtils.java index 114f80b..502d0ba 100644 --- a/src/be/nikiroo/utils/serial/SerialUtils.java +++ b/src/be/nikiroo/utils/serial/SerialUtils.java @@ -173,7 +173,6 @@ public class SerialUtils { throws ClassNotFoundException, NoSuchMethodException { String desc = null; - try { Class clazz = getClass(type); String className = clazz.getName(); @@ -209,8 +208,18 @@ public class SerialUtils { desc += end; // - ctor = clazz.getDeclaredConstructor(classes - .toArray(new Class[] {})); + try { + ctor = clazz.getDeclaredConstructor(classes + .toArray(new Class[] {})); + } catch (NoSuchMethodException nsme) { + // TODO: it seems e do not always need a parameter for each + // level, so we currently try "ALL" levels or "FIRST" level + // only -> we should check the actual rule and use it + ctor = clazz.getDeclaredConstructor(classes.get(0)); + Object firstParent = args.get(0); + args.clear(); + args.add(firstParent); + } desc = null; } else { ctor = clazz.getDeclaredConstructor(); -- 2.27.0