Minimize reproduction for b/391417819

Bug: b/391417819
Change-Id: I65a9c2427b41f2075305c1383f9dd44c0f580433
diff --git a/src/test/java/com/android/tools/r8/B391417819Repro.java b/src/test/java/com/android/tools/r8/B391417819Repro.java
index a22420d..c7f0522 100644
--- a/src/test/java/com/android/tools/r8/B391417819Repro.java
+++ b/src/test/java/com/android/tools/r8/B391417819Repro.java
@@ -3,9 +3,9 @@
 // BSD-style license that can be found in the LICENSE file.
 package com.android.tools.r8;
 
-import com.android.tools.r8.utils.StringUtils;
-import java.util.BitSet;
-import org.junit.Assert;
+import static com.android.tools.r8.utils.codeinspector.AssertUtils.assertFailsCompilation;
+
+import java.util.Arrays;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -23,66 +23,49 @@
     return getTestParameters().withAllRuntimesAndApiLevels().build();
   }
 
-  private static final String EXPECTED_OUTPUT = StringUtils.lines("Hello, world!");
-
   @Test
   public void testJvm() throws Exception {
     parameters.assumeJvmTestParameters();
     testForJvm(parameters)
         .addInnerClasses(getClass())
         .run(parameters.getRuntime(), TestClass.class)
-        .assertFailureWithErrorThatThrows(ArrayIndexOutOfBoundsException.class);
+        .assertSuccessWithOutputLines("[0, 1]");
   }
 
   @Test
   public void testD8() throws Exception {
     parameters.assumeDexRuntime();
-    testForD8(parameters.getBackend())
-        .addInnerClasses(getClass())
-        .setMinApi(parameters)
-        .run(parameters.getRuntime(), TestClass.class)
-        .assertFailureWithErrorThatThrows(ArrayIndexOutOfBoundsException.class);
+    assertFailsCompilation(
+        () ->
+            testForD8(parameters.getBackend())
+                .addInnerClasses(getClass())
+                .release()
+                .setMinApi(parameters)
+                .run(parameters.getRuntime(), TestClass.class)
+                .assertSuccessWithOutputLines("[0, 1]"));
   }
 
   @Test
   public void testR8() throws Exception {
-    Assert.assertThrows(
-        CompilationFailedException.class,
+    assertFailsCompilation(
         () ->
             testForR8(parameters.getBackend())
                 .addInnerClasses(getClass())
                 .addKeepMainRule(TestClass.class)
                 .setMinApi(parameters)
                 .run(parameters.getRuntime(), TestClass.class)
-                .assertSuccessWithOutput(EXPECTED_OUTPUT));
+                .assertSuccessWithOutputLines("[0, 1]"));
   }
 
   static class TestClass {
 
-    public byte[] toBytes(boolean on) {
-      byte[] bytes = new byte[3];
-      bytes[0] = 1;
-      BitSet bits = new BitSet(8);
-      byte[] byteArray = bits.toByteArray();
-      if (byteArray != null && byteArray.length >= 1) {
-        bytes[1] = bits.toByteArray()[0];
-      }
-      BitSet bitSet = new BitSet(8);
-      // Throws ArrayIndexOutOfBoundsException here, as the returned byte array from
-      // bitSet.toByteArray() has length zero.
-      bytes[2] = bitSet.toByteArray()[0];
-      return bytes;
-    }
-
-    public static void print(byte[] b) {
-      for (int i = 0; i < b.length; i++) {
-        System.out.println(i + ": " + b[i]);
-      }
-    }
-
     public static void main(String[] args) {
-      print(new TestClass().toBytes(System.currentTimeMillis() >= 0));
-      print(new TestClass().toBytes(System.currentTimeMillis() < 0));
+      int[] ints = new int[2];
+      if (System.currentTimeMillis() > 0) {
+        ints[0] = args.length;
+      }
+      ints[1] = 1;
+      System.out.println(Arrays.toString(ints));
     }
   }
 }