Skip to content

Commit

Permalink
update README and version check for new JVMCI requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Jul 2, 2018
1 parent 4e4071a commit 49889ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
12 changes: 6 additions & 6 deletions compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ git clone https://github.com/graalvm/mx.git
export PATH=$PWD/mx:$PATH
```

Graal depends on a JDK that supports JVMCI ([JVM Compiler Interface](https://bugs.openjdk.java.net/browse/JDK-8062493)). There is a JVMCI
[port](https://github.com/graalvm/graal-jvmci-8) for JDK 8 and JVMCI is built into the JDK as of JDK 9.
Graal depends on a JDK that supports a compatible version of JVMCI ([JVM Compiler Interface](https://bugs.openjdk.java.net/browse/JDK-8062493)). There is a JVMCI
[port](https://github.com/graalvm/graal-jvmci-8) for JDK 8 and the required JVMCI version is built into the JDK as of JDK 11-ea+20.

Graal currently requires a JVMCI-enabled JDK 8 (download from [OTN](http://www.oracle.com/technetwork/oracle-labs/program-languages/downloads/index.html) or [build](#building-jvmci-jdk8) yourself) and will do so until all JDK 8 specific Graal code is factored out as [versioned sources](https://github.com/graalvm/mx#versioning-sources-for-different-jdk-releases).
Developing versioned sources specific to other JDKs requires them to be made
available on the `EXTRA_JAVA_HOMES` environment variable. At the time of writing, this means JDK 9
and JDK 11 ([early access builds](http://jdk.java.net/11/) should work but a build from
available on the `EXTRA_JAVA_HOMES` environment variable. At the time of writing, this
JDK 11-ea+20 ([early access build](http://jdk.java.net/11/) should work but a build from
the [latest bits](http://hg.openjdk.java.net/jdk/jdk/) is required if Graal targets features not yet in an early access build).

Here is a typical set up for specifying multiple JDKs on Linux:
```
export JAVA_HOME=/usr/lib/jvm/labsjdk1.8.0_172-jvmci-0.44
export EXTRA_JAVA_HOMES=/usr/lib/jvm/jdk-9.0.4:/usr/lib/jvm/jdk-11
export EXTRA_JAVA_HOMES=/usr/lib/jvm/jdk-11
```
And on macOS:
```
export JAVA_HOME=/Library/Java/JavaVirtualMachines/labsjdk1.8.0_172-jvmci-0.44/Contents/Home
export EXTRA_JAVA_HOMES=/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home:/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
export EXTRA_JAVA_HOMES=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
```
If you omit `EXTRA_JAVA_HOMES`, the associated sources will not be built. Note that `JAVA_HOME` defines the *primary* JDK for development. For instance, when running `mx vm`, this is the JDK that will be used so if you want to run on JDK 11, swap JDK 8 and JDK 11 in `JAVA_HOME` and `EXTRA_JAVA_HOMES`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
class JVMCIVersionCheck {

private static final int JVMCI8_MIN_MAJOR_VERSION = 0;
private static final int JVMCI8_MIN_MINOR_VERSION = 29;
private static final int JVMCI8_MIN_MINOR_VERSION = 46;

private static void failVersionCheck(boolean exit, String reason, Object... args) {
Formatter errorMessage = new Formatter().format(reason, args);
Expand All @@ -52,7 +52,7 @@ private static void failVersionCheck(boolean exit, String reason, Object... args
if (System.getProperty("java.specification.version").compareTo("1.9") < 0) {
errorMessage.format("Download the latest JVMCI JDK 8 from http://www.oracle.com/technetwork/oracle-labs/program-languages/downloads/index.html");
} else {
errorMessage.format("Download the latest JDK 9 build from https://jdk9.java.net/download/");
errorMessage.format("Download JDK 11 or later.");
}
String value = System.getenv("JVMCI_VERSION_CHECK");
if ("warn".equals(value)) {
Expand All @@ -69,8 +69,9 @@ private static void failVersionCheck(boolean exit, String reason, Object... args

static void check(boolean exitOnFailure) {
// Don't use regular expressions to minimize Graal startup time
String javaSpecVersion = System.getProperty("java.specification.version");
String vmVersion = System.getProperty("java.vm.version");
if (System.getProperty("java.specification.version").compareTo("1.9") < 0) {
if (javaSpecVersion.compareTo("1.9") < 0) {
int start = vmVersion.indexOf("-jvmci-");
if (start >= 0) {
start += "-jvmci-".length();
Expand Down Expand Up @@ -107,18 +108,28 @@ static void check(boolean exitOnFailure) {
}
failVersionCheck(exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
"Cannot read JVMCI version from java.vm.version property: %s.%n", vmVersion);
} else if (javaSpecVersion.compareTo("11") < 0) {
failVersionCheck(exitOnFailure, "Graal is not compatible with the JVMCI API in JDK 9 and 10.%n");
} else {
if (vmVersion.contains("SNAPSHOT")) {
// The snapshot of http://hg.openjdk.java.net/jdk9/dev tip is expected to work
return;
}
if (vmVersion.contains("internal")) {
// Allow local builds
return;
}
if (vmVersion.startsWith("9-ea")) {
failVersionCheck(exitOnFailure, "This version of Graal is not compatible with JDK 9 Early Access builds.%n");
return;
if (vmVersion.startsWith("11-ea+")) {
String buildString = vmVersion.substring("11-ea+".length());
try {
int build = Integer.parseInt(buildString);
if (build < 20) {
failVersionCheck(exitOnFailure, "Graal requires build 20 or later of JDK 11 early access binary, got build %d.%n", build);
return;
}
} catch (NumberFormatException e) {
failVersionCheck(exitOnFailure, "Could not parse the JDK 11 early access build number from java.vm.version property: %s.%n", vmVersion);
return;
}
} else {
// Graal is compatible with all JDK versions as of 9 GA.
}
Expand Down

0 comments on commit 49889ce

Please sign in to comment.