diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-02-05 14:50:45 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-02-05 16:46:39 +0000 |
commit | 1b48f0161754bb3ffa453d3c55a9d9497fd20111 (patch) | |
tree | 87c6d845283e5b4aed1a8afbe564a39c5903138d /share/qbs/modules/java/utils.js | |
parent | 4cc46c923b3ed7e69d1edfba32b11a9b9008bcd1 (diff) | |
download | qbs-1b48f0161754bb3ffa453d3c55a9d9497fd20111.tar.gz |
Java: Adapt to Java 9 changes
- tools.jar and rt.jar are gone
- The -bootclasspath option is not allowed when targeting Java 9
- JavaCompiler.isSupportedOption() (erroneously?) returns 1 instead of 0
for -Xlint
- version number related changes:
- major version has jumped to 9
- javac prints the version number to stdout rather than stderr
- version number no longer contains a forth component
- The -source and -target options take only the major version
Change-Id: I0b23c8868db7aeaa06785ee43c1efd9fcb1bc9d2
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'share/qbs/modules/java/utils.js')
-rw-r--r-- | share/qbs/modules/java/utils.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/share/qbs/modules/java/utils.js b/share/qbs/modules/java/utils.js index be117d98e..52c0e880a 100644 --- a/share/qbs/modules/java/utils.js +++ b/share/qbs/modules/java/utils.js @@ -136,8 +136,10 @@ function findJdkVersion(compilerFilePath) { var p = new Process(); try { p.exec(compilerFilePath, ["-version"]); - var re = /^javac (([0-9]+(?:\.[0-9]+){2,2})_([0-9]+))$/m; + var re = /^javac (([0-9]+(?:\.[0-9]+){2,2})(_([0-9]+))?)$/m; var match = p.readStdErr().trim().match(re); + if (!match) + match = p.readStdOut().trim().match(re); if (match !== null) return match; } finally { @@ -194,8 +196,10 @@ function javacArguments(product, inputs, overrides) { if (languageVersion) args.push("-source", languageVersion); var bootClassPaths = getModuleProperties(product, "bootClassPaths", overrides); - if (bootClassPaths && bootClassPaths.length > 0) + if (bootClassPaths && bootClassPaths.length > 0 + && (!runtimeVersion || Utilities.versionCompare(runtimeVersion, "9") < 0)) { args.push("-bootclasspath", bootClassPaths.join(pathListSeparator)); + } if (!getModuleProperty(product, "enableWarnings", overrides)) args.push("-nowarn"); if (getModuleProperty(product, "warningsAsErrors", overrides)) @@ -255,8 +259,10 @@ function helperOverrideArgs(product, tool) { // compiled with. Both are irrelevant here since the resulting tool will only be run // with the same JDK as it was built with, and we know in advance the source is // compatible with all Java language versions from 1.6 and above. - var jdkVersion = [ModUtils.moduleProperty(product, "compilerVersionMajor"), - ModUtils.moduleProperty(product, "compilerVersionMinor")].join("."); + var jdkVersionArray = [product.java.compilerVersionMajor]; + if (product.java.compilerVersionMajor < 9) + jdkVersionArray.push(product.java.compilerVersionMinor); + var jdkVersion = jdkVersionArray.join("."); overrides["languageVersion"] = jdkVersion; overrides["runtimeVersion"] = jdkVersion; @@ -273,7 +279,8 @@ function helperOverrideArgs(product, tool) { // Inject the current JDK's runtime classes into the boot class path when building/running the // dependency scanner. This is normally not necessary but is important for Android platforms // where android.jar is the only JAR on the boot classpath and JSR 199 is unavailable. - overrides["bootClassPaths"] = [ModUtils.moduleProperty(product, "runtimeJarPath")].concat( + var rtJarPath = product.java.runtimeJarPath; + overrides["bootClassPaths"] = (rtJarPath ? [rtJarPath] : []).concat( ModUtils.moduleProperty(product, "bootClassPaths")); return overrides; } |