SLING-7105 - Some JSP tests fail under Java 9 - parameterized types are
authorRobert Munteanu <rombert@apache.org>
Tue, 12 Sep 2017 19:50:07 +0000 (19:50 +0000)
committerRobert Munteanu <rombert@apache.org>
Tue, 12 Sep 2017 19:50:07 +0000 (19:50 +0000)
only available if source level is 1.5 or greater

- pass Java version as 1.9 instead of 9, as Eclipse expects that
- update to ecj 4.6.1

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1808147 13f79535-47bb-0310-9956-ffa450edef68

pom.xml
src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java

diff --git a/pom.xml b/pom.xml
index d1bd3de..5de2242 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -91,7 +91,7 @@
         <dependency>
             <groupId>org.eclipse.jdt.core.compiler</groupId>
             <artifactId>ecj</artifactId>
-            <version>4.5.1</version>
+            <version>4.6.1</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
index 49d4a5e..160bb6b 100644 (file)
@@ -198,11 +198,11 @@ public class EclipseJavaCompiler implements JavaCompiler {
             props.put(CompilerOptions.OPTION_SourceFileAttribute, "generate");
         }
         if (options.getSourceVersion() != null) {
-            props.put(CompilerOptions.OPTION_Source, options.getSourceVersion());
-            props.put(CompilerOptions.OPTION_Compliance, options.getSourceVersion());
+            props.put(CompilerOptions.OPTION_Source, adjustJavaVersion(options.getSourceVersion()));
+            props.put(CompilerOptions.OPTION_Compliance, adjustJavaVersion(options.getSourceVersion()));
         }
         if (options.getTargetVersion() != null) {
-            props.put(CompilerOptions.OPTION_TargetPlatform, options.getTargetVersion());
+            props.put(CompilerOptions.OPTION_TargetPlatform, adjustJavaVersion(options.getTargetVersion()));
         }
         props.put(CompilerOptions.OPTION_Encoding, "UTF8");
 
@@ -232,6 +232,12 @@ public class EclipseJavaCompiler implements JavaCompiler {
         return result;
     }
 
+    private String adjustJavaVersion(String javaVersion) {
+
+        // ECJ 4.6.1 expects Java version 1.9, not 9
+        return "9".equals(javaVersion) ? "1.9" : javaVersion;
+    }
+
     //--------------------------------------------------------< inner classes >
 
     private class CompileContext implements ICompilerRequestor, INameEnvironment {