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;
* </p>
*
* @author niki
- *
+ *
*/
class Optional {
/***
* that has not been compiled into the code.
*
* @author niki
- *
+ *
*/
public class NotSupportedException extends Exception {
private static final long serialVersionUID = 1L;
*
* @param port
* the port to run on
- *
+ *
* @throws NotSupportedException
* in case the option is not supported
* @throws IOException
@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) {
} 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);
}
}