Invoking non-static method needs to perform dispatch ReducedStack
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 17 Feb 2014 16:55:44 +0100
branchReducedStack
changeset 14706ab756741111
parent 1469 f57fa856ffc4
child 1471 6655ae68ef9b
Invoking non-static method needs to perform dispatch
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java
rt/emul/mini/src/main/java/java/lang/reflect/Method.java
     1.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Mon Feb 17 15:39:34 2014 +0100
     1.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Mon Feb 17 16:55:44 2014 +0100
     1.3 @@ -250,6 +250,17 @@
     1.4          }
     1.5      }
     1.6      
     1.7 +    @Compare public int callAbst() throws Exception {
     1.8 +        class Impl extends Abst {
     1.9 +            @Override
    1.10 +            public int abst() {
    1.11 +                return 10;
    1.12 +            }
    1.13 +        }
    1.14 +        Abst impl = new Impl();
    1.15 +        return (int) Abst.class.getMethod("abst").invoke(impl);
    1.16 +    }
    1.17 +    
    1.18      @Compare public String componentGetNameForObjectArray() {
    1.19          return (new Object[3]).getClass().getComponentType().getName();
    1.20      }
    1.21 @@ -296,4 +307,7 @@
    1.22          return VMTest.create(ReflectionTest.class);
    1.23      }
    1.24      
    1.25 +    public static abstract class Abst {
    1.26 +        public abstract int abst();
    1.27 +    }
    1.28  }
     2.1 --- a/rt/emul/mini/src/main/java/java/lang/reflect/Method.java	Mon Feb 17 15:39:34 2014 +0100
     2.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Method.java	Mon Feb 17 16:55:44 2014 +0100
     2.3 @@ -528,15 +528,17 @@
     2.4      }
     2.5      
     2.6      @JavaScriptBody(args = { "st", "method", "self", "args" }, body =
     2.7 -          "var p;\n"
     2.8 +          "var p; var cll;\n"
     2.9          + "if (st) {\n"
    2.10 +        + "  cll = self[method._name() + '__' + method._sig()];\n"
    2.11          + "  p = new Array(1);\n"
    2.12          + "  p[0] = self;\n"
    2.13          + "  p = p.concat(args);\n"
    2.14          + "} else {\n"
    2.15          + "  p = args;\n"
    2.16 +        + "  cll = method._data();"
    2.17          + "}\n"
    2.18 -        + "return method._data().apply(self, p);\n"
    2.19 +        + "return cll.apply(self, p);\n"
    2.20      )
    2.21      private static native Object invoke0(boolean isStatic, Method m, Object self, Object[] args);
    2.22