Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
51 changes: 27 additions & 24 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,44 +125,41 @@ 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

jdk_version is a JavaLangRuntimeVersion
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
Expand All @@ -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
Expand Down Expand Up @@ -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<jdk_version>.+)-jvmci(?:-(?P<jvmci_major>\d+)\.(?P<jvmci_minor>\d+))?-b(?P<jvmci_build>\d+)')
jvmci_re = re.compile(r'(?:ce|ee)-(?P<jdk_version>.+)-jvmci(?:-(?P<release_name>.+))?-b(?P<jvmci_build>\d+)')
common_path = os.path.normpath(join(_suite.dir, '..', 'common.json'))

if _jdk_jvmci_version is None:
Expand All @@ -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':
Expand Down Expand Up @@ -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/(.+)')
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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"});
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
}
Expand Down
Loading