Reapply "Move backport test to java 11 package"

This reverts commit 732cc09c16ceb61a0b58a4f19daba7c2d5c1305d.


Reapply "Move Java 10 backport to Java 10 module"

This reverts commit 545813dfcaf71c177ca1ef7fba9172f6c528869f.


Reapply "Move Java9 backport test to java 9 module"

This reverts commit 0ff3415ebe3965d6ced3759dcf263f12fa2d0ec7.

Bug: b/380808556
Change-Id: I628f45b00b691126e25bc679889e88cf4fc22d16
diff --git a/src/test/examplesJava9/backport/ShortBackportJava9Test.java b/src/test/examplesJava9/backport/ShortBackportJava9Test.java
new file mode 100644
index 0000000..43ccb9f
--- /dev/null
+++ b/src/test/examplesJava9/backport/ShortBackportJava9Test.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2019, 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 backport;
+
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestRuntime.CfVm;
+import com.android.tools.r8.desugar.backports.AbstractBackportTest;
+import com.android.tools.r8.utils.AndroidApiLevel;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public final class ShortBackportJava9Test extends AbstractBackportTest {
+  @Parameters(name = "{0}")
+  public static Iterable<?> data() {
+    return getTestParameters()
+        .withCfRuntimesStartingFromIncluding(CfVm.JDK9)
+        .withDexRuntimes()
+        .withAllApiLevelsAlsoForCf()
+        .build();
+  }
+
+  public ShortBackportJava9Test(TestParameters parameters) {
+    super(parameters, Short.class, ShortBackportJava9Main.class);
+
+    // Short.compareUnsigned added in API 31.
+    registerTarget(AndroidApiLevel.S, 16);
+  }
+
+  public static class ShortBackportJava9Main {
+    private static final byte MIN_UNSIGNED_VALUE = (short) 0;
+    private static final byte MAX_UNSIGNED_VALUE = (short) -1;
+
+    public static void main(String[] args) {
+      testCompareUnsigned();
+    }
+
+    private static void testCompareUnsigned() {
+      assertTrue(Short.compareUnsigned(MIN_UNSIGNED_VALUE, MIN_UNSIGNED_VALUE) == 0);
+      assertTrue(Short.compareUnsigned(MIN_UNSIGNED_VALUE, Short.MAX_VALUE) < 0);
+      assertTrue(Short.compareUnsigned(MIN_UNSIGNED_VALUE, Short.MIN_VALUE) < 0);
+      assertTrue(Short.compareUnsigned(MIN_UNSIGNED_VALUE, MAX_UNSIGNED_VALUE) < 0);
+
+      assertTrue(Short.compareUnsigned(Short.MAX_VALUE, MIN_UNSIGNED_VALUE) > 0);
+      assertTrue(Short.compareUnsigned(Short.MAX_VALUE, Short.MAX_VALUE) == 0);
+      assertTrue(Short.compareUnsigned(Short.MAX_VALUE, Short.MIN_VALUE) < 0);
+      assertTrue(Short.compareUnsigned(Short.MAX_VALUE, MAX_UNSIGNED_VALUE) < 0);
+
+      assertTrue(Short.compareUnsigned(Short.MIN_VALUE, MIN_UNSIGNED_VALUE) > 0);
+      assertTrue(Short.compareUnsigned(Short.MIN_VALUE, Short.MAX_VALUE) > 0);
+      assertTrue(Short.compareUnsigned(Short.MIN_VALUE, Short.MIN_VALUE) == 0);
+      assertTrue(Short.compareUnsigned(Short.MIN_VALUE, MAX_UNSIGNED_VALUE) < 0);
+
+      assertTrue(Short.compareUnsigned(MAX_UNSIGNED_VALUE, MIN_UNSIGNED_VALUE) > 0);
+      assertTrue(Short.compareUnsigned(MAX_UNSIGNED_VALUE, Short.MAX_VALUE) > 0);
+      assertTrue(Short.compareUnsigned(MAX_UNSIGNED_VALUE, Short.MIN_VALUE) > 0);
+      assertTrue(Short.compareUnsigned(MAX_UNSIGNED_VALUE, MAX_UNSIGNED_VALUE) == 0);
+    }
+
+    private static void assertTrue(boolean value) {
+      if (!value) {
+        throw new AssertionError("Expected <true> but was <false>");
+      }
+    }
+  }
+}