Add OpenJDK 23 GA

* Move Java 22 test module to Java 23
* Keep OpenJDK 22 until bots run tests on OpenJDK 23

Bug: b/383073689
Change-Id: I03d4f9b67afb09bd713d8967cdca3afa87d4e9d0
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
index 1e32ba4..bd2e698 100644
--- a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
+++ b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
@@ -50,12 +50,14 @@
 }
 
 enum class Jdk(val folder : String, val version: Int) {
+  // Only include LTS and latest non-LTS GA.
   JDK_8("jdk8", 8),
-  JDK_9("openjdk-9.0.4", 9),
+  JDK_9("openjdk-9.0.4", 9), // JDK-9 not LTS, but still used.
   JDK_11("jdk-11", 11),
   JDK_17("jdk-17", 17),
   JDK_21("jdk-21", 21),
-  JDK_22("jdk-22", 22);
+  JDK_22("jdk-22", 22),  // TODO(b/383073689) Remove JDK-22 when bots test JDK-23.
+  JDK_23("jdk-23", 23);
 
   fun isJdk8() : Boolean {
     return this == JDK_8
diff --git a/d8_r8/test/build.gradle.kts b/d8_r8/test/build.gradle.kts
index 30933b4..cb73658 100644
--- a/d8_r8/test/build.gradle.kts
+++ b/d8_r8/test/build.gradle.kts
@@ -60,7 +60,7 @@
     dependsOn(gradle.includedBuild("tests_java_11").task(":clean"))
     dependsOn(gradle.includedBuild("tests_java_17").task(":clean"))
     dependsOn(gradle.includedBuild("tests_java_21").task(":clean"))
-    dependsOn(gradle.includedBuild("tests_java_22").task(":clean"))
+    dependsOn(gradle.includedBuild("tests_java_23").task(":clean"))
   }
 
   val packageTests by registering(Jar::class) {
diff --git a/d8_r8/test/settings.gradle.kts b/d8_r8/test/settings.gradle.kts
index 2ff9d56..48b1fb0 100644
--- a/d8_r8/test/settings.gradle.kts
+++ b/d8_r8/test/settings.gradle.kts
@@ -36,4 +36,4 @@
 includeBuild(root.resolve("test_modules").resolve("tests_java_11"))
 includeBuild(root.resolve("test_modules").resolve("tests_java_17"))
 includeBuild(root.resolve("test_modules").resolve("tests_java_21"))
-includeBuild(root.resolve("test_modules").resolve("tests_java_22"))
+includeBuild(root.resolve("test_modules").resolve("tests_java_23"))
diff --git a/d8_r8/test_modules/tests_java_22/build.gradle.kts b/d8_r8/test_modules/tests_java_23/build.gradle.kts
similarity index 85%
rename from d8_r8/test_modules/tests_java_22/build.gradle.kts
rename to d8_r8/test_modules/tests_java_23/build.gradle.kts
index 938e1cb..8a20a32 100644
--- a/d8_r8/test_modules/tests_java_22/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_23/build.gradle.kts
@@ -14,10 +14,10 @@
 
 java {
   sourceSets.test.configure {
-    java.srcDir(root.resolveAll("src", "test", "java22"))
+    java.srcDir(root.resolveAll("src", "test", "java23"))
   }
-  sourceCompatibility = JavaVersion.VERSION_22
-  targetCompatibility = JavaVersion.VERSION_22
+  sourceCompatibility = JavaVersion.VERSION_23
+  targetCompatibility = JavaVersion.VERSION_23
 }
 
 val testbaseJavaCompileTask = projectTask("testbase", "compileJava")
@@ -36,14 +36,14 @@
     dependsOn(gradle.includedBuild("shared").task(":downloadDeps"))
     options.setFork(true)
     options.forkOptions.memoryMaximumSize = "3g"
-    options.forkOptions.executable = getCompilerPath(Jdk.JDK_22)
+    options.forkOptions.executable = getCompilerPath(Jdk.JDK_23)
   }
 
   withType<Test> {
     notCompatibleWithConfigurationCache(
       "Failure storing the configuration cache: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache")
     TestingState.setUpTestingState(this)
-    javaLauncher = getJavaLauncher(Jdk.JDK_22)
+    javaLauncher = getJavaLauncher(Jdk.JDK_23)
     systemProperty("TEST_DATA_LOCATION",
                    layout.buildDirectory.dir("classes/java/test").get().toString())
     systemProperty("TESTBASE_DATA_LOCATION",
diff --git a/d8_r8/test_modules/tests_java_22/settings.gradle.kts b/d8_r8/test_modules/tests_java_23/settings.gradle.kts
similarity index 95%
rename from d8_r8/test_modules/tests_java_22/settings.gradle.kts
rename to d8_r8/test_modules/tests_java_23/settings.gradle.kts
index 057fa4a..523efdb 100644
--- a/d8_r8/test_modules/tests_java_22/settings.gradle.kts
+++ b/d8_r8/test_modules/tests_java_23/settings.gradle.kts
@@ -21,9 +21,9 @@
   }
 }
 
-rootProject.name = "tests_java_22"
+rootProject.name = "tests_java_23"
 val root = rootProject.projectDir.parentFile.parentFile
 
 includeBuild(root.resolve("shared"))
 includeBuild(root.resolve("main"))
-includeBuild(root.resolve("test_modules").resolve("testbase"))
\ No newline at end of file
+includeBuild(root.resolve("test_modules").resolve("testbase"))
diff --git a/scripts/add-openjdk.sh b/scripts/add-openjdk.sh
index 37023ff..b1838fe 100755
--- a/scripts/add-openjdk.sh
+++ b/scripts/add-openjdk.sh
@@ -18,7 +18,7 @@
 
 # Now run script with fingers crossed!
 
-JDK_VERSION="22.0.1"
+JDK_VERSION="23.0.1"
 JDK_VERSION_FULL=${JDK_VERSION}
 # For ea versions the full version name has a postfix.
 # JDK_VERSION_FULL="${JDK_VERSION}-ea+33"
diff --git a/src/test/java22/com/android/tools/r8/java22/Java22ValidationTest.java b/src/test/java23/com/android/tools/r8/java23/Java23ValidationTest.java
similarity index 90%
rename from src/test/java22/com/android/tools/r8/java22/Java22ValidationTest.java
rename to src/test/java23/com/android/tools/r8/java23/Java23ValidationTest.java
index 5343ad9..a06fe15 100644
--- a/src/test/java22/com/android/tools/r8/java22/Java22ValidationTest.java
+++ b/src/test/java23/com/android/tools/r8/java23/Java23ValidationTest.java
@@ -2,7 +2,7 @@
 // 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.java22;
+package com.android.tools.r8.java23;
 
 import static com.android.tools.r8.utils.InternalOptions.ASM_VERSION;
 import static junit.framework.TestCase.assertEquals;
@@ -24,9 +24,9 @@
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassVisitor;
 
-// Test to validate that the tests_java_22 module is built with JDK-22.
+// Test to validate that the tests_java_23 module is built with JDK-23.
 @RunWith(Parameterized.class)
-public class Java22ValidationTest extends TestBase {
+public class Java23ValidationTest extends TestBase {
 
   static final String EXPECTED = StringUtils.lines("Hello, world");
 
@@ -37,7 +37,7 @@
     return getTestParameters().withCfRuntimes().build();
   }
 
-  public Java22ValidationTest(TestParameters parameters) {
+  public Java23ValidationTest(TestParameters parameters) {
     this.parameters = parameters;
   }
 
@@ -78,7 +78,7 @@
   @Test
   public void testTestClassClassFileVersion() throws Exception {
     assertEquals(
-        CfVersion.V22,
+        CfVersion.V23,
         extractClassFileVersion(ToolHelper.getClassFileForTestClass(TestClass.class)));
   }
 
@@ -88,7 +88,7 @@
         .addInnerClasses(getClass())
         .run(parameters.getRuntime(), TestClass.class)
         .applyIf(
-            parameters.getCfRuntime().isOlderThan(CfVm.JDK22),
+            parameters.getCfRuntime().isOlderThan(CfVm.JDK23),
             r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class),
             r -> r.assertSuccessWithOutput(EXPECTED));
   }
diff --git a/src/test/testbase/java/com/android/tools/r8/TestRuntime.java b/src/test/testbase/java/com/android/tools/r8/TestRuntime.java
index 2a7668d..901bfda 100644
--- a/src/test/testbase/java/com/android/tools/r8/TestRuntime.java
+++ b/src/test/testbase/java/com/android/tools/r8/TestRuntime.java
@@ -43,8 +43,11 @@
     JDK17("jdk17", 61),
     JDK18("jdk18", 62),
     JDK20("jdk20", 64),
+    // From JDK-21 only include LTS and latest non-LTS.
     JDK21("jdk21", 65),
-    JDK22("jdk22", 66);
+    // TODO(b/383073689) Remove JDK-22 when bots test JDK-23.
+    JDK22("jdk22", 66),
+    JDK23("jdk23", 67);
 
     /** This should generally be the latest checked in CF runtime we fully support. */
     private static final CfVm DEFAULT = JDK11;
@@ -100,6 +103,7 @@
   private static final Path JDK17_PATH = Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "jdk-17");
   private static final Path JDK21_PATH = Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "jdk-21");
   private static final Path JDK22_PATH = Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "jdk-22");
