1.1 --- a/emul/src/main/java/java/lang/reflect/Method.java Mon Jan 07 17:22:59 2013 +0100
1.2 +++ b/emul/src/main/java/java/lang/reflect/Method.java Mon Jan 07 18:27:01 2013 +0100
1.3 @@ -512,6 +512,9 @@
1.4 throws IllegalAccessException, IllegalArgumentException,
1.5 InvocationTargetException
1.6 {
1.7 + if ((getModifiers() & Modifier.STATIC) == 0 && obj == null) {
1.8 + throw new NullPointerException();
1.9 + }
1.10 Object res = invoke0(this, obj, args);
1.11 if (getReturnType().isPrimitive()) {
1.12 res = fromPrimitive(getReturnType(), res);
1.13 @@ -547,7 +550,9 @@
1.14 if (type == Short.TYPE) {
1.15 return fromRaw(Short.class, "valueOf__Ljava_lang_Short_2S", o);
1.16 }
1.17 -// case 'V': return Void.TYPE;
1.18 + if (type.getName().equals("void")) {
1.19 + return null;
1.20 + }
1.21 throw new IllegalStateException("Can't convert " + o);
1.22 }
1.23
2.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java Mon Jan 07 17:22:59 2013 +0100
2.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Console.java Mon Jan 07 18:27:01 2013 +0100
2.3 @@ -161,10 +161,14 @@
2.4 }
2.5 Object res;
2.6 if (found != null) {
2.7 - if ((found.getModifiers() & Modifier.STATIC) != 0) {
2.8 - res = found.invoke(null);
2.9 - } else {
2.10 - res = found.invoke(c.newInstance());
2.11 + try {
2.12 + if ((found.getModifiers() & Modifier.STATIC) != 0) {
2.13 + res = found.invoke(null);
2.14 + } else {
2.15 + res = found.invoke(c.newInstance());
2.16 + }
2.17 + } catch (Exception ex) {
2.18 + res = ex.getClass().getName() + ":" + ex.getMessage();
2.19 }
2.20 } else {
2.21 res = "Can't find method " + method + " in " + clazz;
3.1 --- a/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/Bck2BrwsrCase.java Mon Jan 07 17:22:59 2013 +0100
3.2 +++ b/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/Bck2BrwsrCase.java Mon Jan 07 18:27:01 2013 +0100
3.3 @@ -20,6 +20,7 @@
3.4 import java.io.File;
3.5 import java.io.FileWriter;
3.6 import java.io.IOException;
3.7 +import java.lang.reflect.InvocationTargetException;
3.8 import java.lang.reflect.Method;
3.9 import java.util.Map;
3.10 import java.util.WeakHashMap;
3.11 @@ -52,7 +53,12 @@
3.12 MethodInvocation c = l.invokeMethod(m.getDeclaringClass(), m.getName());
3.13 value = c.toString();
3.14 } else {
3.15 - value = m.invoke(m.getDeclaringClass().newInstance());
3.16 + try {
3.17 + value = m.invoke(m.getDeclaringClass().newInstance());
3.18 + } catch (InvocationTargetException ex) {
3.19 + Throwable t = ex.getTargetException();
3.20 + value = t.getClass().getName() + ":" + t.getMessage();
3.21 + }
3.22 }
3.23 }
3.24
4.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java Mon Jan 07 17:22:59 2013 +0100
4.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CloneTest.java Mon Jan 07 18:27:01 2013 +0100
4.3 @@ -28,12 +28,9 @@
4.4 public class CloneTest {
4.5 private int value;
4.6
4.7 - @Compare public Object notSupported() {
4.8 - try {
4.9 - return this.clone();
4.10 - } catch (CloneNotSupportedException ex) {
4.11 - return ex.getClass().getName() + ":" + ex.getMessage();
4.12 - }
4.13 + @Compare
4.14 + public Object notSupported() throws CloneNotSupportedException {
4.15 + return this.clone();
4.16 }
4.17
4.18 @Compare public String sameClass() throws CloneNotSupportedException {
5.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java Mon Jan 07 17:22:59 2013 +0100
5.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java Mon Jan 07 18:27:01 2013 +0100
5.3 @@ -39,6 +39,10 @@
5.4 return Integer.TYPE.toString();
5.5 }
5.6
5.7 + @Compare public String voidType() throws Exception {
5.8 + return void.class.toString();
5.9 + }
5.10 +
5.11 @Compare public String longClass() {
5.12 return long.class.toString();
5.13 }
5.14 @@ -56,6 +60,15 @@
5.15 return sb.toString();
5.16 }
5.17
5.18 + @Compare public String cannotCallNonStaticMethodWithNull() throws Exception {
5.19 + try {
5.20 + StaticUse.class.getMethod("instanceMethod").invoke(null);
5.21 + return "should not happen";
5.22 + } catch (Exception ex) {
5.23 + return ex.getClass().getName() + ":" + ex.getMessage();
5.24 + }
5.25 + }
5.26 +
5.27 @Compare public String newInstanceFails() throws InstantiationException {
5.28 try {
5.29 return "success: " + StaticUse.class.newInstance();
6.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java Mon Jan 07 17:22:59 2013 +0100
6.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java Mon Jan 07 18:27:01 2013 +0100
6.3 @@ -21,4 +21,8 @@
6.4 public static final Object NON_NULL = new Object();
6.5 private StaticUse() {
6.6 }
6.7 +
6.8 + public int instanceMethod() {
6.9 + return 0;
6.10 + }
6.11 }