You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2018/01/15 09:34:48 UTC
[sling-org-apache-sling-commons-compiler] branch master updated:
SLING-7365 for unsupported java version fall back to Java 9
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-compiler.git
The following commit(s) were added to refs/heads/master by this push:
new e6ae4d4 SLING-7365 for unsupported java version fall back to Java 9
e6ae4d4 is described below
commit e6ae4d43311e7cb708a2bc10f7466ea6e0412e39
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
This closes #1
---
pom.xml | 5 +++--
.../sling/commons/compiler/impl/EclipseJavaCompiler.java | 16 +++++++++++++---
2 files changed, 16 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..564b232 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
@@ -26,6 +26,8 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
import org.apache.sling.commons.classloader.ClassLoaderWriter;
import org.apache.sling.commons.compiler.CompilationResult;
@@ -70,6 +72,8 @@ public class EclipseJavaCompiler implements JavaCompiler {
/** the static policy. */
private final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
+
+ private final Set<String> warningEmittedForUnsupportedJavaVersion = new CopyOnWriteArraySet<>();
/**
* Get the classloader for the compilation.
@@ -233,9 +237,15 @@ 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) {
+ // only log once per invalid javaVersion
+ if (!warningEmittedForUnsupportedJavaVersion.contains(javaVersion) && warningEmittedForUnsupportedJavaVersion.add(javaVersion)) {
+ 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>'].