+  private static final Path JDK23_PATH = Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "jdk-23");
   private static final Map<CfVm, Path> jdkPaths =
       ImmutableMap.of(
           CfVm.JDK8, JDK8_PATH,
@@ -107,7 +111,8 @@
           CfVm.JDK11, JDK11_PATH,
           CfVm.JDK17, JDK17_PATH,
           CfVm.JDK21, JDK21_PATH,
-          CfVm.JDK22, JDK22_PATH);
+          CfVm.JDK22, JDK22_PATH,
+          CfVm.JDK23, JDK23_PATH);
 
   public static CfRuntime getCheckedInJdk(CfVm vm) {
     if (vm == CfVm.JDK8) {
@@ -164,6 +169,10 @@
     return new CfRuntime(CfVm.JDK22, getCheckedInJdkHome(CfVm.JDK22));
   }
 
+  public static CfRuntime getCheckedInJdk23() {
+    return new CfRuntime(CfVm.JDK23, getCheckedInJdkHome(CfVm.JDK23));
+  }
+
   public static List<CfRuntime> getCheckedInCfRuntimes() {
     CfRuntime[] jdks =
         new CfRuntime[] {
@@ -172,7 +181,8 @@
           getCheckedInJdk11(),
           getCheckedInJdk17(),
           getCheckedInJdk21(),
-          getCheckedInJdk22()
+          getCheckedInJdk22(),
+          getCheckedInJdk23()
         };
     Builder<CfRuntime> builder = ImmutableList.builder();
     for (CfRuntime jdk : jdks) {
@@ -236,6 +246,9 @@
     if (version.equals("22") || version.startsWith("22.")) {
       return new CfRuntime(CfVm.JDK22, Paths.get(home));
     }
+    if (version.equals("23") || version.startsWith("23.")) {
+      return new CfRuntime(CfVm.JDK23, Paths.get(home));
+    }
     throw new Unimplemented("No support for JDK version: " + version);
   }
 
diff --git a/third_party/openjdk/jdk-23/linux.tar.gz.sha1 b/third_party/openjdk/jdk-23/linux.tar.gz.sha1
new file mode 100644
index 0000000..d39b694
--- /dev/null
+++ b/third_party/openjdk/jdk-23/linux.tar.gz.sha1
@@ -0,0 +1 @@
+36f1f7c6d924aa7cf1f62aff190db06e08579e9f
\ No newline at end of file
diff --git a/third_party/openjdk/jdk-23/osx.tar.gz.sha1 b/third_party/openjdk/jdk-23/osx.tar.gz.sha1
new file mode 100644
index 0000000..953229a
--- /dev/null
+++ b/third_party/openjdk/jdk-23/osx.tar.gz.sha1
@@ -0,0 +1 @@
+ae286ba92adf86288fb631ee89a97579a0697df0
\ No newline at end of file
diff --git a/third_party/openjdk/jdk-23/windows.tar.gz.sha1 b/third_party/openjdk/jdk-23/windows.tar.gz.sha1
new file mode 100644
index 0000000..8382e1b
--- /dev/null
+++ b/third_party/openjdk/jdk-23/windows.tar.gz.sha1
@@ -0,0 +1 @@
+345fdfbe28933020e55010003bde6c71a1cdf8f1
\ No newline at end of file
diff --git a/tools/jdk.py b/tools/jdk.py
index 3b41c3b..745f1c1 100755
--- a/tools/jdk.py
+++ b/tools/jdk.py
@@ -10,8 +10,9 @@
 
 JDK_DIR = os.path.join(defines.THIRD_PARTY, 'openjdk')
 
+# TODO(b/383073689) Remove JDK-22 when bots test JDK-23.
 ALL_JDKS = ['openjdk-9.0.4', 'jdk-11', 'jdk-15', 'jdk-16', 'jdk-17',
-            'jdk-18', 'jdk-21', 'jdk-22']
+            'jdk-18', 'jdk-21', 'jdk-22', 'jdk-23']
 
 
 def GetJdkHome():
diff --git a/tools/test.py b/tools/test.py
index 26eda1e..3b52a4b 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -45,6 +45,7 @@
 NUMBER_OF_TEST_REPORTS = 5
 REPORTS_PATH = os.path.join(utils.BUILD, 'reports')
 REPORT_INDEX = ['tests', 'test', 'index.html']
+# TODO(b/383073689) Remove JDK-22 when bots test JDK-23.
 VALID_RUNTIMES = [
     'none',
     'jdk8',
@@ -53,6 +54,7 @@
     'jdk17',
     'jdk21',
     'jdk22',
+    'jdk23',
 ] + ['dex-%s' % dexvm for dexvm in ALL_ART_VMS]