This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push: new d3a79b7 Add Java 12 and Java 13 support d3a79b7 is described below commit d3a79b7c5f041efa71c6c3b35ab9ecf7a70b4e99 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Mar 21 12:29:43 2019 +0000 Add Java 12 and Java 13 support If used with an ECJ version that does not support these values, a warning will be logged and the latest supported version will used. Based on a patch by Thomas Collignon. --- java/org/apache/jasper/compiler/JDTCompiler.java | 57 +++++++++++++++++++--- .../jasper/resources/LocalStrings.properties | 4 ++ webapps/docs/changelog.xml | 8 +++ 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java index 5f1d07a..8124bd0 100644 --- a/java/org/apache/jasper/compiler/JDTCompiler.java +++ b/java/org/apache/jasper/compiler/JDTCompiler.java @@ -377,14 +377,26 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { JDT_JAVA_9_VERSION); } else if(opt.equals("10")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 6. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_Source, "10"); } else if(opt.equals("11")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 6. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_Source, "11"); + } else if(opt.equals("12")) { + // Constant not available in latest available ECJ version. + // May be supported in a snapshot build. + // This is checked against the actual version below. + settings.put(CompilerOptions.OPTION_Source, "12"); + } else if(opt.equals("13")) { + // Constant not available in latest available ECJ version. + // May be supported in a snapshot build. + // This is checked against the actual version below. + settings.put(CompilerOptions.OPTION_Source, "13"); } else { - log.warn("Unknown source VM " + opt + " ignored."); + log.warn(Localizer.getMessage("jsp.warning.unknown.sourceVM", opt)); settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); } @@ -436,16 +448,30 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { JDT_JAVA_9_VERSION); } else if(opt.equals("10")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 6. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_TargetPlatform, "10"); settings.put(CompilerOptions.OPTION_Compliance, "10"); } else if(opt.equals("11")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 6. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_TargetPlatform, "11"); settings.put(CompilerOptions.OPTION_Compliance, "11"); + } else if(opt.equals("12")) { + // Constant not available in latest available ECJ version. + // May be supported in a snapshot build. + // This is checked against the actual version below. + settings.put(CompilerOptions.OPTION_TargetPlatform, "12"); + settings.put(CompilerOptions.OPTION_Compliance, "12"); + } else if(opt.equals("13")) { + // Constant not available in latest available ECJ version. + // May be supported in a snapshot build. + // This is checked against the actual version below. + settings.put(CompilerOptions.OPTION_TargetPlatform, "13"); + settings.put(CompilerOptions.OPTION_Compliance, "13"); } else { - log.warn("Unknown target VM " + opt + " ignored."); + log.warn(Localizer.getMessage("jsp.warning.unknown.targetVM", opt)); settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); } @@ -526,6 +552,25 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { compilationUnits[i] = new CompilationUnit(fileNames[i], className); } CompilerOptions cOptions = new CompilerOptions(settings); + + // Check source/target JDK versions as the newest versions are allowed + // in Tomcat configuration but may not be supported by the ECJ version + // being used. + String requestedSource = ctxt.getOptions().getCompilerSourceVM(); + if (requestedSource != null) { + String actualSource = CompilerOptions.versionFromJdkLevel(cOptions.sourceLevel); + if (!requestedSource.equals(actualSource)) { + log.warn(Localizer.getMessage("jsp.warning.unsupported.sourceVM", requestedSource, actualSource)); + } + } + String requestedTarget = ctxt.getOptions().getCompilerTargetVM(); + if (requestedTarget != null) { + String actualTarget = CompilerOptions.versionFromJdkLevel(cOptions.targetJDK); + if (!requestedTarget.equals(actualTarget)) { + log.warn(Localizer.getMessage("jsp.warning.unsupported.targetVM", requestedTarget, actualTarget)); + } + } + cOptions.parseLiteralExpressionsAsConstants = true; Compiler compiler = new Compiler(env, policy, diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index 5277cda..fe62b10 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -188,6 +188,10 @@ jsp.warning.unknown.element.in.variable=Unknown element ({0}) in variable jsp.warning.unknown.element.in.validator=Unknown element ({0}) in validator jsp.warning.unknown.element.in.initParam=Unknown element ({0}) in validator''s init-param jsp.warning.unknown.element.in.function=Unknown element ({0}) in function +jsp.warning.unknown.sourceVM=Unknown source VM [{0}] ignored +jsp.warning.unknown.targetVM=Unknown target VM [{0}] ignored +jsp.warning.unsupported.sourceVM=Unsupported source VM [{0}] requested, using [{1}] +jsp.warning.unsupported.targetVM=Unsupported target VM [{0}] requested, using [{1}] jsp.error.more.than.one.taglib=More than one taglib in the TLD: {0} jsp.error.teiclass.instantiation=Failed to load or instantiate TagExtraInfo class: {0} jsp.error.non_null_tei_and_var_subelems=Tag {0} has one or more variable subelements and a TagExtraInfo class that returns one or more VariableInfo diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 33b3d3e..387c850 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -137,6 +137,14 @@ Add support for specifying Java 11 (with the value <code>11</code>) as the compiler source and/or compiler target for JSP compilation. (markt) </add> + <add> + Add support for specifying Java 12 (with the value <code>12</code>) and + Java 13 (with the value <code>13</code>) as the compiler source and/or + compiler target for JSP compilation. If used with an ECJ version that + does not support these values, a warning will be logged and the latest + supported version will used. Based on a patch by Thomas Collignon. + (markt) + </add> </changelog> </subsection> <subsection name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org