1.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java Tue Dec 25 14:07:02 2012 +0100
1.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java Mon Jan 07 17:22:59 2013 +0100
1.3 @@ -21,9 +21,8 @@
1.4 import java.io.InputStream;
1.5 import java.lang.reflect.InvocationTargetException;
1.6 import java.lang.reflect.Method;
1.7 +import java.lang.reflect.Modifier;
1.8 import java.net.URL;
1.9 -import java.net.URLDecoder;
1.10 -import java.net.URLEncoder;
1.11 import java.util.Enumeration;
1.12 import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.13
1.14 @@ -113,7 +112,7 @@
1.15 return sb.toString();
1.16 }
1.17
1.18 - static String invoke(String clazz, String method) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
1.19 + static String invoke(String clazz, String method) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException {
1.20 final Object r = invokeMethod(clazz, method);
1.21 return r == null ? "null" : r.toString().toString();
1.22 }
1.23 @@ -151,7 +150,8 @@
1.24
1.25 private static Object invokeMethod(String clazz, String method)
1.26 throws ClassNotFoundException, InvocationTargetException,
1.27 - SecurityException, IllegalAccessException, IllegalArgumentException {
1.28 + SecurityException, IllegalAccessException, IllegalArgumentException,
1.29 + InstantiationException {
1.30 Method found = null;
1.31 Class<?> c = Class.forName(clazz);
1.32 for (Method m : c.getMethods()) {
1.33 @@ -161,7 +161,11 @@
1.34 }
1.35 Object res;
1.36 if (found != null) {
1.37 - res = found.invoke(null);
1.38 + if ((found.getModifiers() & Modifier.STATIC) != 0) {
1.39 + res = found.invoke(null);
1.40 + } else {
1.41 + res = found.invoke(c.newInstance());
1.42 + }
1.43 } else {
1.44 res = "Can't find method " + method + " in " + clazz;
1.45 }