Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-60387] Fix mx jvmci-version-check --as-tag for LTS versions. #10336

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 0 additions & 2 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ def _capture_jvmci_version(args=None):
if out.data:
try:
(jdk_version, jvmci_major, jvmci_minor, jvmci_build) = out.data.split(',')
if jdk_version.endswith('-LTS'):
jdk_version = jdk_version[:-len('-LTS')]
return JVMCIVersionCheckVersion(JavaLangRuntimeVersion(jdk_version), int(jvmci_major), int(jvmci_minor), int(jvmci_build))
except ValueError:
mx.warn(f'Could not parse jvmci version from JVMCIVersionCheck output:\n{out.data}')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024, 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 jdk.graal.compiler.core.test.GraalCompilerTest;
import jdk.graal.compiler.hotspot.JVMCIVersionCheck;
import org.junit.Assert;
import org.junit.Test;

/**
* 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);
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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ public String printFormat(PrintFormat format) {
case AS_TAG -> toString();
};
}

public Version stripLTS() {
if ("LTS".equals(jdkVersion.optional().orElse(null))) {
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);
} else {
return this;
}
}
}

public static final String OPEN_LABSJDK_RELEASE_URL_PATTERN = "https://github.com/graalvm/labs-openjdk-*/releases";
Expand Down Expand Up @@ -369,7 +380,7 @@ private String run(Version minVersion, PrintFormat format) {
Version v = Version.parse(vmVersion);
if (v != null) {
if (format != null) {
System.out.println(v.printFormat(format));
System.out.println(v.stripLTS().printFormat(format));
}
if (v.isLessThan(minVersion)) {
return String.format("The VM does not support the minimum JVMCI API version required by Graal: %s < %s.", v, minVersion);
Expand Down