Update test of invalid MethodParameters attribute from desugaring

* Don't use JDK8 on Windows
* Test on JVM as well

Bug: 189743726
Change-Id: I926a89511513be3075e2784f5ef0b4375112f8f6
diff --git a/src/test/java/com/android/tools/r8/TestRuntime.java b/src/test/java/com/android/tools/r8/TestRuntime.java
index 5aef2ad..8b99ca8 100644
--- a/src/test/java/com/android/tools/r8/TestRuntime.java
+++ b/src/test/java/com/android/tools/r8/TestRuntime.java
@@ -12,10 +12,12 @@
 import com.android.tools.r8.utils.ListUtils;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.ImmutableMap;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 // Base class for the runtime structure in the test parameters.
@@ -69,6 +71,19 @@
       Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "openjdk-9.0.4");
   private static final Path JDK11_PATH = Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "jdk-11");
   private static final Path JDK15_PATH = Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "jdk-15");
+  private static final Map<CfVm, Path> jdkPaths =
+      ImmutableMap.of(
+          CfVm.JDK8, JDK8_PATH,
+          CfVm.JDK9, JDK9_PATH,
+          CfVm.JDK11, JDK11_PATH,
+          CfVm.JDK15, JDK15_PATH);
+
+  public static CfRuntime getCheckedInJdk(CfVm vm) {
+    if (vm == CfVm.JDK8) {
+      return getCheckedInJdk8();
+    }
+    return new CfRuntime(vm, getCheckedInJdkHome(vm));
+  }
 
   public static CfRuntime getCheckedInJdk8() {
     Path home;
@@ -83,7 +98,9 @@
     return new CfRuntime(CfVm.JDK8, home);
   }
 
-  private static Path getCheckedInJdkHome(Path path, CfVm vm) {
+  private static Path getCheckedInJdkHome(CfVm vm) {
+    Path path = jdkPaths.get(vm);
+    assert path != null : "No JDK path defined for " + vm;
     if (ToolHelper.isLinux()) {
       return path.resolve("linux");
     } else if (ToolHelper.isMac()) {
@@ -97,16 +114,16 @@
   }
 
   public static CfRuntime getCheckedInJdk9() {
-    return new CfRuntime(CfVm.JDK9, getCheckedInJdkHome(JDK9_PATH, CfVm.JDK9));
+    return new CfRuntime(CfVm.JDK9, getCheckedInJdkHome(CfVm.JDK9));
   }
 
   public static CfRuntime getCheckedInJdk11() {
-    return new CfRuntime(CfVm.JDK11, getCheckedInJdkHome(JDK11_PATH, CfVm.JDK11));
+    return new CfRuntime(CfVm.JDK11, getCheckedInJdkHome(CfVm.JDK11));
   }
 
   // TODO(b/169692487): Add this to 'getCheckedInCfRuntimes' when we start having support for JDK15.
   public static CfRuntime getCheckedInJdk15() {
-    return new CfRuntime(CfVm.JDK15, getCheckedInJdkHome(JDK15_PATH, CfVm.JDK15));
+    return new CfRuntime(CfVm.JDK15, getCheckedInJdkHome(CfVm.JDK15));
   }
 
   public static List<CfRuntime> getCheckedInCfRuntimes() {
diff --git a/src/test/java/com/android/tools/r8/desugaring/interfacemethods/MethodParametersTest.java b/src/test/java/com/android/tools/r8/desugaring/interfacemethods/MethodParametersTest.java
index 02ddfbc..7d70d21 100644
--- a/src/test/java/com/android/tools/r8/desugaring/interfacemethods/MethodParametersTest.java
+++ b/src/test/java/com/android/tools/r8/desugaring/interfacemethods/MethodParametersTest.java
@@ -3,9 +3,11 @@
 // BSD-style license that can be found in the LICENSE file.
 package com.android.tools.r8.desugaring.interfacemethods;
 
-import static com.android.tools.r8.TestRuntime.getCheckedInJdk8;
+import static com.android.tools.r8.TestRuntime.getCheckedInJdk;
+import static com.android.tools.r8.TestRuntime.getCheckedInJdk11;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assume.assumeTrue;
 
 import com.android.tools.r8.TestBase;
 import com.android.tools.r8.TestCompileResult;
@@ -39,9 +41,26 @@
   }
 
   @Test
-  public void test() throws Exception {
+  public void testJvm() throws Exception {
+    assumeTrue(parameters.isCfRuntime());
+    testForJvm()
+        .addProgramClassesAndInnerClasses(I.class)
+        .addInnerClasses(getClass())
+        .run(parameters.getRuntime(), TestRunner.class)
+        .assertSuccessWithOutputLines("0", "1", "2", "0", "1", "2");
+  }
+
+  @Test
+  public void testDesugar() throws Exception {
+    // JDK8 is not present on Windows.
+    assumeTrue(
+        parameters.isDexRuntime()
+            || getCheckedInJdk(parameters.getRuntime().asCf().getVm()) != null);
     Path compiledWithParameters =
-        javac(getCheckedInJdk8())
+        javac(
+                parameters.isCfRuntime()
+                    ? getCheckedInJdk(parameters.getRuntime().asCf().getVm())
+                    : getCheckedInJdk11())
             .addSourceFiles(ToolHelper.getSourceFileForTestClass(I.class))
             .addOptions("-parameters")
             .compile();