Add reproduction of issue 344363462

Bug: b/344363462
Change-Id: Id77b00026ce0136156ba26cefa3de2ecb5374689
diff --git a/src/test/java/com/android/tools/r8/B344363462Test.java b/src/test/java/com/android/tools/r8/B344363462Test.java
new file mode 100644
index 0000000..bba41ed
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/B344363462Test.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2024, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8;
+
+import com.android.tools.r8.utils.StringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class B344363462Test extends TestBase {
+
+  @Parameter() public TestParameters parameters;
+
+  @Parameters(name = "{0}")
+  public static TestParametersCollection data() {
+    return getTestParameters().withAllRuntimesAndApiLevels().build();
+  }
+
+  private static final String EXPECTED_OUTPUT = StringUtils.lines("-225");
+  private static final String UNEXPECTED_OUTPUT = StringUtils.lines("0");
+
+  @Test
+  public void testD8() throws Exception {
+    parameters.assumeDexRuntime();
+    testForD8(parameters.getBackend())
+        .addInnerClasses(getClass())
+        .setMinApi(parameters)
+        .run(parameters.getRuntime(), TestClass.class)
+        .assertSuccessWithOutput(EXPECTED_OUTPUT);
+  }
+
+  @Test
+  public void testD8Release() throws Exception {
+    parameters.assumeDexRuntime();
+    testForD8(parameters.getBackend())
+        .addInnerClasses(getClass())
+        .setMinApi(parameters)
+        .release()
+        .run(parameters.getRuntime(), TestClass.class)
+        .assertSuccessWithOutput(UNEXPECTED_OUTPUT);
+  }
+
+  @Test
+  public void testR8() throws Exception {
+    testForR8(parameters.getBackend())
+        .addInnerClasses(getClass())
+        .addKeepMainRule(TestClass.class)
+        .setMinApi(parameters)
+        .run(parameters.getRuntime(), TestClass.class)
+        .assertSuccessWithOutput(UNEXPECTED_OUTPUT);
+  }
+
+  static class TestClass {
+
+    int iFld1;
+
+    void t() {
+      int i5 = 61127, i7 = 42011;
+      long[] lArr = new long[10];
+      try {
+        iFld1 -= 225L;
+        lArr[i5] = i7;
+        iFld1 = i7;
+      } catch (ArrayIndexOutOfBoundsException err) {
+      }
+      System.out.println(iFld1);
+    }
+
+    public static void main(String[] strArr) {
+      TestClass test = new TestClass();
+      test.t();
+    }
+  }
+}