1.1 --- a/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Sun Apr 07 11:38:56 2013 +0200
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Sun Apr 07 15:24:45 2013 +0200
1.3 @@ -501,8 +501,8 @@
1.4 throws IllegalAccessException, IllegalArgumentException,
1.5 InvocationTargetException
1.6 {
1.7 - final boolean isStatic = (getModifiers() & Modifier.STATIC) == 0;
1.8 - if (isStatic && obj == null) {
1.9 + final boolean nonStatic = (getModifiers() & Modifier.STATIC) == 0;
1.10 + if (nonStatic && obj == null) {
1.11 throw new NullPointerException();
1.12 }
1.13 Class[] types = getParameterTypes();
1.14 @@ -517,7 +517,7 @@
1.15 }
1.16 }
1.17 }
1.18 - Object res = invoke0(isStatic, this, obj, args);
1.19 + Object res = invokeTry(nonStatic, this, obj, args);
1.20 if (getReturnType().isPrimitive()) {
1.21 res = fromPrimitive(getReturnType(), res);
1.22 }
1.23 @@ -536,6 +536,15 @@
1.24 + "return method._data().apply(self, p);\n"
1.25 )
1.26 private static native Object invoke0(boolean isStatic, Method m, Object self, Object[] args);
1.27 +
1.28 + private static Object invokeTry(boolean isStatic, Method m, Object self, Object[] args)
1.29 + throws InvocationTargetException {
1.30 + try {
1.31 + return invoke0(isStatic, m, self, args);
1.32 + } catch (Throwable ex) {
1.33 + throw new InvocationTargetException(ex, ex.getMessage());
1.34 + }
1.35 + }
1.36
1.37 static Object fromPrimitive(Class<?> type, Object o) {
1.38 if (type == Integer.TYPE) {
2.1 --- a/rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java Sun Apr 07 11:38:56 2013 +0200
2.2 +++ b/rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java Sun Apr 07 15:24:45 2013 +0200
2.3 @@ -250,6 +250,9 @@
2.4 res = found.invoke(c.newInstance());
2.5 }
2.6 } catch (Throwable ex) {
2.7 + if (ex instanceof InvocationTargetException) {
2.8 + ex = ((InvocationTargetException)ex).getTargetException();
2.9 + }
2.10 res = ex.getClass().getName() + ":" + ex.getMessage();
2.11 }
2.12 } else {
3.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java Sun Apr 07 11:38:56 2013 +0200
3.2 +++ b/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java Sun Apr 07 15:24:45 2013 +0200
3.3 @@ -104,6 +104,11 @@
3.4 return "should not happen";
3.5 }
3.6
3.7 + @Compare public String methodThatThrowsException() throws Exception {
3.8 + StaticUse.class.getMethod("instanceMethod").invoke(new StaticUse());
3.9 + return "should not happen";
3.10 + }
3.11 +
3.12 @Compare public Object voidReturnType() throws Exception {
3.13 return StaticUse.class.getMethod("instanceMethod").getReturnType();
3.14 }
4.1 --- a/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java Sun Apr 07 11:38:56 2013 +0200
4.2 +++ b/rt/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/StaticUse.java Sun Apr 07 15:24:45 2013 +0200
4.3 @@ -30,6 +30,7 @@
4.4 }
4.5
4.6 public void instanceMethod() {
4.7 + throw new IllegalStateException();
4.8 }
4.9
4.10 public static int plus(int a, int b) {