mx: --strict-compliance is now the only supported mode

Doug Simon doug.simon at
Fri Jun 1 14:54:36 UTC 2018

Historically, mx has used a non-strict algorithm when deciding which JDK to use for compiling a project with Java compliance N. The motivation was to support using a single JDK for all compilation. For Java code that only uses public JDK API, this was not a problem. However, both Graal and SVM use non-public JDK API which complicates things. To make it possible to use javac from JDK 9 with a `--release 8` option to compile a project that uses JDK 8 internal API (e.g. sun.misc.Unsafe), mx provided skeletons for the API in question (e.g., <>) since the `--release` mechanism only provides symbol for public JDK API. However, this approach did not scale as it meant skeletons need to be provided for every internal API used by any mx project. A better approach is to simply enforce a strict JDK matching algorithm. That is, if a project has a Java compliance of 8, then a JDK 8 must be made available (via JAVA_HOME/EXTRA_JAVA_HOMES or --java-home/--extra-java-homes).

Mx has now been changed <> to enforce this.
Prior to this change, a Java compliance could be either exact or open ended:
Compliance Value	Compatible JDKs for compilation
8	JDK8
9+	JDK9, JDK10, JDK11, ...

Since a project may use internal API that spans only a fixed set of JDKs, Java compliance now also supports a fixed range:
Compliance Value	Compatible JDKs for compilation
8	JDK8
9+	JDK9, JDK10, JDK11, ...
9..10	JDK9, JDK10
The lower bound in a fixed range specifies the language level. That is, it will be used as the value for the -source and -target javac options.

One noticeable impact is that the auto-JDK-selection in mx has been moved to a separate utility: When mx cannot find a JDK it needs, you will now get an error message such as:

Could not find a JDK
The following JDKs are available:
Specify one with the --java-home or --extra-java-homes option or with the JAVA_HOME or EXTRA_JAVA_HOMES environment variable.
Or run `/Users/dsimon/mx/ -p /Users/dsimon/graal/graal/compiler` to set and persist these variables in /Users/dsimon/graal/graal/compiler/mx.compiler/env.

The last line shows you how to run the utility to configure your env file.

This utility can also be used to define a `select_jdk` shell function as described here:

Please feel free to reply or open mx issues on GitHub if you run into any problems as a result of this change.


More information about the graal-dev mailing list