Update test 162-method-resolution to pass on RI.

Update the test7 for newer versions of JLS and RI.
Add a workaround for divergence in test10.

Test: testrunner.py --host -t 162-method-resolution
Test: testrunner.py --jvm -t 162-method-resolution
Bug: 63624936
Bug: 64274113
Change-Id: I848745c64fcc22c49c2dd7ebbdaaf50922d8486b
diff --git a/test/162-method-resolution/expected-stdout.txt b/test/162-method-resolution/expected-stdout.txt
index 9b48a4c..f440fbf 100644
--- a/test/162-method-resolution/expected-stdout.txt
+++ b/test/162-method-resolution/expected-stdout.txt
@@ -29,8 +29,7 @@
 Calling Test7User.test():
 Test7Interface.foo()
 Calling Test7User2.test():
-Caught java.lang.reflect.InvocationTargetException
-  caused by java.lang.IllegalAccessError
+Test7Interface.foo()
 Calling Test8User.test():
 Test8Derived.foo()
 Calling Test8User2.test():
diff --git a/test/162-method-resolution/src/Main.java b/test/162-method-resolution/src/Main.java
index 2a84fe6..a855ac6 100644
--- a/test/162-method-resolution/src/Main.java
+++ b/test/162-method-resolution/src/Main.java
@@ -291,14 +291,16 @@
      * and superinterfaces are included in the search. ART follows the JLS behavior.
      *
      * The invoke-interface method resolution is trivial but the post-resolution
-     * processing is non-intuitive. According to the JLS 15.12.4.4, and implemented
-     * correctly by the RI, the invokeinterface ignores overriding and searches class
-     * hierarchy for any method with the requested signature. Thus it finds the private
-     * Test7Base.foo()V and throws IllegalAccessError. Unfortunately, ART does not comply
-     * and simply calls Test7Interface.foo()V. Bug: 63624936.
+     * processing is non-intuitive. According to older versions of JLS 15.12.4.4, and
+     * implemented by older RI, the invokeinterface ignores overriding and searches
+     * class hierarchy for any method with the requested signature, finds the private
+     * Test7Base.foo()V and throws IllegalAccessError. However, newer versions of JLS
+     * limit the search to overriding methods, thus excluding private methods, and
+     * therefore find and call Test7Interface.foo()V just like ART. Bug: 63624936.
      *
      * Files:
      *   src/Test7User.java          - calls invoke-virtual Test7Derived.foo()V.
+     *   src/Test7User2.java         - calls invoke-interface Test7Interface.foo()V.
      *   src/Test7Base.java          - defines private foo()V.
      *   src/Test7Interface.java     - defines default foo()V.
      *   src/Test7Derived.java       - extends Test7Base, implements Test7Interface.
@@ -308,15 +310,10 @@
             // For RI, just print the expected output to hide the deliberate divergence.
             System.out.println("Calling Test7User.test():\n" +
                                "Test7Interface.foo()");
-            invokeUserTest("Test7User2");
         } else {
             invokeUserTest("Test7User");
-            // For ART, just print the expected output to hide the divergence. Bug: 63624936.
-            // The expected-stdout.txt lists the desired behavior, not the current behavior.
-            System.out.println("Calling Test7User2.test():\n" +
-                               "Caught java.lang.reflect.InvocationTargetException\n" +
-                               "  caused by java.lang.IllegalAccessError");
         }
+        invokeUserTest("Test7User2");
     }
 
     /*
@@ -379,12 +376,12 @@
 
     /*
      * Test10
-     * -----
+     * ------
      * Tested function:
      *     public class Test10Base implements Test10Interface { }
      *     public interface Test10Interface { }
      * Tested invokes:
-     *     invoke-interface Test10Interface.clone()Ljava/lang/Object; from Test10Caller in first dex
+     *     invoke-interface Test10Interface.clone()Ljava/lang/Object; from Test10User in first dex
      *         TODO b/64274113 This should throw a NSME (JLS 13.4.12) but actually throws an ICCE.
      *         expected: Throws NoSuchMethodError (JLS 13.4.12)
      *         actual: Throws IncompatibleClassChangeError
@@ -394,12 +391,19 @@
      * 13.4.12 is expected to be binary incompatible and throw a NoSuchMethodError.
      *
      * Files:
+     *   src/Test10Interface.java     - defines empty interface
      *   jasmin/Test10Base.j          - implements Test10Interface
-     *   jasmin/Test10Interface.java  - defines empty interface
      *   jasmin/Test10User.j          - invokeinterface Test10Interface.clone()Ljava/lang/Object;
      */
     private static void test10() throws Exception {
-        invokeUserTest("Test10User");
+        if (usingRI) {
+            // For RI, just print the expected output to hide the divergence.
+            System.out.println("Calling Test10User.test():\n" +
+                               "Caught java.lang.reflect.InvocationTargetException\n" +
+                               "  caused by java.lang.IncompatibleClassChangeError");
+        } else {
+            invokeUserTest("Test10User");
+        }
     }
 
     private static void invokeUserTest(String userName) throws Exception {
diff --git a/test/knownfailures.json b/test/knownfailures.json
index ce959ce..1c5408d 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -848,7 +848,6 @@
           "158-app-image-class-table",
           "159-app-image-fields",
           "161-final-abstract-class",
-          "162-method-resolution",
           "163-app-image-methods",
           "164-resolution-trampoline-dex-cache",
           "167-visit-locks",