From ac1a9ec36b21f548efa4ee50afd22f5723024572 Mon Sep 17 00:00:00 2001 From: ol-automation_ww Date: Wed, 15 Oct 2025 14:46:20 +0000 Subject: [PATCH 1/3] update JVMCI to 25+37-jvmci-25.1-b07 --- common.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common.json b/common.json index ce93489247e8..058f6e8bd2a4 100644 --- a/common.json +++ b/common.json @@ -49,12 +49,12 @@ "graalvm-ee-25-ea": {"name": "graalvm-jdk", "version": "25.0.0", "ea": "36", "platformspecific": true }, "oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+37", "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+37-jvmci-b06", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+37-jvmci-b06-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+37-jvmci-b06-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+37-jvmci-b06", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+37-jvmci-b06-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+37-jvmci-b06-sulong", "platformspecific": true } + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+37-jvmci-25.1-b07", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+37-jvmci-25.1-b07-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+37-jvmci-25.1-b07-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+37-jvmci-25.1-b07", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+37-jvmci-25.1-b07-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+37-jvmci-25.1-b07-sulong", "platformspecific": true } }, "eclipse": { From 52b4a476cf6c54b324d1f4f7c86a2d92d602527e Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Fri, 17 Oct 2025 15:08:41 +0200 Subject: [PATCH 2/3] compiler: adopt new labsjdk version scheme in JVMCIVersionCheck [GR-70870] --- compiler/mx.compiler/mx_compiler.py | 51 ++--- .../test/JVMCIVersionCheckLTSTest.java | 15 +- .../hotspot/test/JVMCIVersionCheckMain.java | 90 +++++++++ .../test/JVMCIVersionCheckMaxValueTest.java | 19 +- .../test/JVMCIVersionCheckMiscTest.java | 155 +++++++++++++++ .../test/JVMCIVersionCheckOpenJDKTest.java | 20 +- .../hotspot/test/JVMCIVersionCheckTest.java | 95 +++++---- .../test/JVMCIVersionCheckVendorTest.java | 10 +- .../compiler/hotspot/JVMCIVersionCheck.java | 183 +++++++++++------- 9 files changed, 475 insertions(+), 163 deletions(-) create mode 100644 compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMain.java create mode 100644 compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMiscTest.java diff --git a/compiler/mx.compiler/mx_compiler.py b/compiler/mx.compiler/mx_compiler.py index 17d070504c03..cfa70f93ba5a 100644 --- a/compiler/mx.compiler/mx_compiler.py +++ b/compiler/mx.compiler/mx_compiler.py @@ -125,7 +125,7 @@ def feature(self): @total_ordering class JVMCIVersionCheckVersion(object): - def __init__(self, jdk_version, jvmci_major, jvmci_minor, jvmci_build): + def __init__(self, jdk_version, release_name, jvmci_build): """ Python version of jdk.graal.compiler.hotspot.JVMCIVersionCheck.Version @@ -133,36 +133,33 @@ def __init__(self, jdk_version, jvmci_major, jvmci_minor, jvmci_build): jvmci_major and jvmci_minor might be 0 if not needed (JDK 22+) """ assert isinstance(jdk_version, JavaLangRuntimeVersion) - assert isinstance(jvmci_major, int) - assert isinstance(jvmci_minor, int) assert isinstance(jvmci_build, int) self.jdk_version = jdk_version - self.jvmci_major = jvmci_major - self.jvmci_minor = jvmci_minor + self.release_name = release_name self.jvmci_build = jvmci_build - def _as_tuple(self): - return (self.jdk_version, self.jvmci_major, self.jvmci_minor, self.jvmci_build) - def __eq__(self, other): if not isinstance(other, JVMCIVersionCheckVersion): return False - return self._as_tuple() == other._as_tuple() + return (self.jdk_version, self.release_name, self.jvmci_build) == (other.jdk_version, other.release_name, other.jvmci_build) def __lt__(self, other): if not isinstance(other, JVMCIVersionCheckVersion): return NotImplemented - return self._as_tuple() < other._as_tuple() + if self.release_name != other.release_name: + # cannot compare versions with different release_names + return NotImplemented + return (self.jdk_version, self.jvmci_build) < (other.jdk_version, other.jvmci_build) def __str__(self): - jdk_version, jvmci_major, jvmci_minor, jvmci_build = self._as_tuple() - if jvmci_major == 0: + jdk_version, release_name, jvmci_build = (self.jdk_version, self.release_name, self.jvmci_build) + if not release_name: if jvmci_build == 0: return f'(openjdk|oraclejdk)-{jdk_version}' else: return f'labsjdk-(ce|ee)-{jdk_version}-jvmci-b{jvmci_build:02d}' else: - return f'labsjdk-(ce|ee)-{jdk_version}-jvmci-{jvmci_major}.{jvmci_minor}-b{jvmci_build:02d}' + return f'labsjdk-(ce|ee)-{jdk_version}-jvmci-{release_name}-b{jvmci_build:02d}' _jdk_jvmci_version = None @@ -181,8 +178,8 @@ def _capture_jvmci_version(args=None): _run_jvmci_version_check(args, jdk=jdk, out=out) if out.data: try: - (jdk_version, jvmci_major, jvmci_minor, jvmci_build) = out.data.split(',') - return JVMCIVersionCheckVersion(JavaLangRuntimeVersion(jdk_version), int(jvmci_major), int(jvmci_minor), int(jvmci_build)) + (jdk_version, release_name, jvmci_build) = out.data.split(',') + return JVMCIVersionCheckVersion(JavaLangRuntimeVersion(jdk_version), None if release_name == "null" else release_name, int(jvmci_build)) except ValueError: mx.warn(f'Could not parse jvmci version from JVMCIVersionCheck output:\n{out.data}') return None @@ -1224,7 +1221,7 @@ def _check_latest_jvmci_version(): the JVMCI version of the JVMCI JDKs in the "jdks" section of the ``common.json`` file and issues a warning if not. """ - jvmci_re = re.compile(r'(?:ce|ee)-(?P.+)-jvmci(?:-(?P\d+)\.(?P\d+))?-b(?P\d+)') + jvmci_re = re.compile(r'(?:ce|ee)-(?P.+)-jvmci(?:-(?P.+))?-b(?P\d+)') common_path = os.path.normpath(join(_suite.dir, '..', 'common.json')) if _jdk_jvmci_version is None: @@ -1242,13 +1239,13 @@ def get_latest_jvmci_version(): match = jvmci_re.match(version) if not match: mx.abort(f'Cannot parse version {version}') - (jdk_version, jvmci_major, jvmci_minor, jvmci_build) = match.groups(default=0) + (jdk_version, release_name, jvmci_build) = match.groups(default=None) if _jdk_jvmci_version.jvmci_build == 0: # jvmci_build == 0 indicates an OpenJDK version has been specified in JVMCIVersionCheck.java. # The JDK does not know the jvmci_build number that might have been specified in common.json, # as it is only a repackaged JDK. Thus, we reset the jvmci_build because we cannot validate it. jvmci_build = 0 - current = JVMCIVersionCheckVersion(JavaLangRuntimeVersion(jdk_version), int(jvmci_major), int(jvmci_minor), int(jvmci_build)) + current = JVMCIVersionCheckVersion(JavaLangRuntimeVersion(jdk_version), release_name, int(jvmci_build)) if current.jdk_version.feature() == _jdk_jvmci_version.jdk_version.feature(): # only compare the same major versions if latest == 'not found': @@ -1284,12 +1281,18 @@ def get_latest_jvmci_version(): msg += ' suppress this error.' mx.abort(msg) - if success and _jdk_jvmci_version < latest: - msg = f'JVMCI version of JAVA_HOME is older than in {common_path}: {_jdk_jvmci_version} < {latest} ' - msg += os.linesep + 'This poses the risk of hitting JVMCI bugs that have already been fixed.' - msg += os.linesep + f'Consider using {latest}, which you can get via:' - msg += os.linesep + f'mx fetch-jdk --configuration {common_path}' - mx.abort_or_warn(msg, version_check_setting == 'strict') + if success: + msg_suffix = os.linesep + 'This poses the risk of hitting JVMCI bugs that have already been fixed.' + msg_suffix += os.linesep + f'Consider using {latest}, which you can get via:' + msg_suffix += os.linesep + f'mx fetch-jdk --configuration {common_path}' + try: + if _jdk_jvmci_version < latest: + msg = f'JVMCI version of JAVA_HOME is older than in {common_path}: {_jdk_jvmci_version} < {latest}' + msg_suffix + mx.abort_or_warn(msg, version_check_setting == 'strict') + except TypeError: + msg = f'JVMCI version of JAVA_HOME incompatible with the version specified in {common_path}: {_jdk_jvmci_version} vs. {latest}' + msg_suffix + mx.abort_or_warn(msg, version_check_setting == 'strict') + class GraalArchiveParticipant: providersRE = re.compile(r'(?:META-INF/versions/([1-9][0-9]*)/)?META-INF/providers/(.+)') diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckLTSTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckLTSTest.java index 635c7656ddf8..4f5dce821cdd 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckLTSTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckLTSTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,25 +24,26 @@ */ package jdk.graal.compiler.hotspot.test; -import jdk.graal.compiler.core.test.GraalCompilerTest; -import jdk.graal.compiler.hotspot.JVMCIVersionCheck; import org.junit.Assert; import org.junit.Test; +import jdk.graal.compiler.core.test.GraalCompilerTest; +import jdk.graal.compiler.hotspot.JVMCIVersionCheck; + /** * Tests that {@link JVMCIVersionCheck} can strip the -LTS suffix. */ public class JVMCIVersionCheckLTSTest extends GraalCompilerTest { private static void expect(String jdkVersionString, String expected) { - JVMCIVersionCheck.Version version = JVMCIVersionCheck.createLabsJDKVersion(jdkVersionString, 1); + JVMCIVersionCheck.Version version = JVMCIVersionCheck.createLabsJDKVersion(jdkVersionString, "myrelease", 1); Assert.assertEquals(expected, version.stripLTS().toString()); } @Test public void test() { - expect("24+17", "24+17-jvmci-b01"); - expect("25+1", "25+1-jvmci-b01"); - expect("25+1-LTS", "25+1-jvmci-b01"); + expect("24+17", "24+17-jvmci-myrelease-b01"); + expect("25+1", "25+1-jvmci-myrelease-b01"); + expect("25+1-LTS", "25+1-jvmci-myrelease-b01"); } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMain.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMain.java new file mode 100644 index 000000000000..042fd53341cb --- /dev/null +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMain.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.graal.compiler.hotspot.test; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Arrays; + +import org.junit.Assert; +import org.junit.Test; + +import jdk.graal.compiler.core.test.GraalCompilerTest; +import jdk.graal.compiler.hotspot.JVMCIVersionCheck; + +/** + * Tests {@link JVMCIVersionCheck#main(String[])} argument handling. This focuses on covering all + * accepted flags and the unknown-argument path while avoiding the default path that may call + * System.exit on version check failure. + */ +public class JVMCIVersionCheckMain extends GraalCompilerTest { + + private static String runMainCaptureOut(String... args) { + PrintStream originalOut = System.out; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream capture = new PrintStream(baos); + try { + System.setOut(capture); + JVMCIVersionCheck.main(args); + } finally { + System.setOut(originalOut); + } + return baos.toString(); + } + + @Test + public void testNoArgument() { + String out = runMainCaptureOut(); + Assert.assertNotNull(out); + Assert.assertFalse("no output produced", out.isEmpty()); + String[] split = out.strip().split(","); + Assert.assertEquals("unexpected length of result: " + Arrays.toString(split), 3, split.length); + JVMCIVersionCheck.createLabsJDKVersion(split[0], split[1], Integer.parseInt(split[2])); + } + + @Test + public void testMinVersionTuple() { + String out = runMainCaptureOut("--min-version"); + Assert.assertNotNull(out); + Assert.assertFalse("no output produced", out.isEmpty()); + String[] split = out.strip().split(","); + Assert.assertEquals("unexpected length of result: " + Arrays.toString(split), 3, split.length); + JVMCIVersionCheck.createLabsJDKVersion(split[0], split[1], Integer.parseInt(split[2])); + } + + @Test + public void testMinVersionAsTag() { + String out = runMainCaptureOut("--min-version", "--as-tag"); + Assert.assertNotNull(out); + Assert.assertFalse(out.contains("No minimum JVMCI version specified for JDK version")); + // check that the output is a valid version + Runtime.Version.parse(out.strip()); + } + + @Test(expected = IllegalArgumentException.class) + public void testUnknownArgument() { + JVMCIVersionCheck.main(new String[]{"--unknown-flag"}); + } +} diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMaxValueTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMaxValueTest.java index 40f760820778..e351c772d06e 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMaxValueTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMaxValueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,24 +36,25 @@ */ public class JVMCIVersionCheckMaxValueTest extends GraalCompilerTest { - public static final String EXPECTED_MSG = "Cannot read JVMCI version from java.vm.version property"; + public static final String EXPECTED_MSG_CANNOT_READ = "Cannot read JVMCI version from java.vm.version property"; + public static final String EXPECTED_MSG_INCOMPARABLE = "Graal expected a JVMCI release version"; @Test - public void testLegacyVersion() { - for (String version : new String[]{"20.0-b" + Long.MAX_VALUE, "20." + Long.MAX_VALUE + "-b1", Long.MAX_VALUE + ".0-b1"}) { - testVersion(String.format("prefix-jvmci-%s-suffix", version)); + public void testCurrentVersion() { + for (String version : new String[]{"20.0-b" + Long.MAX_VALUE, "20." + Long.MAX_VALUE + "-b1", Long.MAX_VALUE + ".0-b1", "myrelease"}) { + testVersion(String.format("99.0.1-jvmci-%s-suffix", version)); } } @Test - public void testNewVersion() { + public void testVersionUntilGraalVmForJDK25() { // We only want to test jvmciBuild, not Runtime.Version, so we use a fixed jdkVersion string testVersion(String.format("99.0.1-jvmci-b%s-suffix", Long.MAX_VALUE)); } private static void testVersion(String javaVmVersion) { try { - JVMCIVersionCheck.Version minVersion = JVMCIVersionCheck.createLegacyVersion(20, 0, 1); + JVMCIVersionCheck.Version minVersion = JVMCIVersionCheck.createLabsJDKVersion("99.0.1", "20.0", 1); // Use a javaSpecVersion that will likely not fail in the near future String javaSpecVersion = "99"; var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, javaVmVersion, null); @@ -65,8 +66,8 @@ private static void testVersion(String javaVmVersion) { Assert.fail("expected to fail checking " + javaVmVersion + " against " + minVersion); } } catch (InternalError e) { - if (!e.getMessage().contains(EXPECTED_MSG)) { - throw new AssertionError("Unexpected exception message. Expected: " + EXPECTED_MSG, e); + if (!e.getMessage().contains(EXPECTED_MSG_INCOMPARABLE) && !e.getMessage().contains(EXPECTED_MSG_CANNOT_READ)) { + throw new AssertionError("Unexpected exception message. Expected: " + EXPECTED_MSG_INCOMPARABLE + " or " + EXPECTED_MSG_CANNOT_READ, e); } } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMiscTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMiscTest.java new file mode 100644 index 000000000000..bdc803d15526 --- /dev/null +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckMiscTest.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.graal.compiler.hotspot.test; + +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + +import jdk.graal.compiler.core.test.GraalCompilerTest; +import jdk.graal.compiler.hotspot.JVMCIVersionCheck; +import jdk.graal.compiler.util.CollectionsUtil; + +/** + * Tests code branches not covered by other {@link JVMCIVersionCheck} tests. + */ +public class JVMCIVersionCheckMiscTest extends GraalCompilerTest { + + public static final String EXPECTED_RELEASE = "Graal expected a JVMCI release version"; + public static final String EXPECTED_MINIMUM_JDK = "Graal requires JDK"; + public static final String EXPECTED_VM_JDK = "The VM does not support JDK"; + public static final String EXPECTED_NO_JVMCI = "Cannot compare JVMCI version"; + + /** + * Gets the base JDK version without the optional "-jvmci-" part. + */ + private static String getJDKVersion() { + String versionString = Runtime.version().toString(); + var idx = versionString.indexOf("-jvmci-"); + if (idx >= 0) { + return versionString.substring(0, idx); + } + return versionString; + } + + @Test + public void testMinRelease() { + var props = JVMCIVersionCheckTest.createTestProperties("1", null, null); + var message = JVMCIVersionCheck.check(props); + Assert.assertNotNull("unexpectedly passed", message); + Assert.assertTrue("expected error %s, got %s".formatted(EXPECTED_MINIMUM_JDK, message), message.startsWith(EXPECTED_MINIMUM_JDK)); + } + + @Test + public void testSnapshot() { + // Use javaSpecVersion and jdkVersion from the runtime + String javaSpecVersion = Integer.toString(Runtime.version().feature()); + String jdkVersion = getJDKVersion(); + // expected to pass, because it is a snapshot build + var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, jdkVersion + "-SNAPSHOT", null); + var message = JVMCIVersionCheck.check(props); + Assert.assertNull("unexpected failure: " + message, message); + } + + @Test + public void testNonJvmciJdk() { + // Use javaSpecVersion and jdkVersion from the runtime + String javaSpecVersion = Integer.toString(Runtime.version().feature()); + String jdkVersion = getJDKVersion(); + // expected to fail because not a JVMCI build + var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, jdkVersion, null); + var message = JVMCIVersionCheck.check(props); + Assert.assertNotNull("unexpectedly passed", message); + Assert.assertTrue("expected error '%s', got '%s'".formatted(EXPECTED_NO_JVMCI, message), message.contains(EXPECTED_NO_JVMCI)); + } + + @Test + public void testNoMinVersion() { + // Use javaSpecVersion and jdkVersion from the runtime + String javaSpecVersion = Integer.toString(Runtime.version().feature()); + String jdkVersion = getJDKVersion(); + // expected to pass, because it is a snapshot build + var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, jdkVersion, null); + JVMCIVersionCheck.check(props, false, null, CollectionsUtil.mapOf()); + } + + @Test + public void testOpenJDKEmptyMinVersion() { + // Use javaSpecVersion and jdkVersion from the runtime + String javaSpecVersion = Integer.toString(Runtime.version().feature()); + String jdkVersion = getJDKVersion(); + // expected to pass, because it is a snapshot build + var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, jdkVersion, null); + try { + JVMCIVersionCheck.check(props, false, null, CollectionsUtil.mapOf("99", CollectionsUtil.mapOf())); + Assert.fail("unexpectedly passing"); + } catch (InternalError e) { + var message = e.getMessage(); + Assert.assertTrue("expected error '%s', got '%s'".formatted(EXPECTED_VM_JDK, message), message.contains(EXPECTED_VM_JDK)); + } + } + + @Test + public void testInternal() { + // Use javaSpecVersion and jdkVersion from the runtime + String javaSpecVersion = Integer.toString(Runtime.version().feature()); + String jdkVersion = getJDKVersion(); + // expected to pass, because it is an internal build + var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, jdkVersion + "-internal", null); + var message = JVMCIVersionCheck.check(props); + Assert.assertNull("unexpected failure: " + message, message); + } + + /** + * Tests {@link JVMCIVersionCheck#check(Map)}, which is only used by truffle. + */ + @Test + public void testTruffleCheck01() { + // Use javaSpecVersion and jdkVersion from the runtime + String javaSpecVersion = Integer.toString(Runtime.version().feature()); + String jdkVersion = getJDKVersion(); + // expected to fail because the release name does not match + var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, jdkVersion + "-jvmci-11.1-b02", null); + var message = JVMCIVersionCheck.check(props); + Assert.assertNotNull("unexpectedly passed", message); + Assert.assertTrue("expected error '%s', got '%s'".formatted(EXPECTED_RELEASE, message), message.contains(EXPECTED_RELEASE)); + } + + /** + * Tests {@link JVMCIVersionCheck#check(Map)}, which is only used by truffle. + */ + @Test + public void testTruffleCheck02() { + // Use javaSpecVersion and jdkVersion from the runtime + String javaSpecVersion = Integer.toString(Runtime.version().feature()); + // expected to pass, because it is newer then specified + // test case just appends a number to the jvmci build number + var props = JVMCIVersionCheckTest.createTestProperties(javaSpecVersion, Runtime.version().toString() + "9", null); + var message = JVMCIVersionCheck.check(props); + Assert.assertNull("unexpected failure: " + message, message); + } + +} diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckOpenJDKTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckOpenJDKTest.java index c55a0417d19d..41efb2bb7e95 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckOpenJDKTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckOpenJDKTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,17 +49,18 @@ public class JVMCIVersionCheckOpenJDKTest extends GraalCompilerTest { public static Collection data() { return List.of( /* - * If comparing a LabsJDK version against an OpenJDK version, ignore the - * JVMCI build number. + * Comparing a LabsJDK version against an OpenJDK version always fails + * unless the OpenJDK version is higher than the LabsJDK version (and thus + * might have required JVMCI changes). */ expectFail("99+99-jvmci-b02", "99+98"), - expectPass("99+99-jvmci-b02", "99+99"), + expectFail("99+99-jvmci-b02", "99+99"), expectPass("99+99-jvmci-b02", "99+100"), /* * Also if comparing against an OpenJDK early access version. */ expectFail("99+99-jvmci-b02", "99-ea+98"), - expectPass("99+99-jvmci-b02", "99-ea+99"), + expectFail("99+99-jvmci-b02", "99-ea+99"), expectPass("99+99-jvmci-b02", "99-ea+100"), /* * OpenJDK version with unknown $PRE value are ignored. @@ -88,9 +89,12 @@ public static Collection data() { expectPass("99+99", "99+99"), expectPass("99+99", "99+100"), - /* Comparing an OpenJDK version against a LabsJDK version. */ + /* + * Comparing an OpenJDK version against a LabsJDK version fails because they + * are not comparable. + */ expectFail("99+99", "99+98-jvmci-b01"), - expectPass("99+99", "99+99-jvmci-b01"), + expectFail("99+99", "99+99-jvmci-b01"), expectPass("99+99", "99+100-jvmci-b01")); } @@ -135,7 +139,7 @@ private static Map> getMinVersion // get the version string without the option part String versionWithoutOptional = version.toString().split("-" + optional, 2)[0]; return CollectionsUtil.mapOf(Integer.toString(version.feature()), CollectionsUtil.mapOf( - DEFAULT_VENDOR_ENTRY, JVMCIVersionCheck.createLabsJDKVersion(versionWithoutOptional, jvmciBuild))); + DEFAULT_VENDOR_ENTRY, JVMCIVersionCheck.createLabsJDKVersionUntilGraalVmForJDK25(versionWithoutOptional, jvmciBuild))); } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckTest.java index dee678c0f693..1271dfcc6e30 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Random; import org.junit.Assert; import org.junit.Test; @@ -49,12 +48,27 @@ public class JVMCIVersionCheckTest extends GraalCompilerTest { private static final String[] JDK_VERSIONS = { - null, "99", "99+3", "99.0.1+3", "99-ea+11-790" }; + private static final String[] RELEASE_NAMES = { + null, + "25.1", + "25.2", + "26.1", + "26.2", + "fooRelease", + "barRelease", + }; + private static final int[] JVMCI_BUILD_NUMBERS = { + 1, + 2, + 5, + 11, + 111 + }; static final Map PROPS; static { @@ -83,24 +97,17 @@ static Map createTestProperties(String javaSpecVersion, String j @Parameters(name = "{0} vs {1}") public static Collection data() { List ret = new ArrayList<>(); - Random random = getRandomInstance(); for (String minJdkVersion : JDK_VERSIONS) { for (String jdkVersion : JDK_VERSIONS) { - for (int i = 0; i < (minJdkVersion == null ? 50 : 1); i++) { - int minMajor = i; - int minMinor = 50 - i; - for (int j = 0; j < (jdkVersion == null ? 50 : 1); j++) { - int major = j; - int minor = 50 - j; - - for (int k = 0; k < 30; k++) { - int minBuild = random.nextInt(100); - int build = random.nextInt(100); - - Version version = getVersion(jdkVersion, major, minor, build); - Version minVersion = getVersion(minJdkVersion, minMajor, minMinor, minBuild); - ret.add(new Object[]{version, minVersion}); + for (String minReleaseName : RELEASE_NAMES) { + for (String releaseName : RELEASE_NAMES) { + for (int minBuild : JVMCI_BUILD_NUMBERS) { + for (int build : JVMCI_BUILD_NUMBERS) { + Version version = getLabsJDKVersion(jdkVersion, releaseName, build); + Version minVersion = getLabsJDKVersion(minJdkVersion, minReleaseName, minBuild); + ret.add(new Object[]{version, minVersion}); + } } } } @@ -109,43 +116,49 @@ public static Collection data() { return ret; } - private static Version getVersion(String jdkVersion, int major, int minor, int build) { - if (jdkVersion != null) { - // new version scheme - return JVMCIVersionCheck.createLabsJDKVersion(jdkVersion, build); - } else { - // legacy version scheme - return JVMCIVersionCheck.createLegacyVersion(major, minor, build); + private static Version getLabsJDKVersion(String jdkVersion, String releaseName, int build) { + if (releaseName == null) { + // legacy version without release name + return JVMCIVersionCheck.createLabsJDKVersionUntilGraalVmForJDK25(jdkVersion, build); } + return JVMCIVersionCheck.createLabsJDKVersion(jdkVersion, releaseName, build); } @Parameter(value = 0) public Version version; @Parameter(value = 1) public Version minVersion; @Test + public void test00() { + test01(); + } + public void test01() { - String legacyPrefix = version.toString().startsWith("jvmci") ? "prefix-" : ""; - String javaVmVersion = legacyPrefix + version.toString() + "Suffix"; + assert !version.toString().startsWith("jvmci"); + String javaVmVersion = version.toString(); // + "Suffix"; String javaSpecVersion = "99"; var props = createTestProperties(javaSpecVersion, javaVmVersion, null); var jvmciMinVersions = CollectionsUtil.mapOf( javaSpecVersion, CollectionsUtil.mapOf(JVMCIVersionCheck.DEFAULT_VENDOR_ENTRY, minVersion)); - if (!version.isLessThan(minVersion)) { - try { - JVMCIVersionCheck.check(props, false, null, jvmciMinVersions); - } catch (InternalError e) { - throw new AssertionError("Failed " + JVMCIVersionCheckTest.class.getSimpleName(), e); - } - } else { - try { - JVMCIVersionCheck.check(props, false, null, jvmciMinVersions); - String value = System.getenv("JVMCI_VERSION_CHECK"); - if (!"warn".equals(value) && !"ignore".equals(value)) { - Assert.fail("expected to fail checking " + javaVmVersion + " against " + minVersion); + try { + if (!version.isLessThan(minVersion)) { + try { + JVMCIVersionCheck.check(props, false, null, jvmciMinVersions); + } catch (InternalError e) { + throw new AssertionError("Failed " + JVMCIVersionCheckTest.class.getSimpleName(), e); + } + } else { + try { + JVMCIVersionCheck.check(props, false, null, jvmciMinVersions); + String value = System.getenv("JVMCI_VERSION_CHECK"); + if (!"warn".equals(value) && !"ignore".equals(value)) { + Assert.fail("expected to fail checking " + javaVmVersion + " against " + minVersion); + } + } catch (InternalError e) { + // pass } - } catch (InternalError e) { - // pass } + } catch (JVMCIVersionCheck.IncomparableVersionException e) { + // pass } } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckVendorTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckVendorTest.java index effa8aeb63ac..4d01f53a2800 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckVendorTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/JVMCIVersionCheckVendorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,8 +44,8 @@ public class JVMCIVersionCheckVendorTest extends GraalCompilerTest { private static final Map> VERSION_MAP = CollectionsUtil.mapOf("99", CollectionsUtil.mapOf( - DEFAULT_VENDOR_ENTRY, JVMCIVersionCheck.createLabsJDKVersion("99+99", 1), - "Vendor Specific", JVMCIVersionCheck.createLabsJDKVersion("99.0.1", 1))); + DEFAULT_VENDOR_ENTRY, JVMCIVersionCheck.createLabsJDKVersion("99+99", "myrelease", 1), + "Vendor Specific", JVMCIVersionCheck.createLabsJDKVersion("99.0.1", "myrelease", 1))); private static void expect(String javaVmVendor, String expected) { var props = JVMCIVersionCheckTest.createTestProperties("99", null, javaVmVendor); @@ -55,12 +55,12 @@ private static void expect(String javaVmVendor, String expected) { @Test public void testVendorDefault() { - expect("Vendor Default", "99+99-jvmci-b01"); + expect("Vendor Default", "99+99-jvmci-myrelease-b01"); } @Test public void testVendorSpecific() { - expect("Vendor Specific", "99.0.1-jvmci-b01"); + expect("Vendor Specific", "99.0.1-jvmci-myrelease-b01"); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java index e985b6d33c5d..9f2fcd56cffa 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ */ package jdk.graal.compiler.hotspot; +import java.io.Serial; import java.util.Collections; import java.util.Formatter; import java.util.LinkedHashMap; @@ -57,8 +58,8 @@ public final class JVMCIVersionCheck { // Checkstyle: stop stable iteration order check private static final Map> JVMCI_MIN_VERSIONS = Map.of( "25", Map.of( - "Oracle Corporation", createLabsJDKVersion("25+37", 6), - DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25+37", 6))); + "Oracle Corporation", createLabsJDKVersion("25+37", "25.1", 7), + DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25+37", "25.1", 7))); // Checkstyle: resume stable iteration order check private static final int NA = 0; @@ -68,11 +69,19 @@ public final class JVMCIVersionCheck { private static final int JAVA_MIN_RELEASE = 25; /** - * Convenience factory for the current version scheme that only uses the JDK version and the - * JVMCI build number. + * Convenience factory for the current version scheme that only uses the JDK version, a release + * name and the JVMCI build number. */ - public static Version createLabsJDKVersion(String jdkVersionString, int jvmciBuild) { - return new Version(jdkVersionString, NA, NA, jvmciBuild, false, false); + public static Version createLabsJDKVersion(String jdkVersionString, String releaseName, int jvmciBuild) { + return new Version(jdkVersionString, Objects.requireNonNull(releaseName), jvmciBuild); + } + + /** + * Convenience factory for the old version scheme used until GraalVM for JDK 25 (internal + * version 25.0) without a release name but only a JDK version and the JVMCI build number. + */ + public static Version createLabsJDKVersionUntilGraalVmForJDK25(String jdkVersionString, int jvmciBuild) { + return new Version(jdkVersionString, null, jvmciBuild); } /** @@ -81,39 +90,71 @@ public static Version createLabsJDKVersion(String jdkVersionString, int jvmciBui * custom LabsJDK build. */ public static Version createOpenJDKVersion(String jdkVersionString) { - return new Version(jdkVersionString, NA, NA, NA, false, true); + return new Version(jdkVersionString, null, NA); + } + + /** + * Denotes that two {@link Version} objects are not comparable. See subclasses for reasons. + */ + public abstract static class IncomparableVersionException extends Exception { + @Serial private static final long serialVersionUID = -3033077236154277911L; + + protected IncomparableVersionException(String message) { + super(message); + } } /** - * Legacy factory for versions without JDK version. This force sets {@link Version#jdkVersion} - * to {@code 21}. While this is not entirely correct, it works for our purposes. + * Denotes that two {@link Version} objects are not comparable. This happens if the + * {@link Version#jdkVersion} is the same but the {@link Version#releaseName} is not. In this + * case, we cannot tell anything about the relation of the two version. + * {@link Version#isComparableRelease} can be used to determine whether two version are + * comparable in principle. */ - public static Version createLegacyVersion(int jvmciMajor, int jvmciMinor, int jvmciBuild) { - return new Version("21", jvmciMajor, jvmciMinor, jvmciBuild, true, false); + public static final class IncomparableReleaseException extends IncomparableVersionException { + + @Serial private static final long serialVersionUID = 8413999811550577857L; + + public IncomparableReleaseException(Version a, Version b) { + super("Incomparable versions for " + a + " and " + b + ". Release names do not match: " + a.releaseName + " and " + b.releaseName); + } + } + + /** + * Denotes that two {@link Version} objects are not comparable. This happens if the + * {@link Version#jdkVersion} is the same but the {@link Version#releaseName} is not. In this + * case, we cannot tell anything about the relation of the two version. + * {@link Version#isComparableRelease} can be used to determine whether two version are + * comparable in principle. + */ + public static final class IncomparableNonJVMCIException extends JVMCIVersionCheck.IncomparableVersionException { + + @Serial private static final long serialVersionUID = 8413999811550577857L; + + public IncomparableNonJVMCIException(Version nonJvmci, Version jvmci) { + super("Cannot compare JVMCI version " + jvmci + " with non-JVMCI version " + nonJvmci); + assert nonJvmci.isOpenJDK(); + assert !jvmci.isOpenJDK(); + } } public static final class Version { private final Runtime.Version jdkVersion; - private final int jvmciMajor; - private final int jvmciMinor; + private final String releaseName; private final int jvmciBuild; - private final boolean legacy; - private final boolean isOpenJDK; static Version parse(String vmVersion) { - Matcher m = Pattern.compile("(.+)-jvmci(-(\\d+)\\.(\\d+))?-b(\\d+).*").matcher(vmVersion); + Matcher m = Pattern.compile("(.+)-jvmci(-(.+))?-b(\\d+).*").matcher(vmVersion); if (m.matches()) { try { + String jdkVersion = m.group(1); if (m.group(3) == null) { - assert m.group(4) == null : "if jvmciMajor is null jvmciMinor must also be null"; - String jdkVersion = m.group(1); - int jvmciBuild = Integer.parseInt(m.group(5)); - return createLabsJDKVersion(jdkVersion, jvmciBuild); + int jvmciBuild = Integer.parseInt(m.group(4)); + return createLabsJDKVersionUntilGraalVmForJDK25(jdkVersion, jvmciBuild); } else { - int jvmciMajor = Integer.parseInt(m.group(3)); - int jvmciMinor = Integer.parseInt(m.group(4)); - int jvmciBuild = Integer.parseInt(m.group(5)); - return createLegacyVersion(jvmciMajor, jvmciMinor, jvmciBuild); + String releaseName = m.group(3); + int jvmciBuild = Integer.parseInt(m.group(4)); + return createLabsJDKVersion(jdkVersion, releaseName, jvmciBuild); } } catch (NumberFormatException e) { @@ -145,87 +186,85 @@ private static String stripVersion(Runtime.Version rv) { return sb.toString(); } - private Version(String jdkVersionString, int jvmciMajor, int jvmciMinor, int jvmciBuild, boolean legacy, boolean isOpenJDK) { - this(Runtime.Version.parse(jdkVersionString), jvmciMajor, jvmciMinor, jvmciBuild, legacy, isOpenJDK); + private Version(String jdkVersionString, String releaseName, int jvmciBuild) { + this(Runtime.Version.parse(jdkVersionString), releaseName, jvmciBuild); } - private Version(Runtime.Version jdkVersion, int jvmciMajor, int jvmciMinor, int jvmciBuild, boolean legacy, boolean isOpenJDK) { + private Version(Runtime.Version jdkVersion, String releaseName, int jvmciBuild) { this.jdkVersion = jdkVersion; - this.jvmciMajor = jvmciMajor; - this.jvmciMinor = jvmciMinor; + this.releaseName = releaseName; this.jvmciBuild = jvmciBuild; - this.legacy = legacy; - this.isOpenJDK = isOpenJDK; } - boolean isGreaterThan(Version other) { - if (!isLessThan(other)) { - return !equals(other); - } - return false; + /** + * Checks whether {@code this} version is comparable to the {@code other} version, i.e., if + * both {@link #releaseName} members are {@linkplain Objects#equals equal}. Note that this + * does not make any assumption on {@link #jdkVersion}. + */ + public boolean isComparableRelease(Version other) { + return Objects.equals(this.releaseName, other.releaseName); } - public boolean isLessThan(Version other) { - if (this.legacy && !other.legacy) { + public boolean isLessThan(Version other) throws IncomparableVersionException { + int compareTo = this.jdkVersion.compareToIgnoreOptional(other.jdkVersion); + if (compareTo < 0) { return true; } - if (this.legacy == other.legacy) { - int compareTo = this.legacy ? 0 : this.jdkVersion.compareToIgnoreOptional(other.jdkVersion); - if (compareTo < 0) { - return true; - } - if (compareTo == 0) { - if (this.isOpenJDK != other.isOpenJDK) { - // comparing OpenJDK version with LabsJDK version. - return false; - } - if (this.jvmciMajor < other.jvmciMajor) { - return true; - } - if (this.jvmciMajor == other.jvmciMajor) { - if (this.jvmciMinor < other.jvmciMinor) { - return true; - } - if (this.jvmciMinor == other.jvmciMinor && this.jvmciBuild < other.jvmciBuild) { - return true; - } + if (compareTo == 0) { + if (this.isOpenJDK() != other.isOpenJDK()) { + // comparing OpenJDK version with LabsJDK version. + if (this.isOpenJDK()) { + throw new IncomparableNonJVMCIException(this, other); + } else { + throw new IncomparableNonJVMCIException(other, this); } } + if (!isComparableRelease(other)) { + throw new IncomparableReleaseException(this, other); + } + if (this.jvmciBuild < other.jvmciBuild) { + return true; + } } return false; } + private boolean isOpenJDK() { + return jvmciBuild == NA; + } + @Override public boolean equals(Object obj) { if (obj instanceof Version that) { - return this.jdkVersion.equals(that.jdkVersion) && this.jvmciMajor == that.jvmciMajor && this.jvmciMinor == that.jvmciMinor && this.jvmciBuild == that.jvmciBuild; + return this.jdkVersion.equals(that.jdkVersion) && Objects.equals(this.releaseName, that.releaseName) && this.jvmciBuild == that.jvmciBuild; } return false; } @Override public int hashCode() { - return this.jdkVersion.hashCode() ^ this.jvmciMajor ^ this.jvmciMinor ^ this.jvmciBuild; + return Objects.hashCode(this.jdkVersion) ^ Objects.hashCode(this.releaseName) ^ this.jvmciBuild; } + public static final String AS_TAG_FORMAT_RELEASE_NAME = "%s-jvmci-%s-b%02d"; public static final String AS_TAG_FORMAT_22_AND_LATER = "%s-jvmci-b%02d"; public static final String AS_TAG_FORMAT_21_AND_EARLIER = "jvmci-%d.%d-b%02d"; @Override public String toString() { - if (isOpenJDK) { + if (isOpenJDK()) { return jdkVersion.toString(); } - if (!legacy) { - return String.format(AS_TAG_FORMAT_22_AND_LATER, jdkVersion, jvmciBuild); + if (releaseName != null) { + return String.format(AS_TAG_FORMAT_RELEASE_NAME, jdkVersion, releaseName, jvmciBuild); } else { - return String.format(AS_TAG_FORMAT_21_AND_EARLIER, jvmciMajor, jvmciMinor, jvmciBuild); + return String.format(AS_TAG_FORMAT_22_AND_LATER, jdkVersion, jvmciBuild); } } public String printFormat(PrintFormat format) { return switch (format) { - case TUPLE -> String.format("%s,%d,%d,%d", jdkVersion, jvmciMajor, jvmciMinor, jvmciBuild); + case TUPLE -> String.format("%s,%s,%d", jdkVersion, releaseName, jvmciBuild); case AS_TAG -> toString(); }; } @@ -235,7 +274,7 @@ public Version stripLTS() { String version = jdkVersion.toString(); assert version.endsWith("-LTS"); String stripped = version.substring(0, version.length() - 4); - return new Version(stripped, jvmciMajor, jvmciMinor, jvmciBuild, legacy, isOpenJDK); + return new Version(stripped, releaseName, jvmciBuild); } else { return this; } @@ -394,8 +433,14 @@ private String run(Version minVersion, PrintFormat format, Map Date: Mon, 20 Oct 2025 09:58:47 +0200 Subject: [PATCH 3/3] compiler: add CollectionsUtil#mapOf() for creating an empty map --- .../src/jdk/graal/compiler/util/CollectionsUtil.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/CollectionsUtil.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/CollectionsUtil.java index cf83e33b1537..8f0e056fe2c8 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/CollectionsUtil.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/CollectionsUtil.java @@ -67,6 +67,17 @@ public static Map mapOfEntries(Map.Entry... entries) { return Collections.unmodifiableMap(newMap); } + /** + * Creates an unmodifiable empty map. + * + * @param the key type + * @param the value type + * @return an unmodifiable empty map + */ + public static Map mapOf() { + return Collections.emptyMap(); + } + /** * Creates an unmodifiable map with a single entry. *