rombert commented on a change in pull request #1: SLING-7365 for unsupported 
java version fall back to Java 9
URL: 
https://github.com/apache/sling-org-apache-sling-commons-compiler/pull/1#discussion_r161230451
 
 

 ##########
 File path: 
src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
 ##########
 @@ -233,9 +233,12 @@ public CompilationResult compile(final CompilationUnit[] 
units,
     }
 
     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);
 
 Review comment:
   To log the warning only once could we not use a static field on the 
EclipseJavaCompiler? If need be, we can even use a `CopyOnWriteArrayList` which 
holds the versions we logged for before ( I don't expect thousands of Java 
versions :-) ) and have some logic similar to
   
   ```java
   if ( warnings.add(javaVersion) ) {
      // log 
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to