Skip to content

Commit bcdf565

Browse files
committed
[GR-41724] JVMCIVersionCheck should print to stdout instead of to a file
PullRequest: graal/12933
2 parents 71914d8 + 6c8b355 commit bcdf565

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

compiler/mx.compiler/mx_compiler.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,11 @@ def source_supplier():
123123
fp.write(source_supplier().replace('package org.graalvm.compiler.hotspot;', ''))
124124
mx.run([jdk.javac, '-d', sdu.directory, unqualified_source_path])
125125

126-
jvmci_version_file = join(binDir, 'jvmci_version.' + str(os.getpid()))
127-
mx.run([jdk.java, '-DJVMCIVersionCheck.jvmci.version.file=' + jvmci_version_file, '-cp', binDir, unqualified_name])
128-
if exists(jvmci_version_file):
129-
with open(jvmci_version_file) as fp:
130-
global _jdk_jvmci_version
131-
_jdk_jvmci_version = tuple((int(n) for n in fp.read().split(',')))
132-
os.remove(jvmci_version_file)
126+
out = mx.OutputCapture()
127+
mx.run([jdk.java, '-cp', binDir, unqualified_name], out=out)
128+
global _jdk_jvmci_version
129+
if out.data:
130+
_jdk_jvmci_version = tuple((int(n) for n in out.data.split(',')))
133131

134132
if os.environ.get('JVMCI_VERSION_CHECK', None) != 'ignore':
135133
_check_jvmci_version(jdk)

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfigAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static boolean jvmciGE(Version v) {
146146
public static final boolean JDK_PRERELEASE;
147147
static {
148148
String vmVersion = getProperty("java.vm.version");
149-
JVMCI_VERSION = Version.parse(vmVersion, Services.getSavedProperties());
149+
JVMCI_VERSION = Version.parse(vmVersion);
150150
JDK_PRERELEASE = vmVersion.contains("SNAPSHOT") || vmVersion.contains("-dev");
151151
JVMCI = JVMCI_VERSION != null;
152152
}

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalCompilerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void onSelection() {
114114
}
115115

116116
private void initialize() {
117-
JVMCIVersionCheck.check(Services.getSavedProperties(), false);
117+
JVMCIVersionCheck.check(Services.getSavedProperties(), false, true);
118118
assert options == null : "cannot select " + getClass() + " service more than once";
119119
try {
120120
options = HotSpotGraalOptionValues.defaultOptions();

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/JVMCIVersionCheck.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
*/
2525
package org.graalvm.compiler.hotspot;
2626

27-
import java.io.IOException;
28-
import java.io.UncheckedIOException;
29-
import java.nio.file.Files;
30-
import java.nio.file.Paths;
3127
import java.util.Formatter;
3228
import java.util.HashMap;
3329
import java.util.Map;
@@ -54,21 +50,13 @@ public static class Version {
5450
private final int minor;
5551
private final int build;
5652

57-
static Version parse(String vmVersion, Map<String, String> props) {
53+
static Version parse(String vmVersion) {
5854
Matcher m = Pattern.compile(".*-jvmci-(\\d+)\\.(\\d+)-b(\\d+).*").matcher(vmVersion);
5955
if (m.matches()) {
6056
try {
6157
int major = Integer.parseInt(m.group(1));
6258
int minor = Integer.parseInt(m.group(2));
6359
int build = Integer.parseInt(m.group(3));
64-
String jvmciVersionFile = props.get("JVMCIVersionCheck.jvmci.version.file");
65-
if (jvmciVersionFile != null) {
66-
try {
67-
Files.write(Paths.get(jvmciVersionFile), String.format("%d,%d,%d", major, minor, build).getBytes());
68-
} catch (IOException e) {
69-
throw new UncheckedIOException(e);
70-
}
71-
}
7260
return new Version(major, minor, build);
7361
} catch (NumberFormatException e) {
7462
// ignore
@@ -163,9 +151,9 @@ private JVMCIVersionCheck(Map<String, String> props, String javaSpecVersion, Str
163151
this.vmVersion = vmVersion;
164152
}
165153

166-
static void check(Map<String, String> props, boolean exitOnFailure) {
154+
static void check(Map<String, String> props, boolean exitOnFailure, boolean quiet) {
167155
JVMCIVersionCheck checker = new JVMCIVersionCheck(props, props.get("java.specification.version"), props.get("java.vm.version"));
168-
checker.run(exitOnFailure, JVMCI_MIN_VERSION);
156+
checker.run(exitOnFailure, JVMCI_MIN_VERSION, quiet);
169157
}
170158

171159
/**
@@ -176,10 +164,10 @@ public static void check(Map<String, String> props,
176164
String javaSpecVersion,
177165
String javaVmVersion, boolean exitOnFailure) {
178166
JVMCIVersionCheck checker = new JVMCIVersionCheck(props, javaSpecVersion, javaVmVersion);
179-
checker.run(exitOnFailure, minVersion);
167+
checker.run(exitOnFailure, minVersion, true);
180168
}
181169

182-
private void run(boolean exitOnFailure, Version minVersion) {
170+
private void run(boolean exitOnFailure, Version minVersion, boolean quiet) {
183171
if (javaSpecVersion.compareTo("11") < 0) {
184172
failVersionCheck(exitOnFailure, "Graal requires JDK 11 or later.%n");
185173
} else {
@@ -192,8 +180,11 @@ private void run(boolean exitOnFailure, Version minVersion) {
192180
}
193181
if (vmVersion.contains("-jvmci-")) {
194182
// A "labsjdk"
195-
Version v = Version.parse(vmVersion, props);
183+
Version v = Version.parse(vmVersion);
196184
if (v != null) {
185+
if (!quiet) {
186+
System.out.println(String.format("%d,%d,%d", v.major, v.minor, v.build));
187+
}
197188
if (v.isLessThan(minVersion)) {
198189
failVersionCheck(exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal: %s < %s.%n", v, minVersion);
199190
}
@@ -216,6 +207,6 @@ public static void main(String[] args) {
216207
for (String name : sprops.stringPropertyNames()) {
217208
props.put(name, sprops.getProperty(name));
218209
}
219-
check(props, true);
210+
check(props, true, false);
220211
}
221212
}

0 commit comments

Comments
 (0)