Author: markt
Date: Sun Apr 22 11:00:27 2018
New Revision: 1829777
URL: http://svn.apache.org/viewvc?rev=1829777&view=rev
Log:
Enable ECJ version 4.7 and later to be used as a drop in replacement for the
ECJ version that ships with Apache Tomcat.
Modified:
tomcat/tc8.5.x/trunk/java/org/apache/jasper/compiler/JDTCompiler.java
tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc8.5.x/trunk/java/org/apache/jasper/compiler/JDTCompiler.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/jasper/compiler/JDTCompiler.java?rev=1829777&r1=1829776&r2=1829777&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/jasper/compiler/JDTCompiler.java
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/jasper/compiler/JDTCompiler.java Sun
Apr 22 11:00:27 2018
@@ -27,6 +27,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
@@ -62,6 +63,33 @@ import org.eclipse.jdt.internal.compiler
*/
public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
+ private static final String JDT_JAVA_9_VERSION;
+
+ static {
+ // The constant for Java 9 changed between 4.6 and 4.7 in a way that is
+ // not backwards compatible. Need to figure out which version is in use
+ // so the correct constant value is used.
+
+ String jdtJava9Version = null;
+
+ Class<?> clazz = CompilerOptions.class;
+
+ for (Field field : clazz.getFields()) {
+ if ("VERSION_9".equals(field.getName())) {
+ // 4.7 onwards: CompilerOptions.VERSION_9
+ jdtJava9Version = "9";
+ break;
+ }
+ }
+
+ if (jdtJava9Version == null) {
+ // 4.6 and earlier: CompilerOptions.VERSION_1_9
+ jdtJava9Version = "1.9";
+ }
+
+ JDT_JAVA_9_VERSION = jdtJava9Version;
+ }
+
private final Log log = LogFactory.getLog(JDTCompiler.class); // must not
be static
/**
@@ -312,9 +340,10 @@ public class JDTCompiler extends org.apa
} else if(opt.equals("1.8")) {
settings.put(CompilerOptions.OPTION_Source,
CompilerOptions.VERSION_1_8);
- } else if(opt.equals("1.9")) {
+ // Support old format that was used in EA implementation as well
+ } else if(opt.equals("9") || opt.equals("1.9")) {
settings.put(CompilerOptions.OPTION_Source,
- CompilerOptions.VERSION_1_9);
+ JDT_JAVA_9_VERSION);
} else {
log.warn("Unknown source VM " + opt + " ignored.");
settings.put(CompilerOptions.OPTION_Source,
@@ -361,11 +390,11 @@ public class JDTCompiler extends org.apa
CompilerOptions.VERSION_1_8);
settings.put(CompilerOptions.OPTION_Compliance,
CompilerOptions.VERSION_1_8);
- } else if(opt.equals("1.9")) {
+ } else if(opt.equals("9") || opt.equals("1.9")) {
settings.put(CompilerOptions.OPTION_TargetPlatform,
- CompilerOptions.VERSION_1_9);
+ JDT_JAVA_9_VERSION);
settings.put(CompilerOptions.OPTION_Compliance,
- CompilerOptions.VERSION_1_9);
+ JDT_JAVA_9_VERSION);
} else {
log.warn("Unknown target VM " + opt + " ignored.");
settings.put(CompilerOptions.OPTION_TargetPlatform,
Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1829777&r1=1829776&r2=1829777&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Sun Apr 22 11:00:27 2018
@@ -79,6 +79,14 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ Enable ECJ version 4.7 and later to be used as a drop in replacement
for
+ the ECJ version that ships with Apache Tomcat. (markt)
+ </fix>
+ </changelog>
+ </subsection>
</section>
<section name="Tomcat 8.5.30 (markt)" rtext="2018-04-07">
<subsection name="Catalina">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]