diff options
author | 2018-02-27 20:33:09 -0800 | |
---|---|---|
committer | 2018-03-02 00:10:53 +0000 | |
commit | 74fa8882f6de4d2755917554ab368f9859a5f995 (patch) | |
tree | 007df695b3395c18eaa58bb2a002178faa1d82cf /test/044-proxy/src/BasicTest.java | |
parent | 8dcb3527d416fb63f936a8fbeb7b59abfc2ac446 (diff) |
ART: harden test 044
Ensure that spec-required methods are correctly passed to the
invocation handler.
Do not rely on undefined ordering of methods (and unify the
handling).
Bug: 73888836
Bug: 73901493
Test: art/test/testrunner/testrunner.py -b --host -t 044
Change-Id: I0886bd78f7a45588384c745e38b4a12de4b81934
Diffstat (limited to 'test/044-proxy/src/BasicTest.java')
-rw-r--r-- | test/044-proxy/src/BasicTest.java | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/test/044-proxy/src/BasicTest.java b/test/044-proxy/src/BasicTest.java index 7f301f667b..c23576c699 100644 --- a/test/044-proxy/src/BasicTest.java +++ b/test/044-proxy/src/BasicTest.java @@ -22,7 +22,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Arrays; -import java.util.Comparator; /** * Do some basic tests. @@ -54,6 +53,11 @@ public class BasicTest { Trace trace = (Trace) proxy; trace.getTrace(); + // Test the proxy spec: These Object functions are supposed to be given to the handler. + int unusedHashCode = ((Object)trace).hashCode(); + boolean unusedEquals = ((Object)trace).equals(trace); + String unusedString = ((Object)trace).toString(); + try { shapes.upChuck(); System.out.println("Didn't get expected exception"); @@ -73,15 +77,7 @@ public class BasicTest { */ System.out.println(""); Method[] methods = proxy.getClass().getDeclaredMethods(); - Arrays.sort(methods, new Comparator<Method>() { - public int compare(Method o1, Method o2) { - int result = o1.getName().compareTo(o2.getName()); - if (result != 0) { - return result; - } - return o1.getReturnType().getName().compareTo(o2.getReturnType().getName()); - } - }); + Arrays.sort(methods, new MethodComparator()); System.out.println("Proxy interfaces: " + Arrays.deepToString(proxy.getClass().getInterfaces())); System.out.println("Proxy methods: " + @@ -239,6 +235,8 @@ class MyInvocationHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + System.out.println("Invoke " + method); + Object result = null; // Trap Object calls. This is important here to avoid a recursive @@ -286,7 +284,6 @@ class MyInvocationHandler implements InvocationHandler { } } - System.out.println("Invoke " + method); if (args == null || args.length == 0) { System.out.println(" (no args)"); } else { |