From: Niki Roo Date: Sun, 24 Feb 2019 09:46:45 +0000 (+0100) Subject: serial: fix constructor bug X-Git-Tag: fanfix-swing-0.0.1~21^2~186 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=cd26ee071b3853e21afe1732244d666e231f21ed;p=fanfix-swing.git serial: fix constructor bug --- diff --git a/src/be/nikiroo/utils/serial/SerialUtils.java b/src/be/nikiroo/utils/serial/SerialUtils.java index 114f80b2..502d0ba7 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();