You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2018/01/12 13:05:35 UTC
[sling-org-apache-sling-commons-compiler] 01/01: SLING-7365 for
unsupported java version fall back to Java 9
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/support-java-10
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git
commit 74f012c18f8ea2abb53c42b826e1aff295b92e1d
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Jan 12 14:05:27 2018 +0100
SLING-7365 for unsupported java version fall back to Java 9
also upgrade to the latest Eclipse Java Compiler (with the right GAV)
shipped with Oxygen .2
---
pom.xml | 5 +++--
.../apache/sling/commons/compiler/impl/EclipseJavaCompiler.java | 9 ++++++---
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6996c97..946895a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,10 +88,11 @@
<version>1.3.0</version>
<scope>provided</scope>
</dependency>
+ <!-- the correct GAV is referenced in https://bugs.eclipse.org/bugs/show_bug.cgi?id=499019#c19 -->
<dependency>
- <groupId>org.eclipse.jdt.core.compiler</groupId>
+ <groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
- <version>4.6.1</version>
+ <version>3.13.100</version> <!-- this is the version shipped in Oxygen .2 -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
index 160bb6b..0a4ab90 100644
--- a/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
+++ b/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
@@ -233,9 +233,12 @@ public class EclipseJavaCompiler implements JavaCompiler {
}
private String adjustJavaVersion(String javaVersion) {
-
- // ECJ 4.6.1 expects Java version 1.9, not 9
- return "9".equals(javaVersion) ? "1.9" : javaVersion;
+ // use latest supported version (Java 9) in case the given java version is not supported by ECJ yet
+ if (CompilerOptions.versionToJdkLevel(javaVersion) == 0) {
+ logger.warn("Using unsupported java version '{}', assuming latest supported version '{}'", javaVersion, CompilerOptions.VERSION_9);
+ return CompilerOptions.VERSION_9;
+ }
+ return javaVersion;
}
//--------------------------------------------------------< inner classes >
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.