X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Flauncher%2FOptional.java;fp=src%2Fbe%2Fnikiroo%2Fjvcard%2Flauncher%2FOptional.java;h=40592f36ed6ff9622e0ce9eccbc8f24600434d50;hp=9ed726dfe857201285e9dc61078b632abb5c2d63;hb=10dd1e387d6a1834596ae70f48cf905d7b302131;hpb=d5260eeb873fcf2ef9855dedcd9e2a3a3a990582 diff --git a/src/be/nikiroo/jvcard/launcher/Optional.java b/src/be/nikiroo/jvcard/launcher/Optional.java index 9ed726d..40592f3 100644 --- a/src/be/nikiroo/jvcard/launcher/Optional.java +++ b/src/be/nikiroo/jvcard/launcher/Optional.java @@ -1,6 +1,7 @@ package be.nikiroo.jvcard.launcher; import java.io.IOException; +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; @@ -21,7 +22,7 @@ import be.nikiroo.jvcard.launcher.CardResult.MergeCallback; *

* * @author niki - * + * */ class Optional { /*** @@ -29,7 +30,7 @@ class Optional { * that has not been compiled into the code. * * @author niki - * + * */ public class NotSupportedException extends Exception { private static final long serialVersionUID = 1L; @@ -70,7 +71,7 @@ class Optional { * * @param port * the port to run on - * + * * @throws NotSupportedException * in case the option is not supported * @throws IOException @@ -124,9 +125,10 @@ class Optional { @SuppressWarnings("rawtypes") Class launcherClass = Class .forName("be.nikiroo.jvcard.tui.TuiLauncher"); - Method start = launcherClass.getDeclaredMethod("start", - new Class[] { Boolean.class, List.class }); - start.invoke(launcherClass.newInstance(), textMode, files); + Constructor cons = launcherClass.getConstructors()[0]; + Object instance = cons.newInstance(textMode, files); + Method start = launcherClass.getDeclaredMethod("start"); + start.invoke(instance); } catch (NoSuchMethodException e) { throw new Optional().new NotSupportedException(e, "TUI", true); } catch (ClassNotFoundException e) { @@ -140,6 +142,9 @@ class Optional { } catch (IllegalArgumentException e) { throw new Optional().new NotSupportedException(e, "TUI", false); } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new Optional().new NotSupportedException(e, "TUI", false); + } catch (IndexOutOfBoundsException e) { throw new Optional().new NotSupportedException(e, "TUI", false); } }